@Override public void get(ByteBuffer key, ReaderResult result) throws IOException { StringBuilder sb = new StringBuilder(); sb.append("Original value: "); sb.append(BytesUtils.bytesToHexString(key)); sb.append(" Assigned to partition number: "); sb.append(partNum); byte[] bytes = sb.toString().getBytes(); result.requiresBufferSize(bytes.length); System.arraycopy(bytes, 0, result.getBuffer().array(), 0, bytes.length); result.found(); }
@Override public void get(ByteBuffer key, ReaderResult result) throws IOException { if (key.equals(ByteBuffer.wrap("nullKey".getBytes()))) { result.notFound(); } else { result.requiresBufferSize(returnValue.length); result.getBuffer().position(0).limit(returnValue.length); result.getBuffer().put(returnValue); result.getBuffer().flip(); result.found(); } }
@Override public void get(ByteBuffer key, ReaderResult result) throws IOException { byte[] v = map.get(key); if (v == null) { result.notFound(); } else { result.found(); result.requiresBufferSize(v.length); System.arraycopy(v, 0, result.getBuffer().array(), 0, v.length); result.getBuffer().limit(v.length); result.getBuffer().rewind(); } }
private boolean loadValueFromCache(ByteBuffer location, ReaderResult result) { ByteBuffer value = cache.get(location); if (value != null) { result.deepCopyIntoResultBuffer(value); result.found(); result.setL2CacheHit(true); return true; } else { return false; } }
result.found(); buffer.limit(bufferOffset + valueSize); buffer.position(bufferOffset);
private boolean loadValueFromCache(ByteBuffer keyHash, ReaderResult result) { ByteBuffer value; value = cache.get(keyHash); if (value != null) { // Compare against the not found marker (note that this is an address equality // and not an object equality on purpose) if (value != NOT_FOUND_MARKER) { // Load cached value into result result.deepCopyIntoResultBuffer(value); result.found(); } else { result.notFound(); } // Was found in cache result.setL1CacheHit(true); return true; } else { // Was not found in cache return false; } } }