/** Create a record, allocating space for the key and value (if any) */ public Record create() { return create(new byte[keyLength], (valueLength > 0) ? new byte[valueLength] : null); }
@Override public boolean equals(Object other) { if ( this == other ) return true ; if ( ! ( other instanceof Record ) ) return false ; Record r = (Record)other ; return compareByKeyValue(this, r) == 0 ; }
static void checkCompatible(Record record1, Record record2) { if ( ! compatible(record1, record2, true) ) throw new RecordException(format("Incompatible: %s, %s", record1, record2)) ; }
public int getRecordLength() { return recordFactory.recordLength() ; }
/** Is the key of record1 <= key of record2 */ public static boolean keyLE(Record record1, Record record2) { int x = compareByKey(record1, record2) ; return x <= 0 ; }
public Record(byte[] key, byte[] value) { this.key = key ; this.value = value ; if ( SystemIndex.Checking ) { if ( value != null && value.length == 0 ) throw new RecordException("Zero length value") ; } }
public Record _get(int idx) { return factory.buildFrom(bb, idx) ; }
private static Record record(int i) { byte b[] = new byte[]{ (byte)((i>>8)&0xFF), (byte)(i&0xFF)} ; Record r = factory.create(b) ; return r ; }
/** Is (key, value) of record1 equal to (key,value) of record2 */ public static boolean equals(Record record1, Record record2) { int x = compareByKeyValue(record1, record2) ; return x == 0 ; }
static void checkKeyCompatible(Record record1, Record record2) { if ( ! compatible(record1, record2, false) ) throw new RecordException(format("Incompatible: %s, %s", record1, record2)) ; }
/** Is the key of record1 > key of record2 */ public static boolean keyGT(Record record1, Record record2) { int x = compareByKey(record1, record2) ; return x > 0 ; }
/** Is the key of record1 != key of record2 */ public static boolean keyNE(Record record1, Record record2) { int x = compareByKey(record1, record2) ; return x != 0 ; }
/** Is the key of record1 == key of record2 */ public static boolean keyEQ(Record record1, Record record2) { int x = compareByKey(record1, record2) ; return x == 0 ; }
/** Is the key of record1 < key of record2 */ public static boolean keyLT(Record record1, Record record2) { int x = compareByKey(record1, record2) ; return x < 0 ; }
/** Is the key of record1 >= key of record2 */ public static boolean keyGE(Record record1, Record record2) { int x = compareByKey(record1, record2) ; return x >= 0 ; }