@Nullable SegmentNodeState diff(@NotNull NodeState before, @NotNull NodeState after) throws IOException { boolean success = after.compareAgainstBaseState(before, this); if (exception != null) { throw new IOException(exception); } else if (success) { NodeState nodeState = builder.getNodeState(); checkState(modCount == 0 || !(nodeState instanceof SegmentNodeState)); RecordId nodeId = writer.writeNode(nodeState, getStableIdBytes(after)); reporter.reportNode(this::getPath); return new SegmentNodeState(reader, writer, blobStore, nodeId); } else { return null; } }
@Nullable SegmentNodeState diff(@NotNull NodeState before, @NotNull NodeState after) throws IOException { boolean success = after.compareAgainstBaseState(before, this); if (exception != null) { throw new IOException(exception); } else if (success) { NodeState nodeState = builder.getNodeState(); checkState(modCount == 0 || !(nodeState instanceof SegmentNodeState)); RecordId nodeId = writer.writeNode(nodeState, getStableIdBytes(after)); reporter.reportNode(this::getPath); return new SegmentNodeState(reader, writer, blobStore, nodeId); } else { return null; } }
@NotNull @Override public SegmentNodeState getNodeState() { try { NodeState state = super.getNodeState(); SegmentNodeState sState = new SegmentNodeState(reader, writer, blobStore, writer.writeNode(state), readStats); if (state != sState) { set(sState); if(!isChildBuilder()) { updateCount = 0; } } return sState; } catch (IOException e) { LOG.error("Error flushing changes", e); throw new IllegalStateException("Unexpected IOException", e); } }
private static String getSourcePathAnnotation(MemoryNodeBuilder builder) { PropertyState base = builder.getBaseState().getProperty(MoveDetector.SOURCE_PATH); PropertyState head = builder.getNodeState().getProperty(MoveDetector.SOURCE_PATH); if (Objects.equal(base, head)) { // Both null: no source path annotation // Both non null but equals: source path annotation is from a previous commit return null; } else { return head.getValue(Type.STRING); } }
private void updated() throws IOException { if (modCount % UPDATE_LIMIT == 0) { RecordId newBaseId = writer.writeNode(builder.getNodeState(), null); SegmentNodeState newBase = new SegmentNodeState(reader, writer, blobStore, newBaseId); builder = new MemoryNodeBuilder(newBase); } modCount++; }
private void updated() throws IOException { if (modCount % UPDATE_LIMIT == 0) { RecordId newBaseId = writer.writeNode(builder.getNodeState(), null); SegmentNodeState newBase = new SegmentNodeState(reader, writer, blobStore, newBaseId); builder = new MemoryNodeBuilder(newBase); } modCount++; }
@Nullable SegmentNodeState diff(@NotNull NodeState before, @NotNull NodeState after) throws IOException { boolean success = after.compareAgainstBaseState(before, new CancelableDiff(this, () -> canceller.check().isCancelled())); if (exception != null) { throw new IOException(exception); } else if (success) { NodeState nodeState = builder.getNodeState(); checkState(modCount == 0 || !(nodeState instanceof SegmentNodeState)); RecordId nodeId = writer.writeNode(nodeState, getStableIdBytes(after)); compactionMonitor.onNode(); return new SegmentNodeState(reader, writer, blobStore, nodeId); } else { return null; } }
private void updated() throws IOException { if (++modCount % UPDATE_LIMIT == 0) { RecordId newBaseId = writer.writeNode(builder.getNodeState(), null); SegmentNodeState newBase = new SegmentNodeState(reader, writer, blobStore, newBaseId); builder = new MemoryNodeBuilder(newBase); } }
private static String getSourcePathAnnotation(MemoryNodeBuilder builder) { PropertyState base = builder.getBaseState().getProperty(MoveDetector.SOURCE_PATH); PropertyState head = builder.getNodeState().getProperty(MoveDetector.SOURCE_PATH); if (Objects.equal(base, head)) { // Both null: no source path annotation // Both non null but equals: source path annotation is from a previous commit return null; } else { return head.getValue(Type.STRING); } }
@Test public void setTest() { Assume.assumeTrue(EMPTY_NODE.builder() instanceof MemoryNodeBuilder); MemoryNodeBuilder rootBuilder = (MemoryNodeBuilder) EMPTY_NODE.builder(); assertFalse(base.equals(rootBuilder.getNodeState())); rootBuilder.set(base); assertTrue(base.equals(rootBuilder.getNodeState())); MemoryNodeBuilder xBuilder = (MemoryNodeBuilder) rootBuilder.getChildNode("x"); NodeState yState = base.getChildNode("y"); assertFalse(yState.equals(xBuilder.getNodeState())); xBuilder.set(yState); assertTrue(yState.equals(xBuilder.getNodeState())); }
if (newParent.exists()) { annotateSourcePath(); NodeState nodeState = getNodeState(); newParent.setChildNode(newName, nodeState); remove();
if (newParent.exists()) { annotateSourcePath(); NodeState nodeState = getNodeState(); newParent.setChildNode(newName, nodeState); remove();