public Object freeze(ColumnLoader.ValueSet valueSet, int[] sources) { final int n = valueSet.map.keySet().size(); int extra = valueSet.containsNull ? 1 : 0; Comparable[] codeValues = valueSet.map.keySet().toArray(new Comparable[n + extra]); Arrays.sort(codeValues, 0, n); ColumnLoader.ValueSet codeValueSet = new ColumnLoader.ValueSet(int.class); final List<Comparable> list = permuteList(valueSet.values, sources); for (Comparable value : list) { int code; if (value == null) { code = n; } else { code = Arrays.binarySearch(codeValues, value); assert code >= 0 : code + ", " + value; } codeValueSet.add(code); } Object codes = representation.freeze(codeValueSet, null); return Pair.of(codes, codeValues); }
public Object[] current() { Object[] objects = new Object[columnCount]; for (int j = 0; j < objects.length; j++) { final Column pair = columns.get(j); objects[j] = pair.representation.getObject(pair.dataSet, i); } return objects; }
public Object freeze(ColumnLoader.ValueSet valueSet, int[] sources) { final int n = valueSet.map.keySet().size(); int extra = valueSet.containsNull ? 1 : 0; Comparable[] codeValues = valueSet.map.keySet().toArray(new Comparable[n + extra]); Arrays.sort(codeValues, 0, n); ColumnLoader.ValueSet codeValueSet = new ColumnLoader.ValueSet(int.class); final List<Comparable> list = permuteList(valueSet.values, sources); for (Comparable value : list) { int code; if (value == null) { code = n; } else { code = Arrays.binarySearch(codeValues, value); assert code >= 0 : code + ", " + value; } codeValueSet.add(code); } Object codes = representation.freeze(codeValueSet, null); return Pair.of(codes, codeValues); }
public Object get(int index) { return representation.getObject(dataSet, index); }
/** Returns a list view onto a data set. */ public static List asList(final Representation representation, final Object dataSet) { // Cache size. It might be expensive to compute. final int size = representation.size(dataSet); return new AbstractList() { public Object get(int index) { return representation.getObject(dataSet, index); } public int size() { return size; } }; } }
/** Freezes the contents of this value set into a column, optionally * re-ordering if {@code sources} is specified. */ ArrayTable.Column freeze(int ordinal, int[] sources) { ArrayTable.Representation representation = chooseRep(ordinal); final int cardinality = map.size() + (containsNull ? 1 : 0); final Object data = representation.freeze(this, sources); return new ArrayTable.Column(representation, data, cardinality); }
/** Freezes the contents of this value set into a column, optionally * re-ordering if {@code sources} is specified. */ ArrayTable.Column freeze(int ordinal, int[] sources) { ArrayTable.Representation representation = chooseRep(ordinal); final int cardinality = map.size() + (containsNull ? 1 : 0); final Object data = representation.freeze(this, sources); return new ArrayTable.Column(representation, data, cardinality); }
public Object permute(Object dataSet, int[] sources) { final Pair<Object, Comparable[]> pair = (Pair<Object, Comparable[]>) dataSet; Object codes = pair.left; Comparable[] codeValues = pair.right; return Pair.of(representation.permute(codes, sources), codeValues); }
public Column permute(int[] sources) { return new Column( representation, representation.permute(dataSet, sources), cardinality); }
private void checkColumn(ArrayTable.Column x, ArrayTable.RepresentationType expectedRepresentationType, String expectedString) { assertEquals( expectedRepresentationType, x.representation.getType()); assertEquals(expectedString, x.toString()); } }
public int size(Object dataSet) { final Pair<Object, Comparable[]> pair = (Pair<Object, Comparable[]>) dataSet; return representation.size(pair.left); }
public Object getObject(Object dataSet, int ordinal) { final Pair<Object, Comparable[]> pair = (Pair<Object, Comparable[]>) dataSet; int code = representation.getInt(pair.left, ordinal); return pair.right[code]; }
@Override public String toString() { return "Column(representation=" + representation + ", value=" + representation.toString(dataSet) + ")"; }
/** Returns a list view onto a data set. */ public static List asList(final Representation representation, final Object dataSet) { // Cache size. It might be expensive to compute. final int size = representation.size(dataSet); return new AbstractList() { public Object get(int index) { return representation.getObject(dataSet, index); } public int size() { return size; } }; } }
public Object get(int index) { return representation.getObject(dataSet, index); }
private void checkColumn(ArrayTable.Column x, ArrayTable.RepresentationType expectedRepresentationType, String expectedString) { assertEquals( expectedRepresentationType, x.representation.getType()); assertEquals(expectedString, x.toString()); } }
public Object permute(Object dataSet, int[] sources) { final Pair<Object, Comparable[]> pair = (Pair<Object, Comparable[]>) dataSet; Object codes = pair.left; Comparable[] codeValues = pair.right; return Pair.of(representation.permute(codes, sources), codeValues); }
public int size(Object dataSet) { final Pair<Object, Comparable[]> pair = (Pair<Object, Comparable[]>) dataSet; return representation.size(pair.left); }
public Object getObject(Object dataSet, int ordinal) { final Pair<Object, Comparable[]> pair = (Pair<Object, Comparable[]>) dataSet; int code = representation.getInt(pair.left, ordinal); return pair.right[code]; }
public Column permute(int[] sources) { return new Column( representation, representation.permute(dataSet, sources), cardinality); }