@Test public void prune() { final String docId = randomUUID().toString(); ObjectVersionGraph<String> versionGraph = graphForOptimization(); documentStore.append(docId, ImmutableList.copyOf(versionGraph.getVersionNodes()).reverse()); documentStore.publish(); assertThat(queryFactory.from(documentVersion).where(documentVersion.docId.eq(docId)).fetchCount()).isEqualTo(6); documentStore.prune(docId, graph -> versionNode -> versionNode.revision.equals(rev5) || versionNode.revision.equals(rev6)); assertThat(queryFactory.from(documentVersion).where(documentVersion.docId.eq(docId)).fetchCount()).isEqualTo(3); versionGraph = documentStore.getFullGraph(docId); VersionNode<PropertyPath, Object, String> versionNode = versionGraph.getVersionNode(rev3); assertThat(versionNode.getParentRevisions()).isEmpty(); assertThat(versionNode.getChangeset()).isEqualTo(mapOf("property1", "value1")); assertThat(versionNode.getProperties()).doesNotContainKey(parse("property2")); versionNode = versionGraph.getVersionNode(rev5); assertThat(versionNode.getParentRevisions()).isEqualTo(ImmutableSet.of(rev3)); assertThat(versionNode.getChangeset()).isEqualTo(mapOf("property2", "value2")); versionNode = versionGraph.getVersionNode(rev6); assertThat(versionNode.getParentRevisions()).isEqualTo(ImmutableSet.of(rev3)); assertThat(versionNode.getChangeset()).isEqualTo(mapOf( "property1", "value2", "property2", "value1")); }
public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); void append(Id docId, VersionNode<PropertyPath, Object, M> version); void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions); void append(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId); @Override DocumentUpdateBatch<Id, M, V> updateBatch(Collection<Id> ids); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); void append(Id docId, VersionNode<PropertyPath, Object, M> version); void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions); void append(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId); @Override DocumentUpdateBatch<Id, M, V> updateBatch(Collection<Id> ids);  }