/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; return Bytes.equals(this.getValue(), other.getValue()); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof NullComparator)) return false; return super.areSerializedFieldsEqual(other); } }
@Override public int compareTo(byte [] value) { return compareTo(value, 0, value.length); }
List<Cell> result = get(get, false); boolean valueIsNull = comparator.getValue() == null || comparator.getValue().length == 0; boolean matches = false; long cellTs = 0; Cell kv = result.get(0); cellTs = kv.getTimestamp(); int compareResult = comparator.compareTo(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()); switch (compareOp) {
/** * Convert a ByteArrayComparable to a protocol buffer Comparator * * @param comparator the ByteArrayComparable to convert * @return the converted protocol buffer Comparator */ public static ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator) { ComparatorProtos.Comparator.Builder builder = ComparatorProtos.Comparator.newBuilder(); builder.setName(comparator.getClass().getName()); builder.setSerializedComparator(ByteStringer.wrap(comparator.toByteArray())); return builder.build(); }
boolean valueIsNull = comparator.getValue() == null || comparator.getValue().length == 0; boolean matches = false; long cellTs = 0; Cell kv = result.get(0); cellTs = kv.getTimestamp(); int compareResult = comparator.compareTo(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()); switch (compareOp) {
/** * Convert a ByteArrayComparable to a protocol buffer Comparator * * @param comparator the ByteArrayComparable to convert * @return the converted protocol buffer Comparator */ public static ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator) { ComparatorProtos.Comparator.Builder builder = ComparatorProtos.Comparator.newBuilder(); builder.setName(comparator.getClass().getName()); builder.setSerializedComparator(UnsafeByteOperations.unsafeWrap(comparator.toByteArray())); return builder.build(); }
@Override public String toString() { return String.format("%s (%s, %s)", this.getClass().getSimpleName(), this.op.name(), Bytes.toStringBinary(this.comparator.getValue())); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ boolean areSerializedFieldsEqual(LongComparator other) { if (other == this) return true; return super.areSerializedFieldsEqual(other); } }
/** * Special compareTo method for subclasses, to avoid copying bytes unnecessarily. * @param value bytes to compare within a ByteBuffer * @param offset offset into value * @param length number of bytes to compare * @return a negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. */ public int compareTo(ByteBuffer value, int offset, int length) { // For BC, providing a default implementation here which is doing a bytes copy to a temp byte[] // and calling compareTo(byte[]). Make sure to override this method in subclasses to avoid // copying bytes unnecessarily. byte[] temp = new byte[length]; ByteBufferUtils.copyFromBufferToArray(temp, value, offset, 0, length); return compareTo(temp); } }
/** * Convert a ByteArrayComparable to a protocol buffer Comparator * * @param comparator the ByteArrayComparable to convert * @return the converted protocol buffer Comparator */ public static ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator) { ComparatorProtos.Comparator.Builder builder = ComparatorProtos.Comparator.newBuilder(); builder.setName(comparator.getClass().getName()); builder.setSerializedComparator(UnsafeByteOperations.unsafeWrap(comparator.toByteArray())); return builder.build(); }
public ByteArrayComparableModel( ByteArrayComparable comparator) { String typeName = comparator.getClass().getSimpleName(); ComparatorType type = ComparatorType.valueOf(typeName); this.type = typeName; switch (type) { case BinaryComparator: case BinaryPrefixComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); break; case BitComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); this.op = ((BitComparator)comparator).getOperator().toString(); break; case NullComparator: break; case RegexStringComparator: case SubstringComparator: this.value = Bytes.toString(comparator.getValue()); break; default: throw new RuntimeException("unhandled filter type: " + type); } }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof BinaryComparator)) return false; return super.areSerializedFieldsEqual(other); } }
/** * Compare cell's row against given comparator * @param cell * @param comparator * @return result comparing cell's row */ public static int compareRow(Cell cell, ByteArrayComparable comparator) { if (cell instanceof ByteBufferExtendedCell) { return comparator.compareTo(((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength()); } return comparator.compareTo(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); }
/** * Convert a ByteArrayComparable to a protocol buffer Comparator * * @param comparator the ByteArrayComparable to convert * @return the converted protocol buffer Comparator */ public static ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator) { ComparatorProtos.Comparator.Builder builder = ComparatorProtos.Comparator.newBuilder(); builder.setName(comparator.getClass().getName()); builder.setSerializedComparator(ByteStringer.wrap(comparator.toByteArray())); return builder.build(); }
@Override public String toString() { return String.format("%s (%s, %s, %s, %s)", getClass().getSimpleName(), Bytes.toStringBinary(this.family), Bytes.toStringBinary(this.qualifier), this.op.name(), Bytes.toStringBinary(this.comparator.getValue())); }
/** * @param other the other comparator * @return true if and only if the fields of the comparator that are serialized are equal to the * corresponding fields in other. Used for testing. */ boolean areSerializedFieldsEqual(BigDecimalComparator other) { if (other == this) { return true; } return super.areSerializedFieldsEqual(other); } }
/** * Compare cell's value against given comparator * @param cell * @param comparator * @return result comparing cell's value */ public static int compareValue(Cell cell, ByteArrayComparable comparator) { if (cell instanceof ByteBufferExtendedCell) { return comparator.compareTo(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength()); } return comparator.compareTo(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); }
/** * Convert a ByteArrayComparable to a protocol buffer Comparator * * @param comparator the ByteArrayComparable to convert * @return the converted protocol buffer Comparator */ public static ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator) { ComparatorProtos.Comparator.Builder builder = ComparatorProtos.Comparator.newBuilder(); builder.setName(comparator.getClass().getName()); builder.setSerializedComparator(UnsafeByteOperations.unsafeWrap(comparator.toByteArray())); return builder.build(); }
@Override public String toString() { return String.format("%s (%s, %s, %s, %s)", this.getClass().getSimpleName(), Bytes.toStringBinary(this.columnFamily), Bytes.toStringBinary(this.columnQualifier), this.op.name(), Bytes.toStringBinary(this.comparator.getValue())); }