List of usage examples for org.apache.hadoop.io WritableComparator readLong
public static long readLong(byte[] bytes, int start)
From source file:com.asakusafw.runtime.value.ByteArrayUtil.java
License:Apache License
static long readLong(byte[] bytes, int offset) { return WritableComparator.readLong(bytes, offset); }
From source file:com.ibm.bi.dml.runtime.matrix.data.MatrixIndexes.java
License:Open Source License
@Override public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) { //compare row long v1 = WritableComparator.readLong(b1, s1); long v2 = WritableComparator.readLong(b2, s2); if (v1 != v2) return v1 < v2 ? -1 : 1; //compare column (if needed) v1 = WritableComparator.readLong(b1, s1 + Long.SIZE / 8); v2 = WritableComparator.readLong(b2, s2 + Long.SIZE / 8); return (v1 < v2 ? -1 : (v1 == v2 ? 0 : 1)); }
From source file:com.netflix.aegisthus.io.writable.AegisthusKey.java
License:Apache License
/** * Zero copy readFields.//from w w w . j a va 2 s . c o m * Note: As defensive copying is not done, caller should not mutate b1 while using instance. * */ public void readFields(byte[] bytes, int start, int length) { int pos = start; // start at the input position int keyLength = WritableComparator.readInt(bytes, pos); pos += 4; // move forward by the int that held the key length this.key = ByteBuffer.wrap(bytes, pos, keyLength); pos += keyLength; // move forward by the key length if (bytes[pos] == 0) { pos += 1; // move forward by a boolean this.name = null; } else { pos += 1; // move forward by a boolean int nameLength = WritableComparator.readInt(bytes, pos); pos += 4; // move forward by an int that held the name length this.name = ByteBuffer.wrap(bytes, pos, nameLength); pos += nameLength; // move forward by the name length } if (bytes[pos] == 0) { // pos += 1; // move forward by a boolean this.timestamp = null; } else { pos += 1; // move forward by a boolean this.timestamp = WritableComparator.readLong(bytes, pos); // pos += 8; // move forward by a long } }