public static int bytesInt(byte[] _bytes) { return bytesInt(_bytes, 0); }
public static long[] bytesLongs(byte[] _bytes) { if (_bytes == null || _bytes.length == 0) { return null; } int longsCount = _bytes.length / 8; long[] longs = new long[longsCount]; for (int i = 0; i < longsCount; i++) { longs[i] = bytesLong(_bytes, i * 8); } return longs; }
public static byte[] intBytes(int v) { return intBytes(v, new byte[4],0); }
public static int writeByteArray(byte[] bytes, byte[] destination, int offset) { int o = offset; if (bytes != null) { UIO.intBytes(bytes.length, destination, o); o += 4; UIO.writeBytes(bytes, destination, o); o += bytes.length; } else { UIO.intBytes(-1, destination, o); o += 4; } return o; }
public static void writeByteArray(IAppendOnly _filer, byte[] array, int _start, int _len, String fieldName) throws IOException { int len; if (array == null) { len = -1; } else { len = _len; } writeLength(_filer, len); if (len < 0) { return; } _filer.append(array, _start, len); }
public static byte[] longsBytes(long[] _longs) { int len = _longs.length; byte[] bytes = new byte[len * 8]; for (int i = 0; i < len; i++) { longBytes(_longs[i], bytes, i * 8); } return bytes; }
byte[] bPadded; if (a.length < b.length) { aPadded = padTail(a, b.length - a.length); bPadded = b; } else if (b.length < a.length) { aPadded = a; bPadded = padTail(b, a.length - b.length); } else { aPadded = a; BigInteger startBI = new BigInteger(add(prependHeader, aPadded)); BigInteger stopBI = new BigInteger(add(prependHeader, bPadded)); BigInteger diffBI = stopBI.subtract(startBI); if (inclusive) { aPaddedAdditional[aPadded.length] = 0; bPaddedAdditional[bPadded.length] = 0; return iterateOnSplits(aPaddedAdditional, bPaddedAdditional, inclusive, num, lexicographicalComparator);
public void write(IAppendOnly writeable) throws IOException { int entryLength = 4 + 4 + 8 + 8 + 8 + 4 + (minKey == null ? 0 : minKey.length) + 4 + (maxKey == null ? 0 : maxKey.length) + 8 + 8 + 8 + 8 + 4; writeable.appendInt(entryLength); writeable.appendInt(leapCount); writeable.appendLong(count); writeable.appendLong(keysSizeInBytes); writeable.appendLong(valuesSizeInBytes); UIO.writeByteArray(writeable, minKey, "minKey"); UIO.writeByteArray(writeable, maxKey, "maxKey"); writeable.appendLong(maxTimestamp); writeable.appendLong(maxTimestampVersion); writeable.appendLong(keyFormat); writeable.appendLong(valueFormat); writeable.appendInt(entryLength); }
} else { BolBuffer entryKeyBuffer = new BolBuffer(); byte[] middle = Lists.newArrayList(UIO.iterateOnSplits(minKey, maxKey, true, 1, rawhide.getKeyComparator())).get(1); BolBuffer bbMiddle = new BolBuffer(middle); LABAppendableIndex leftAppendableIndex = null;
public static short bytesShort(byte[] _bytes) { return bytesShort(_bytes, 0); }
/** * @param a array * @param length new array size * @return Value in <code>a</code> plus <code>length</code> appended 0 bytes */ private static byte[] padTail(byte[] a, int length) { byte[] padding = new byte[length]; for (int i = 0; i < length; i++) { padding[i] = 0; } return add(a, padding); }
public int getUnsignedShort(int offset) { try { if (bb != null) { return bb.getShort(this.offset + offset) & 0xffff; } return UIO.bytesUnsignedShort(bytes, this.offset + offset); } catch (Exception x) { LOG.error("getInt({}) failed against{} ", offset, this); throw x; } }
public char getChar(int offset) { try { if (bb != null) { return bb.getChar(this.offset + offset); } return UIO.bytesChar(bytes, this.offset + offset); } catch (Exception x) { LOG.error("get({}) failed against{} ", offset, this); throw x; } }
public static byte[] longBytes(long _v) { return longBytes(_v, new byte[8], 0); }
public short getShort(int offset) { try { if (bb != null) { return bb.getShort(this.offset + offset); } return UIO.bytesShort(bytes, this.offset + offset); } catch (Exception x) { LOG.error("getInt({}) failed against{} ", offset, this); throw x; } }
public float getFloat(int offset) { try { if (bb != null) { return bb.getFloat(this.offset + offset); } return Float.intBitsToFloat(UIO.bytesInt(bytes, this.offset + offset)); } catch (Exception x) { LOG.error("getLong({}) failed against{} ", offset, this); throw x; } }
public static long bytesLong(byte[] _bytes) { return bytesLong(_bytes, 0); }
@Override public BolBuffer toRawEntry( byte[] key, long timestamp, boolean tombstoned, long version, byte[] value, BolBuffer rawEntryBuffer) throws IOException { rawEntryBuffer.allocate(keyLength + 8 + 1 + 8 + LABUtils.rawArrayLength(value)); int o = 0; o = LABUtils.writeFixedWidthByteArray(key, rawEntryBuffer.bytes, o); UIO.longBytes(timestamp, rawEntryBuffer.bytes, o); o += 8; rawEntryBuffer.bytes[o] = tombstoned ? (byte) 1 : (byte) 0; o++; UIO.longBytes(version, rawEntryBuffer.bytes, o); o += 8; LABUtils.writeByteArray(value, rawEntryBuffer.bytes, o); return rawEntryBuffer; }
private static void rangeScan(ValueIndex<byte[]> index, int from, int to, ValueStream valueStream) throws Exception { System.out.println("rangeScan for for from:" + from + " to:" + to); byte[] fromBytes = from == -1 ? null : UIO.intBytes(from); byte[] toBytes = to == -1 ? null : UIO.intBytes(to); index.rangeScan(fromBytes, toBytes, valueStream, true); }
public int getInt(int offset) { try { if (bb != null) { return bb.getInt(this.offset + offset); } return UIO.bytesInt(bytes, this.offset + offset); } catch (Exception x) { LOG.error("getInt({}) failed against{} ", offset, this); throw x; } }