@Test public void malformedStalePrev() throws Exception { DocumentNodeStore ns = getDocumentMK().getNodeStore(); DocumentStore ds = ns.getDocumentStore(); for (int i = 0; i < 5; i++) { NodeBuilder nb = ns.getRoot().builder(); nb.setProperty("p", "v" + i); ns.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY); } UpdateOp op = new UpdateOp(ROOT_ID, false); NodeDocument.setStalePrevious(op, ns.newRevision(), 0); assertNotNull(ds.findAndUpdate(NODES, op)); NodeDocument doc = ds.find(NODES, ROOT_ID); assertNotNull(doc); for (UpdateOp updateOp : SplitOperations.forDocument( doc, ns, ns.getHeadRevision(), NO_BINARY, 3)) { ds.createOrUpdate(NODES, updateOp); } doc = ds.find(NODES, ROOT_ID); assertNotNull(doc); assertEquals(0, doc.getStalePrev().size()); }
@NotNull static List<UpdateOp> forDocument(@NotNull NodeDocument doc, @NotNull RevisionContext context, @NotNull RevisionVector headRevision, @NotNull Function<String, Long> binarySize, int numRevsThreshold) { if (doc.isSplitDocument()) { throw new IllegalArgumentException( "Not a main document: " + doc.getId()); } return new SplitOperations(doc, context, headRevision, binarySize, numRevsThreshold).create(); }
SplitOperations { @NotNull static List<UpdateOp> forDocument(@NotNull NodeDocument doc, @NotNull RevisionContext context, @NotNull RevisionVector headRevision, @NotNull Function<String, Long> binarySize, int numRevsThreshold) { if (doc.isSplitDocument()) { throw new IllegalArgumentException( "Not a main document: " + doc.getId()); } return new SplitOperations(doc, context, headRevision, binarySize, numRevsThreshold).create(); } }
SplitOperations { @NotNull static List<UpdateOp> forDocument(@NotNull NodeDocument doc, @NotNull RevisionContext context, @NotNull RevisionVector headRevision, @NotNull Function<String, Long> binarySize, int numRevsThreshold) { if (doc.isSplitDocument()) { throw new IllegalArgumentException( "Not a main document: " + doc.getId()); } return new SplitOperations(doc, context, headRevision, binarySize, numRevsThreshold).create(); } private  SplitOperations(@NotNull final NodeDocument doc,
                            @NotNull final RevisionContext context,
                            @NotNull final RevisionVector headRev,
                            @NotNull final Function<String, Long> binarySize,
                            int numRevsThreshold); }
SplitOperations { @NotNull static List<UpdateOp> forDocument(@NotNull NodeDocument doc, @NotNull RevisionContext context, @NotNull RevisionVector headRevision, @NotNull Function<String, Long> binarySize, int numRevsThreshold) { if (doc.isSplitDocument()) { throw new IllegalArgumentException( "Not a main document: " + doc.getId()); } return new SplitOperations(doc, context, headRevision, binarySize, numRevsThreshold).create(); } private  SplitOperations(@NotNull final NodeDocument doc,
                            @NotNull final RevisionContext context,
                            @NotNull final RevisionVector headRev,
                            @NotNull final Function<String, Long> binarySize,
                            int numRevsThreshold);  }
SplitOperations { @NotNull static List<UpdateOp> forDocument(@NotNull NodeDocument doc, @NotNull RevisionContext context, @NotNull RevisionVector headRevision, @NotNull Function<String, Long> binarySize, int numRevsThreshold) { if (doc.isSplitDocument()) { throw new IllegalArgumentException( "Not a main document: " + doc.getId()); } return new SplitOperations(doc, context, headRevision, binarySize, numRevsThreshold).create(); } private  SplitOperations(@NotNull final NodeDocument doc,
                            @NotNull final RevisionContext context,
                            @NotNull final RevisionVector headRev,
                            @NotNull final Function<String, Long> binarySize,
                            int numRevsThreshold);   }