TarFiles implements Closeable { public Map<String, Set<UUID>> getIndices() { Node head; lock.readLock().lock(); try { head = readers; } finally { lock.readLock().unlock(); } Map<String, Set<UUID>> index = new HashMap<>(); for (TarReader reader : iterable(head)) { index.put(reader.getFileName(), reader.getUUIDs()); } return index; } private  TarFiles(Builder builder); static Builder builder(); @Override void close(); @Override String toString(); long size(); int readerCount(); int segmentCount(); void flush(); boolean containsSegment(long msb, long lsb); Buffer readSegment(long msb, long lsb); void writeSegment(UUID id, byte[] buffer, int offset, int length, GCGeneration generation, Set<UUID> references, Set<String> binaryReferences); CleanupResult cleanup(CleanupContext context); void collectBlobReferences(Consumer<String> collector, Predicate<GCGeneration> reclaim); Iterable<UUID> getSegmentIds(); Map<UUID, Set<UUID>> getGraph(String fileName); Map<String, Set<UUID>> getIndices(); FileReaper createFileReaper();  }
@Test public void testGetIndices() throws Exception { UUID a = randomUUID(); UUID b = randomUUID(); UUID c = randomUUID(); UUID d = randomUUID(); writeSegment(a); writeSegment(b); tarFiles.newWriter(); writeSegment(c); writeSegment(d); tarFiles.newWriter(); Set<Set<UUID>> expected = new HashSet<>(); expected.add(new HashSet<>(asList(a, b))); expected.add(new HashSet<>(asList(c, d))); assertEquals(expected, new HashSet<>(tarFiles.getIndices().values())); }