VersionGCSupport { public Iterable<NodeDocument> getPossiblyDeletedDocs(final long fromModified, final long toModified) { return filter(getSelectedDocuments(store, NodeDocument.DELETED_ONCE, 1), new Predicate<NodeDocument>() { @Override public boolean apply(NodeDocument input) { return input.wasDeletedOnce() && modifiedGreaterThanEquals(input, fromModified) && modifiedLessThan(input, toModified); } private boolean modifiedGreaterThanEquals(NodeDocument doc, long time) { Long modified = doc.getModified(); return modified != null && modified.compareTo(getModifiedInSecs(time)) >= 0; } private boolean modifiedLessThan(NodeDocument doc, long time) { Long modified = doc.getModified(); return modified != null && modified.compareTo(getModifiedInSecs(time)) < 0; } }); } VersionGCSupport(DocumentStore store); Iterable<NodeDocument> getPossiblyDeletedDocs(final long fromModified,
                                                         final long toModified); @NotNull DocumentStore getDocumentStore(); long getOldestDeletedOnceTimestamp(Clock clock, long precisionMs); long getDeletedOnceCount();  }
@Test public void getPossiblyDeletedDocs() { long offset = SECONDS.toMillis(42); for (int i = 0; i < 5; i++) { Revision r = new Revision(offset + SECONDS.toMillis(i), 0, 1); String id = Utils.getIdFromPath("/doc-" + i); ids.add(id); UpdateOp op = new UpdateOp(id, true); NodeDocument.setModified(op, r); NodeDocument.setDeleted(op, r, true); store.create(Collection.NODES, Lists.newArrayList(op)); } assertPossiblyDeleted(0, 41, 0); assertPossiblyDeleted(0, 42, 0); assertPossiblyDeleted(0, 44, 0); assertPossiblyDeleted(0, 45, 3); assertPossiblyDeleted(0, 46, 3); assertPossiblyDeleted(0, 49, 3); assertPossiblyDeleted(0, 50, 5); assertPossiblyDeleted(0, 51, 5); assertPossiblyDeleted(39, 60, 5); assertPossiblyDeleted(40, 60, 5); assertPossiblyDeleted(41, 60, 5); assertPossiblyDeleted(42, 60, 5); assertPossiblyDeleted(44, 60, 5); assertPossiblyDeleted(45, 60, 2); assertPossiblyDeleted(47, 60, 2); assertPossiblyDeleted(48, 60, 2); assertPossiblyDeleted(49, 60, 2); assertPossiblyDeleted(50, 60, 0); assertPossiblyDeleted(51, 60, 0); }