@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((accessor == null) ? 0 : accessor.hashCode()); return result; }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); accessor = new RowKeyValueAccessor(); accessor.readFields(input); fromType = type; // fromType only needed on client side }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; RowKeyColumnExpression other = (RowKeyColumnExpression) obj; return accessor.equals(other.accessor); }
@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; }
@Override public String toString() { return name == null ? "PK[" + accessor.getIndex() + "]" : name; }
public int getPosition() { return accessor.getIndex(); }
@Override public void write(DataOutput output) throws IOException { super.write(output); accessor.write(output); }