public static byte[] intBytes(int v) { return intBytes(v, new byte[4],0); }
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); }
private static void pointRangeScan(ValueIndex<byte[]> index, int from, int to, ValueStream valueStream) throws Exception { System.out.println("pointRangeScan for for from:" + from + " to:" + to); byte[] fromBytes = from == -1 ? null : UIO.intBytes(from); byte[] toBytes = to == -1 ? null : UIO.intBytes(to); index.pointRangeScan(fromBytes, toBytes, valueStream, true); }
private static void pointGet(ValueIndex<byte[]> index, int key, ValueStream valueStream) throws Exception { System.out.println("pointGet for key:" + key); byte[] keyBytes = UIO.intBytes(key); index.get( (keyStream) -> { keyStream.key(0, keyBytes, 0, keyBytes.length); return true; }, valueStream, true); }
private static void update(ValueIndex<byte[]> index, boolean delete, int count, int modulo, boolean fsync) throws Exception { BolBuffer rawEntryBuffer = new BolBuffer(); BolBuffer keyBuffer = new BolBuffer(); long timestamp = System.currentTimeMillis(); index.append((stream) -> { for (int i = 0; i < count; i++) { if (i % modulo == 0) { stream.stream(i, UIO.intBytes(i), timestamp, delete, version.incrementAndGet(), UIO.intBytes(i)); } } return true; }, fsync, rawEntryBuffer, keyBuffer); }
public long allocate(byte[] bytes, int offset, int length, LABCostChangeInBytes costInBytes) { if (bytes == null) { return -1; } synchronized (this) { long address = allocate(4 + length, costInBytes); LABMemorySlabs m = memory; byte[] slab = m.slab(address); int slabAddress = m.slabIndex(address); UIO.intBytes(length, slab, slabAddress); System.arraycopy(bytes, offset, slab, slabAddress + 4, length); return address; } }