public static String toString(BolBuffer bb) { byte[] copy = bb == null ? null : bb.copy(); return copy == null ? "NULL" : Arrays.toString(copy); }
public ByteBuffer asByteBuffer() { if (length == -1) { return null; } if (bb != null) { ByteBuffer duplicate = bb.duplicate(); duplicate.position(offset); duplicate.limit(offset + length); return duplicate.slice(); } return ByteBuffer.wrap(copy()); }
@Override public void append(BolBuffer bolBuffer) throws IOException { byte[] copy = bolBuffer.copy(); append(copy, 0, copy.length); }
public String toString(PointerReadableByteBufferFile pointerReadable) throws IOException { StringBuilder startOfEntryString = new StringBuilder(); LongBuffer longBuffer = startOfEntry.get(pointerReadable); for (int i = 0; i < fps.length; i++) { if (i > 0) { startOfEntryString.append(", "); } startOfEntryString.append(longBuffer.get(i)); } StringBuilder keyString = new StringBuilder(); for (int i = 0; i < keys.length; i++) { if (i > 0) { keyString.append(", "); } byte[] copy = keys[i].copy(); keyString.append(Arrays.toString(copy)); } return "Leaps{" + "index=" + index + ", lastKey=" + Arrays.toString(lastKey.copy()) + ", fps=" + Arrays.toString(fps) + ", keys=" + keyString.toString() + ", startOfEntry=" + startOfEntryString.toString() + '}'; }
ValueIndexConfig valueIndexConfig(byte[] valueIndexId) throws Exception { if (meta == null) { throw new IllegalStateException("This environment doesn't support journaled appends"); } ValueIndexConfig config = meta.get(valueIndexId, (metaValue) -> { if (metaValue != null) { return MAPPER.readValue(metaValue.copy(), ValueIndexConfig.class); } else { return null; } }); if (config == null) { // Fallback to the old way :( String primaryName = new String(valueIndexId, StandardCharsets.UTF_8); File configFile = new File(labRoot, primaryName + ".json"); if (configFile.exists()) { config = MAPPER.readValue(configFile, ValueIndexConfig.class); meta.append(valueIndexId, MAPPER.writeValueAsBytes(config), true); FileUtils.deleteQuietly(configFile); } else { throw new IllegalStateException("There is no config for lab value index:" + new String(valueIndexId, StandardCharsets.UTF_8)); } } return config; }
return new Leaps(index, new BolBuffer(lastKey.copy()), fpIndex, keys, readable1 -> LongBuffer.wrap(startOfEntryIndex));