public TupleProjector(KeyValueSchema schema, Expression[] expressions) { this.schema = schema; this.expressions = expressions; this.valueSet = ValueBitSet.newInstance(schema); }
public KeyValueSchema getSchema() { if (this.schema == null) { this.schema = buildSchema(columns); this.bitSet = ValueBitSet.newInstance(schema); } return schema; }
public ClientAggregators(List<SingleAggregateFunction> functions, int minNullableIndex) { super(functions.toArray(new SingleAggregateFunction[functions.size()]), getAggregators(functions), minNullableIndex); this.tempValueSet = ValueBitSet.newInstance(schema); }
throws SQLException { return new ResultIterator() { private final ValueBitSet destBitSet = ValueBitSet.newInstance(joinedSchema); private final ValueBitSet lhsBitSet = ValueBitSet.newInstance(lhsSchema); private final ValueBitSet rhsBitSet = (joinType == JoinType.Semi || joinType == JoinType.Anti) ? ValueBitSet.EMPTY_VALUE_BITSET : ValueBitSet.newInstance(rhsSchema); private final ResultIterator iter = delegate.iterator(scanGrouper, scan); private ResultIterator rhsIter = null;
public Aggregators(SingleAggregateFunction[] functions, Aggregator[] aggregators, int minNullableIndex) { this.functions = functions; this.aggregators = aggregators; this.estimatedByteSize = calculateSize(aggregators); this.schema = newValueSchema(aggregators, minNullableIndex); this.valueSet = ValueBitSet.newInstance(schema); }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); schema = new KeyValueSchema(); schema.readFields(input); bitSet = ValueBitSet.newInstance(schema); position = input.readInt(); displayName = input.readUTF(); }
public TupleProjector(Expression[] expressions) { this.expressions = expressions; KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(0); for (int i = 0; i < expressions.length; i++) { builder.addField(expressions[i]); } schema = builder.build(); valueSet = ValueBitSet.newInstance(schema); }
public TupleProjector(RowProjector rowProjector) { List<? extends ColumnProjector> columnProjectors = rowProjector.getColumnProjectors(); int count = columnProjectors.size(); KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(0); expressions = new Expression[count]; for (int i = 0; i < count; i++) { Expression expression = columnProjectors.get(i).getExpression(); builder.addField(expression); expressions[i] = expression; } schema = builder.build(); valueSet = ValueBitSet.newInstance(schema); }
public BasicJoinIterator(ResultIterator lhsIterator, ResultIterator rhsIterator) { this.lhsIterator = lhsIterator; this.rhsIterator = rhsIterator; this.initialized = false; this.lhsTuple = null; this.rhsTuple = null; this.lhsKey = new JoinKey(lhsKeyExpressions); this.rhsKey = new JoinKey(rhsKeyExpressions); this.nextLhsTuple = null; this.nextRhsTuple = null; this.nextLhsKey = new JoinKey(lhsKeyExpressions); this.nextRhsKey = new JoinKey(rhsKeyExpressions); this.destBitSet = ValueBitSet.newInstance(joinedSchema); this.lhsBitSet = ValueBitSet.newInstance(lhsSchema); this.rhsBitSet = ValueBitSet.newInstance(rhsSchema); lhsBitSet.clear(); int len = lhsBitSet.getEstimatedLength(); this.emptyProjectedValue = new byte[len]; lhsBitSet.toBytes(emptyProjectedValue, 0); this.queue = new MappedByteBufferTupleQueue(thresholdBytes); this.queueIterator = null; }
public TupleProjector(PTable projectedTable) throws SQLException { Preconditions.checkArgument(projectedTable.getType() == PTableType.PROJECTED); List<PColumn> columns = projectedTable.getColumns(); this.expressions = new Expression[columns.size() - projectedTable.getPKColumns().size()]; KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(0); int i = 0; for (PColumn column : columns) { if (!SchemaUtil.isPKColumn(column)) { builder.addField(column); expressions[i++] = ((ProjectedColumn) column).getSourceColumnRef().newColumnExpression(); } } schema = builder.build(); valueSet = ValueBitSet.newInstance(schema); }
ValueBitSet valueSet = ValueBitSet.newInstance(kvSchema); return kvSchema.toBytes(expressions.toArray(new Expression[0]), valueSet, ptr);
/** * * @param conn connection that was used for reading/generating value. * @param fullTableName fully qualified table name * @param values values of the columns * @param columns list of pair of column that includes column family as first part and column name as the second part. * Column family is optional and hence nullable. Columns in the list have to be in the same order as the order of occurence * of their values in the object array. * @return values encoded in a byte array * @throws SQLException * @see {@link #decodeValues(Connection, String, byte[], List)} */ public static byte[] encodeColumnValues(Connection conn, String fullTableName, Object[] values, List<Pair<String, String>> columns) throws SQLException { PTable table = getTable(conn, fullTableName); List<PColumn> pColumns = getColumns(table, columns); List<Expression> expressions = new ArrayList<Expression>(pColumns.size()); int i = 0; for (PColumn col : pColumns) { Object value = values[i]; // for purposes of encoding, sort order of the columns doesn't matter. Expression expr = LiteralExpression.newConstant(value, col.getDataType(), col.getMaxLength(), col.getScale()); expressions.add(expr); i++; } KeyValueSchema kvSchema = buildKeyValueSchema(pColumns); ImmutableBytesWritable ptr = new ImmutableBytesWritable(); ValueBitSet valueSet = ValueBitSet.newInstance(kvSchema); return kvSchema.toBytes(expressions.toArray(new Expression[0]), valueSet, ptr); }
KeyValueSchema kvSchema = buildKeyValueSchema(getPColumns(table, columns)); ImmutableBytesWritable ptr = new ImmutableBytesWritable(value); ValueBitSet valueSet = ValueBitSet.newInstance(kvSchema); valueSet.clear(); valueSet.or(ptr);
KeyValueSchema kvSchema = buildKeyValueSchema(getColumns(table, columns)); ImmutableBytesWritable ptr = new ImmutableBytesWritable(value); ValueBitSet valueSet = ValueBitSet.newInstance(kvSchema); valueSet.clear(); valueSet.or(ptr);
tempSrcBitSet[i] = ValueBitSet.newInstance(joinInfo.getSchemas()[i]); this.tempDestBitSet = ValueBitSet.newInstance(joinInfo.getJoinedSchema()); this.projector.setValueBitSet(tempDestBitSet);
@Test public void testMaxSetBit() { int nFields = 19; int nRepeating = 1; int nNotNull = 2; KeyValueSchema schema = generateSchema(nFields, nRepeating, nNotNull); ValueBitSet valueSet = ValueBitSet.newInstance(schema); setValueBitSet(schema, valueSet); int length = valueSet.getEstimatedLength(); byte[] buf = new byte[length]; valueSet.toBytes(buf, 0); ValueBitSet copyValueSet = ValueBitSet.newInstance(schema); copyValueSet.or(new ImmutableBytesWritable(buf)); assertTrue(copyValueSet.getMaxSetBit() >= valueSet.getMaxSetBit()); }
TupleUtil.getAggregateValue(result, ptr); KeyValueSchema schema = aggregators.getValueSchema(); ValueBitSet tempValueSet = ValueBitSet.newInstance(schema); tempValueSet.clear(); tempValueSet.or(ptr);
int nNotNull = 8; KeyValueSchema schema = generateSchema(nFields, nRepeating, nNotNull); ValueBitSet valueSet = ValueBitSet.newInstance(schema); nNotNull = 2; schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet); nNotNull = 2; schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet); nNotNull = 19; schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(0, valueSet.getEstimatedLength()); nNotNull = 0; schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet);
@Test public void testNullCount() { int nFields = 32; int nRepeating = 5; int nNotNull = 8; KeyValueSchema schema = generateSchema(nFields, nRepeating, nNotNull); ValueBitSet valueSet = ValueBitSet.newInstance(schema); setValueBitSet(schema, valueSet); // From beginning, not spanning longs assertEquals(5, valueSet.getNullCount(0, 10)); // From middle, not spanning longs assertEquals(5, valueSet.getNullCount(10, 10)); // From middle, spanning to middle of next long assertEquals(10, valueSet.getNullCount(64 - 5, 20)); // from end, not spanning longs assertEquals(5, valueSet.getNullCount(nFields*nRepeating-nNotNull-10, 10)); // from beginning, spanning long entirely into middle of next long assertEquals(64, valueSet.getNullCount(2, 128)); }
kvSchemaBitSet = ValueBitSet.newInstance(kvSchema);