@SuppressWarnings("deprecation")
 @Override
 protected void writeToBuffer(MappedByteBuffer buffer, Tuple e) {
   KeyValue kv = KeyValueUtil.ensureKeyValue(e.getValue(0));
   buffer.putInt(kv.getLength() + Bytes.SIZEOF_INT);
   buffer.putInt(kv.getLength());
   buffer.put(kv.getBuffer(), kv.getOffset(), kv.getLength());
 }
示例#2
0
 public ProjectedValueTuple projectResults(Tuple tuple) {
   byte[] bytesValue = schema.toBytes(tuple, expressions, valueSet, ptr);
   Cell base = tuple.getValue(0);
   return new ProjectedValueTuple(
       base.getRowArray(),
       base.getRowOffset(),
       base.getRowLength(),
       base.getTimestamp(),
       bytesValue,
       valueSet.getEstimatedLength());
 }
 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);
   } catch (IOException e) {
     throw new SQLException(e);
   }
 }
 @Override
 public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
   tuple.getKey(ptr);
   int offset = accessor.getOffset(ptr.get(), ptr.getOffset());
   // Null is represented in the last expression of a multi-part key
   // by the bytes not being present.
   int maxOffset = ptr.getOffset() + ptr.getLength();
   if (offset < maxOffset) {
     byte[] buffer = ptr.get();
     int fixedByteSize = -1;
     // FIXME: fixedByteSize <= maxByteSize ? fixedByteSize : 0 required because HBase passes bogus
     // keys to filter to position scan (HBASE-6562)
     if (fromType.isFixedWidth()) {
       fixedByteSize = getByteSize();
       fixedByteSize = fixedByteSize <= maxOffset ? fixedByteSize : 0;
     }
     int length =
         fixedByteSize >= 0 ? fixedByteSize : accessor.getLength(buffer, offset, maxOffset);
     // In the middle of the key, an empty variable length byte array represents null
     if (length > 0) {
       /*
       if (type == fromType) {
           ptr.set(buffer,offset,length);
       } else {
           ptr.set(type.toBytes(type.toObject(buffer, offset, length, fromType)));
       }
       */
       ptr.set(buffer, offset, length);
       type.coerceBytes(ptr, fromType, getSortOrder(), getSortOrder());
     } else {
       ptr.set(ByteUtil.EMPTY_BYTE_ARRAY);
     }
     return true;
   }
   return false;
 }
示例#5
0
 public static void decodeProjectedValue(Tuple tuple, ImmutableBytesWritable ptr)
     throws IOException {
   boolean b = tuple.getValue(VALUE_COLUMN_FAMILY, VALUE_COLUMN_QUALIFIER, ptr);
   if (!b) throw new IOException("Trying to decode a non-projected value.");
 }
 @Override
 protected int sizeOf(Tuple e) {
   KeyValue kv = KeyValueUtil.ensureKeyValue(e.getValue(0));
   return Bytes.SIZEOF_INT * 2 + kv.getLength();
 }