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 long bytesLong(byte[] _bytes) { return bytesLong(_bytes, 0); }
public long getLong(int offset) { try { if (bb != null) { return bb.getLong(this.offset + offset); } return UIO.bytesLong(bytes, this.offset + offset); } catch (Exception x) { LOG.error("getLong({}) failed against{} ", offset, this); throw x; } }
public double getDouble(int offset) { try { if (bb != null) { return bb.getDouble(this.offset + offset); } return Double.longBitsToDouble(UIO.bytesLong(bytes, this.offset + offset)); } catch (Exception x) { LOG.error("getLong({}) failed against{} ", offset, this); throw x; } }
long word = UIO.bytesLong(bytes, i8);
public void metaKeys(MetaKeys keys) throws Exception { PointerReadableByteBufferFile pointerReadable = readOnlyFile.pointerReadable(-1); offsetKeyOffsetValueCache.stream((key, valueOffset) -> { long offset = UIO.bytesLong(valueOffset); int length = pointerReadable.readInt(offset); return length <= 0 || keys.metaKey(key); }); }
public BolBuffer get(byte[] key, BolBuffer valueBolBuffer) throws Exception { byte[] offsetBytes = offsetKeyOffsetValueCache.get(key, 0, key.length); if (offsetBytes == null) { return null; } long offset = -1; int length = -1; try { offset = UIO.bytesLong(offsetBytes); PointerReadableByteBufferFile pointerReadable = readOnlyFile.pointerReadable(-1); length = pointerReadable.readInt(offset); pointerReadable.sliceIntoBuffer(offset + 4, length, valueBolBuffer); return valueBolBuffer; } catch (Exception x) { LOG.error("Failed to get({}) offset:{} length:{}", Arrays.toString(key), offset, length); throw x; } }
public void copyTo(Meta to) throws Exception { PointerReadableByteBufferFile pointerReadable = readOnlyFile.pointerReadable(-1); offsetKeyOffsetValueCache.stream((key, valueOffset) -> { long offset = UIO.bytesLong(valueOffset); int length = pointerReadable.readInt(offset); if (length > 0) { byte[] value = new byte[length]; pointerReadable.read(offset + 4, value, 0, length); to.append(key, value, false); } return true; }); to.flush(); }