@Test public void toStringEntries() throws IOException { RocksInodeStore store = new RocksInodeStore(mFolder.newFolder().getAbsolutePath()); assertEquals("", store.toStringEntries()); store.writeInode(MutableInodeDirectory.create(1, 0, "dir", CreateDirectoryContext.defaults())); assertEquals("dir", store.get(1).get().getName()); assertThat(store.toStringEntries(), containsString("name=dir")); }
public String toStringEntries() { StringBuilder sb = new StringBuilder(); try (RocksIterator inodeIter = db().newIterator(mInodesColumn.get(), new ReadOptions().setTotalOrderSeek(true))) { inodeIter.seekToFirst(); while (inodeIter.isValid()) { MutableInode<?> inode; try { inode = MutableInode.fromProto(InodeMeta.Inode.parseFrom(inodeIter.value())); } catch (Exception e) { throw new RuntimeException(e); } sb.append("Inode " + Longs.fromByteArray(inodeIter.key()) + ": " + inode + "\n"); inodeIter.next(); } } try (RocksIterator edgeIter = db().newIterator(mEdgesColumn.get())) { edgeIter.seekToFirst(); while (edgeIter.isValid()) { byte[] key = edgeIter.key(); byte[] id = new byte[Longs.BYTES]; byte[] name = new byte[key.length - Longs.BYTES]; System.arraycopy(key, 0, id, 0, Longs.BYTES); System.arraycopy(key, Longs.BYTES, name, 0, key.length - Longs.BYTES); sb.append(String.format("<%s,%s>->%s%n", Longs.fromByteArray(id), new String(name), Longs.fromByteArray(edgeIter.value()))); edgeIter.next(); } } return sb.toString(); }
RocksInodeStore implements InodeStore { public String toStringEntries() { StringBuilder sb = new StringBuilder(); try (RocksIterator inodeIter = db().newIterator(mInodesColumn.get(), new ReadOptions().setTotalOrderSeek(true))) { inodeIter.seekToFirst(); while (inodeIter.isValid()) { MutableInode<?> inode; try { inode = MutableInode.fromProto(InodeMeta.Inode.parseFrom(inodeIter.value())); } catch (Exception e) { throw new RuntimeException(e); } sb.append("Inode " + Longs.fromByteArray(inodeIter.key()) + ": " + inode + "\n"); inodeIter.next(); } } try (RocksIterator edgeIter = db().newIterator(mEdgesColumn.get())) { edgeIter.seekToFirst(); while (edgeIter.isValid()) { byte[] key = edgeIter.key(); byte[] id = new byte[Longs.BYTES]; byte[] name = new byte[key.length - Longs.BYTES]; System.arraycopy(key, 0, id, 0, Longs.BYTES); System.arraycopy(key, Longs.BYTES, name, 0, key.length - Longs.BYTES); sb.append(String.format("<%s,%s>->%s%n", Longs.fromByteArray(id), new String(name), Longs.fromByteArray(edgeIter.value()))); edgeIter.next(); } } return sb.toString(); } }
RocksInodeStore implements InodeStore { public String toStringEntries() { StringBuilder sb = new StringBuilder(); try (RocksIterator inodeIter = db().newIterator(mInodesColumn.get(), new ReadOptions().setTotalOrderSeek(true))) { inodeIter.seekToFirst(); while (inodeIter.isValid()) { MutableInode<?> inode; try { inode = MutableInode.fromProto(InodeMeta.Inode.parseFrom(inodeIter.value())); } catch (Exception e) { throw new RuntimeException(e); } sb.append("Inode " + Longs.fromByteArray(inodeIter.key()) + ": " + inode + "\n"); inodeIter.next(); } } try (RocksIterator edgeIter = db().newIterator(mEdgesColumn.get())) { edgeIter.seekToFirst(); while (edgeIter.isValid()) { byte[] key = edgeIter.key(); byte[] id = new byte[Longs.BYTES]; byte[] name = new byte[key.length - Longs.BYTES]; System.arraycopy(key, 0, id, 0, Longs.BYTES); System.arraycopy(key, Longs.BYTES, name, 0, key.length - Longs.BYTES); sb.append(String.format("<%s,%s>->%s%n", Longs.fromByteArray(id), new String(name), Longs.fromByteArray(edgeIter.value()))); edgeIter.next(); } } return sb.toString(); } RocksInodeStore(String baseDir); }
RocksInodeStore implements InodeStore { public String toStringEntries() { StringBuilder sb = new StringBuilder(); try (RocksIterator inodeIter = db().newIterator(mInodesColumn.get(), new ReadOptions().setTotalOrderSeek(true))) { inodeIter.seekToFirst(); while (inodeIter.isValid()) { MutableInode<?> inode; try { inode = MutableInode.fromProto(InodeMeta.Inode.parseFrom(inodeIter.value())); } catch (Exception e) { throw new RuntimeException(e); } sb.append("Inode " + Longs.fromByteArray(inodeIter.key()) + ": " + inode + "\n"); inodeIter.next(); } } try (RocksIterator edgeIter = db().newIterator(mEdgesColumn.get())) { edgeIter.seekToFirst(); while (edgeIter.isValid()) { byte[] key = edgeIter.key(); byte[] id = new byte[Longs.BYTES]; byte[] name = new byte[key.length - Longs.BYTES]; System.arraycopy(key, 0, id, 0, Longs.BYTES); System.arraycopy(key, Longs.BYTES, name, 0, key.length - Longs.BYTES); sb.append(String.format("<%s,%s>->%s%n", Longs.fromByteArray(id), new String(name), Longs.fromByteArray(edgeIter.value()))); edgeIter.next(); } } return sb.toString(); } RocksInodeStore(String baseDir); @Override void remove(Long inodeId); @Override void writeInode(MutableInode<?> inode); @Override WriteBatch createWriteBatch(); @Override void clear(); @Override void addChild(long parentId, String childName, Long childId); @Override void removeChild(long parentId, String name); @Override Optional<MutableInode<?>> getMutable(long id, ReadOption option); @Override Iterable<Long> getChildIds(Long inodeId, ReadOption option); @Override Optional<Long> getChildId(Long inodeId, String name, ReadOption option); @Override Optional<Inode> getChild(Long inodeId, String name, ReadOption option); @Override boolean hasChildren(InodeDirectoryView inode, ReadOption option); @Override Set<EdgeEntry> allEdges(); @Override Set<MutableInode<?>> allInodes(); Iterator<InodeView> iterator(); @Override boolean supportsBatchWrite(); @Override CheckpointName getCheckpointName(); @Override void writeToCheckpoint(OutputStream output); @Override void restoreFromCheckpoint(CheckpointInputStream input); @Override void close(); String toStringEntries(); }
RocksInodeStore implements InodeStore { public String toStringEntries() { StringBuilder sb = new StringBuilder(); try (RocksIterator inodeIter = db().newIterator(mInodesColumn.get(), new ReadOptions().setTotalOrderSeek(true))) { inodeIter.seekToFirst(); while (inodeIter.isValid()) { MutableInode<?> inode; try { inode = MutableInode.fromProto(InodeMeta.Inode.parseFrom(inodeIter.value())); } catch (Exception e) { throw new RuntimeException(e); } sb.append("Inode " + Longs.fromByteArray(inodeIter.key()) + ": " + inode + "\n"); inodeIter.next(); } } try (RocksIterator edgeIter = db().newIterator(mEdgesColumn.get())) { edgeIter.seekToFirst(); while (edgeIter.isValid()) { byte[] key = edgeIter.key(); byte[] id = new byte[Longs.BYTES]; byte[] name = new byte[key.length - Longs.BYTES]; System.arraycopy(key, 0, id, 0, Longs.BYTES); System.arraycopy(key, Longs.BYTES, name, 0, key.length - Longs.BYTES); sb.append(String.format("<%s,%s>->%s%n", Longs.fromByteArray(id), new String(name), Longs.fromByteArray(edgeIter.value()))); edgeIter.next(); } } return sb.toString(); } RocksInodeStore(String baseDir); @Override void remove(Long inodeId); @Override void writeInode(MutableInode<?> inode); @Override WriteBatch createWriteBatch(); @Override void clear(); @Override void addChild(long parentId, String childName, Long childId); @Override void removeChild(long parentId, String name); @Override Optional<MutableInode<?>> getMutable(long id, ReadOption option); @Override Iterable<Long> getChildIds(Long inodeId, ReadOption option); @Override Optional<Long> getChildId(Long inodeId, String name, ReadOption option); @Override Optional<Inode> getChild(Long inodeId, String name, ReadOption option); @Override boolean hasChildren(InodeDirectoryView inode, ReadOption option); @Override Set<EdgeEntry> allEdges(); @Override Set<MutableInode<?>> allInodes(); Iterator<InodeView> iterator(); @Override boolean supportsBatchWrite(); @Override CheckpointName getCheckpointName(); @Override void writeToCheckpoint(OutputStream output); @Override void restoreFromCheckpoint(CheckpointInputStream input); @Override void close(); String toStringEntries();  }