@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { try { KeyValueSchema schema = getSchema(); TupleProjector.decodeProjectedValue(tuple, ptr); bitSet.clear(); bitSet.or(ptr); int maxOffset = ptr.getOffset() + ptr.getLength() - bitSet.getEstimatedLength(); schema.iterator(ptr, position, bitSet); Boolean hasValue = schema.next(ptr, position, maxOffset, bitSet); if (hasValue == null || !hasValue.booleanValue()) { ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); return true; } } catch (IOException e) { return false; } return true; }
public ProjectedValueTuple projectResults(Tuple tuple) { byte[] bytesValue = schema.toBytes(tuple, getExpressions(), valueSet, ptr); Cell base = tuple.getValue(0); return new ProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), base.getTimestamp(), bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); }
public ProjectedValueTuple projectResults(Tuple tuple, boolean useNewValueQualifier) { long maxTS = tuple.getValue(0).getTimestamp(); int nCells = tuple.size(); for (int i = 1; i < nCells; i++) { long ts = tuple.getValue(i).getTimestamp(); if (ts > maxTS) { maxTS = ts; } } byte[] bytesValue = schema.toBytes(tuple, getExpressions(), valueSet, ptr); Cell base = tuple.getValue(0); if (useNewValueQualifier) { return new ProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), maxTS, bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); } else { return new OldProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), maxTS, bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); } }
valueSet.clear(); int minNullableIndex = getMinNullable(); byte[] b = new byte[getEstimatedValueLength() + valueSet.getEstimatedLength()]; List<Field> fields = getFields(); b = ensureSize(b, offset, offset + valueSet.getEstimatedLength()); offset = valueSet.toBytes(b, offset);
assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet); assertEquals(Bytes.SIZEOF_SHORT + Bytes.SIZEOF_LONG * 3, valueSet.getEstimatedLength()); schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet); assertEquals(Bytes.SIZEOF_SHORT + Bytes.SIZEOF_LONG, valueSet.getEstimatedLength()); schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(0, valueSet.getEstimatedLength()); schema = generateSchema(nFields, nRepeating, nNotNull); valueSet = ValueBitSet.newInstance(schema); assertEquals(Bytes.SIZEOF_SHORT, valueSet.getEstimatedLength()); setValueBitSet(schema, valueSet); assertEquals(Bytes.SIZEOF_SHORT + Bytes.SIZEOF_LONG * 2, valueSet.getEstimatedLength()); valueSet.set(128); assertEquals(Bytes.SIZEOF_SHORT + Bytes.SIZEOF_LONG * 3, valueSet.getEstimatedLength());
private ProjectedValueTuple convertLhs(Tuple lhs) throws IOException { ProjectedValueTuple t; if (lhs instanceof ProjectedValueTuple) { t = (ProjectedValueTuple) lhs; } else { ImmutableBytesWritable ptr = getContext().getTempPtr(); TupleProjector.decodeProjectedValue(lhs, ptr); lhsBitSet.clear(); lhsBitSet.or(ptr); int bitSetLen = lhsBitSet.getEstimatedLength(); t = new ProjectedValueTuple(lhs, lhs.getValue(0).getTimestamp(), ptr.get(), ptr.getOffset(), ptr.getLength(), bitSetLen); } return t; } };
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; }
private Tuple join(Tuple lhs, Tuple rhs) throws SQLException { try { ProjectedValueTuple t = null; if (lhs == null) { t = new ProjectedValueTuple(rhs, rhs.getValue(0).getTimestamp(), this.emptyProjectedValue, 0, this.emptyProjectedValue.length, this.emptyProjectedValue.length); } else if (lhs instanceof ProjectedValueTuple) { t = (ProjectedValueTuple) lhs; } else { ImmutableBytesWritable ptr = context.getTempPtr(); TupleProjector.decodeProjectedValue(lhs, ptr); lhsBitSet.clear(); lhsBitSet.or(ptr); int bitSetLen = lhsBitSet.getEstimatedLength(); t = new ProjectedValueTuple(lhs, lhs.getValue(0).getTimestamp(), ptr.get(), ptr.getOffset(), ptr.getLength(), bitSetLen); } return rhsBitSet == ValueBitSet.EMPTY_VALUE_BITSET ? t : TupleProjector.mergeProjectedValue( t, joinedSchema, destBitSet, rhs, rhsSchema, rhsBitSet, rhsFieldPosition, true); } catch (IOException e) { throw new SQLException(e); } } }
srcBitSet.clear(); srcBitSet.or(srcValue); int origSrcBitSetLen = srcBitSet.getEstimatedLength(); for (int i = 0; i <= srcBitSet.getMaxSetBit(); i++) { if (srcBitSet.get(i)) { int destBitSetLen = destBitSet.getEstimatedLength(); byte[] merged = new byte[destValue.getLength() - origDestBitSetLen + srcValueLen + destBitSetLen]; int o = Bytes.putBytes(merged, 0, destValue.get(), destValue.getOffset(), destValue.getLength() - origDestBitSetLen);
@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()); }
public ProjectedValueTuple projectResults(Tuple tuple) { byte[] bytesValue = schema.toBytes(tuple, getExpressions(), valueSet, ptr); Cell base = tuple.getValue(0); return new ProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), base.getTimestamp(), bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { try { KeyValueSchema schema = getSchema(); TupleProjector.decodeProjectedValue(tuple, ptr); bitSet.clear(); bitSet.or(ptr); int maxOffset = ptr.getOffset() + ptr.getLength() - bitSet.getEstimatedLength(); schema.iterator(ptr, position, bitSet); Boolean hasValue = schema.next(ptr, position, maxOffset, bitSet); if (hasValue == null || !hasValue.booleanValue()) { ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); return true; } } catch (IOException e) { return false; } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { try { KeyValueSchema schema = getSchema(); TupleProjector.decodeProjectedValue(tuple, ptr); bitSet.clear(); bitSet.or(ptr); int maxOffset = ptr.getOffset() + ptr.getLength() - bitSet.getEstimatedLength(); schema.iterator(ptr, position, bitSet); Boolean hasValue = schema.next(ptr, position, maxOffset, bitSet); if (hasValue == null || !hasValue.booleanValue()) { ptr.set(ByteUtil.EMPTY_BYTE_ARRAY); return true; } } catch (IOException e) { return false; } return true; }
public ProjectedValueTuple projectResults(Tuple tuple) { byte[] bytesValue = schema.toBytes(tuple, getExpressions(), valueSet, ptr); Cell base = tuple.getValue(0); return new ProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), base.getTimestamp(), bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); }
public ProjectedValueTuple projectResults(Tuple tuple, boolean useNewValueQualifier) { long maxTS = tuple.getValue(0).getTimestamp(); int nCells = tuple.size(); for (int i = 1; i < nCells; i++) { long ts = tuple.getValue(i).getTimestamp(); if (ts > maxTS) { maxTS = ts; } } byte[] bytesValue = schema.toBytes(tuple, getExpressions(), valueSet, ptr); Cell base = tuple.getValue(0); if (useNewValueQualifier) { return new ProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), maxTS, bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); } else { return new OldProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), maxTS, bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); } }
public ProjectedValueTuple projectResults(Tuple tuple, boolean useNewValueQualifier) { long maxTS = tuple.getValue(0).getTimestamp(); int nCells = tuple.size(); for (int i = 1; i < nCells; i++) { long ts = tuple.getValue(i).getTimestamp(); if (ts > maxTS) { maxTS = ts; } } byte[] bytesValue = schema.toBytes(tuple, getExpressions(), valueSet, ptr); Cell base = tuple.getValue(0); if (useNewValueQualifier) { return new ProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), maxTS, bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); } else { return new OldProjectedValueTuple(base.getRowArray(), base.getRowOffset(), base.getRowLength(), maxTS, bytesValue, 0, bytesValue.length, valueSet.getEstimatedLength()); } }
private ProjectedValueTuple convertLhs(Tuple lhs) throws IOException { ProjectedValueTuple t; if (lhs instanceof ProjectedValueTuple) { t = (ProjectedValueTuple) lhs; } else { ImmutableBytesWritable ptr = getContext().getTempPtr(); TupleProjector.decodeProjectedValue(lhs, ptr); lhsBitSet.clear(); lhsBitSet.or(ptr); int bitSetLen = lhsBitSet.getEstimatedLength(); t = new ProjectedValueTuple(lhs, lhs.getValue(0).getTimestamp(), ptr.get(), ptr.getOffset(), ptr.getLength(), bitSetLen); } return t; } };
private ProjectedValueTuple convertLhs(Tuple lhs) throws IOException { ProjectedValueTuple t; if (lhs instanceof ProjectedValueTuple) { t = (ProjectedValueTuple) lhs; } else { ImmutableBytesWritable ptr = getContext().getTempPtr(); TupleProjector.decodeProjectedValue(lhs, ptr); lhsBitSet.clear(); lhsBitSet.or(ptr); int bitSetLen = lhsBitSet.getEstimatedLength(); t = new ProjectedValueTuple(lhs, lhs.getValue(0).getTimestamp(), ptr.get(), ptr.getOffset(), ptr.getLength(), bitSetLen); } return t; } };
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 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; }