@Override public BolBuffer toRawEntry(byte[] key, long timestamp, boolean tombstoned, long version, byte[] payload, BolBuffer rawEntryBuffer) throws Exception { rawEntryBuffer.allocate(keyLength + payloadLength); System.arraycopy(key, 0, rawEntryBuffer.bytes, 0, keyLength); if (payloadLength > 0) { System.arraycopy(payload, 0, rawEntryBuffer.bytes, keyLength, payloadLength); } return rawEntryBuffer; }
public static String toString(BolBuffer bb) { byte[] copy = bb == null ? null : bb.copy(); return copy == null ? "NULL" : Arrays.toString(copy); }
@Override public boolean streamRawEntry(int index, BolBuffer rawEntry, BolBuffer keyBuffer, BolBuffer valueBuffer, ValueStream stream) throws Exception { if (rawEntry == null) { return stream.stream(index, null, -1, false, -1, null); } int keyLength = rawEntry.getInt(0); BolBuffer key = rawEntry.sliceInto(4, keyLength, keyBuffer); long timestamp = rawEntry.getLong(4 + keyLength); boolean tombstone = rawEntry.get(4 + keyLength + 8) != 0; long version = rawEntry.getLong(4 + keyLength + 8 + 1); BolBuffer payload = null; if (valueBuffer != null) { int payloadLength = rawEntry.getInt(4 + keyLength + 8 + 1 + 8); if (payloadLength >= 0) { payload = rawEntry.sliceInto(4 + keyLength + 8 + 1 + 8 + 4, payloadLength, valueBuffer); } } return stream.stream(index, key, timestamp, tombstone, version, payload); }
public long longMurmurHashCode() { return longMurmurHashCode(length); }
@Override public boolean tombstone( BolBuffer rawEntrys) { return rawEntrys.get(keyLength + 8) != 0; }
public static int compare(BolBuffer left, BolBuffer right) { int leftLength = left.length; int rightLength = right.length; int minLength = Math.min(leftLength, rightLength); int minWords = minLength / 8; int i; for (i = 0; i < minWords * 8; i += 8) { long result = left.getLong(i); long rw = right.getLong(i); if (result != rw) { return UnsignedLongs.compare(result, rw); } } for (i = minWords * 8; i < minLength; ++i) { int var11 = UnsignedBytes.compare(left.get(i), right.get(i)); if (var11 != 0) { return var11; } } return leftLength - rightLength; }
@Override public long readLong() throws IOException { long l = buf.getLong(offset); offset += 8; return l; }
start = time; BolBuffer key = new BolBuffer(); BolBuffer entryBuffer = new BolBuffer(); long hashCode = k.longMurmurHashCode(); long hashIndex = fibonacciIndexForHash(hashCode, twoPower);
int keyLength = readable.readInt(offset); offset += 4; keys[i] = readable.sliceIntoBuffer(offset, keyLength, new BolBuffer()); offset += keyLength; int startOfEntryNumBytes = startOfEntryLength * 8; StartOfEntry startOfEntry = (readable1) -> { BolBuffer sliceIntoBuffer = readable1.sliceIntoBuffer(startOfEntryOffset, startOfEntryNumBytes, new BolBuffer()); return sliceIntoBuffer.asLongBuffer(); }; throw new RuntimeException("Encountered length corruption. "); return new Leaps(index, new BolBuffer(lastKey), fpIndex,keys, startOfEntry);
public BolBuffer sliceIntoBuffer(long offset, int length, BolBuffer entryBuffer) throws IOException { int bbIndex = (int) (offset >> fShift); if (bbIndex == (int) (offset + length >> fShift)) { int filerSeek = (int) (offset & fseekMask); entryBuffer.force(bbs[bbIndex], filerSeek, length); } else { byte[] rawEntry = new byte[length]; // very rare only on bb boundaries read(offset, rawEntry, 0, length); entryBuffer.force(rawEntry, 0, length); } return entryBuffer; }
@Override public char readChar() throws IOException { char c = buf.getChar(offset); offset += 2; return c; }
public LongBuffer asLongBuffer() { return asByteBuffer().asLongBuffer(); }
public Object lock(BolBuffer buffer, int seed) { return locks[Math.abs((int)buffer.longMurmurHashCode(seed) % locks.length)]; }
@Override public boolean readBoolean() throws IOException { int ch = buf.get(offset) & 0xFF; offset++; return (ch != 0); }