-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Sai prefix #4655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
pranavshenoy
wants to merge
6
commits into
apache:trunk
Choose a base branch
from
pranavshenoy:sai-prefix
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Sai prefix #4655
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,8 +79,8 @@ | |
| * Since this was the root of the trie, the current page is padded and the remaining nodes 0, 5 are written. | ||
| */ | ||
| @NotThreadSafe | ||
| public class IncrementalTrieWriterPageAware<VALUE> | ||
| extends IncrementalTrieWriterBase<VALUE, DataOutputPlus, IncrementalTrieWriterPageAware.Node<VALUE>> | ||
| public class IncrementalTrieWriterPageAware<VALUE, DEST, NODE extends IncrementalTrieWriterPageAware.Node<VALUE, NODE>> | ||
| extends IncrementalTrieWriterBase<VALUE, DataOutputPlus, NODE> | ||
| implements IncrementalTrieWriter<VALUE> | ||
| { | ||
| final int maxBytesPerPage; | ||
|
|
@@ -103,22 +103,21 @@ public class IncrementalTrieWriterPageAware<VALUE> | |
| return c; | ||
| }; | ||
|
|
||
| IncrementalTrieWriterPageAware(TrieSerializer<VALUE, ? super DataOutputPlus> trieSerializer, DataOutputPlus dest) | ||
| IncrementalTrieWriterPageAware(TrieSerializer<VALUE, ? super DataOutputPlus> trieSerializer, DataOutputPlus dest, NODE root) | ||
| { | ||
| super(trieSerializer, dest, new Node<>((byte) 0)); | ||
| super(trieSerializer, dest, root); | ||
| this.maxBytesPerPage = dest.maxBytesInPage(); | ||
| } | ||
|
|
||
| @Override | ||
| public void reset() | ||
| { | ||
| reset(new Node<>((byte) 0)); | ||
| reset(new Node<VALUE, NODE>((byte) 0)); | ||
| } | ||
|
|
||
| @Override | ||
| Node<VALUE> performCompletion() throws IOException | ||
| NODE performCompletion() throws IOException | ||
| { | ||
| Node<VALUE> root = super.performCompletion(); | ||
| NODE root = super.performCompletion(); | ||
|
|
||
| int actualSize = recalcTotalSize(root, dest.position()); | ||
| int bytesLeft = dest.bytesLeftInPage(); | ||
|
|
@@ -153,12 +152,12 @@ Node<VALUE> performCompletion() throws IOException | |
| } | ||
|
|
||
| @Override | ||
| void complete(Node<VALUE> node) throws IOException | ||
| void complete(NODE node) throws IOException | ||
| { | ||
| assert node.filePos == -1; | ||
|
|
||
| int branchSize = 0; | ||
| for (Node<VALUE> child : node.children) | ||
| for (NODE child : node.children) | ||
| branchSize += child.branchSize + child.nodeSize; | ||
|
|
||
| node.branchSize = branchSize; | ||
|
|
@@ -171,7 +170,7 @@ void complete(Node<VALUE> node) throws IOException | |
| node.hasOutOfPageChildren = false; | ||
| node.hasOutOfPageInBranch = false; | ||
|
|
||
| for (Node<VALUE> child : node.children) | ||
| for (Node<VALUE, NODE> child : node.children) | ||
| if (child.filePos != -1) | ||
| node.hasOutOfPageChildren = true; | ||
| else if (child.hasOutOfPageChildren || child.hasOutOfPageInBranch) | ||
|
|
@@ -184,19 +183,19 @@ else if (child.hasOutOfPageChildren || child.hasOutOfPageInBranch) | |
| layoutChildren(node); | ||
| } | ||
|
|
||
| private void layoutChildren(Node<VALUE> node) throws IOException | ||
| private void layoutChildren(Node<VALUE, NODE> node) throws IOException | ||
| { | ||
| assert node.filePos == -1; | ||
|
|
||
| NavigableSet<Node<VALUE>> children = node.getChildrenWithUnsetPosition(); | ||
| NavigableSet<Node<VALUE, NODE>> children = node.getChildrenWithUnsetPosition(); | ||
|
|
||
| int bytesLeft = dest.bytesLeftInPage(); | ||
| Node<VALUE> cmp = new Node<>(256); // goes after all equal-sized unplaced nodes (whose transition character is 0-255) | ||
| Node<VALUE, NODE> cmp = new Node<VALUE, NODE>(256); // goes after all equal-sized unplaced nodes (whose transition character is 0-255) | ||
| cmp.nodeSize = 0; | ||
| while (!children.isEmpty()) | ||
| { | ||
| cmp.branchSize = bytesLeft; | ||
| Node<VALUE> child = children.headSet(cmp, true).pollLast(); // grab biggest that could fit | ||
| Node<VALUE, NODE> child = children.headSet(cmp, true).pollLast(); // grab biggest that could fit | ||
| if (child == null) | ||
| { | ||
| dest.padToPageBoundary(); | ||
|
|
@@ -245,12 +244,12 @@ private void layoutChildren(Node<VALUE> node) throws IOException | |
| } | ||
|
|
||
| @SuppressWarnings("DuplicatedCode") // intentionally duplicated in IncrementalDeepTrieWriterPageAware | ||
| protected int recalcTotalSize(Node<VALUE> node, long nodePosition) throws IOException | ||
| protected int recalcTotalSize(Node<VALUE, NODE> node, long nodePosition) throws IOException | ||
| { | ||
| if (node.hasOutOfPageInBranch) | ||
| { | ||
| int sz = 0; | ||
| for (Node<VALUE> child : node.children) | ||
| for (Node<VALUE, NODE> child : node.children) | ||
| sz += recalcTotalSize(child, nodePosition + sz); | ||
| node.branchSize = sz; | ||
| } | ||
|
|
@@ -264,10 +263,10 @@ protected int recalcTotalSize(Node<VALUE> node, long nodePosition) throws IOExce | |
| } | ||
|
|
||
| @SuppressWarnings("DuplicatedCode") // intentionally duplicated in IncrementalDeepTrieWriterPageAware | ||
| protected long write(Node<VALUE> node) throws IOException | ||
| protected long write(Node<VALUE, NODE> node) throws IOException | ||
| { | ||
| long nodePosition = dest.position(); | ||
| for (Node<VALUE> child : node.children) | ||
| for (Node<VALUE, NODE> child : node.children) | ||
| if (child.filePos == -1) | ||
| child.filePos = write(child); | ||
|
|
||
|
|
@@ -283,14 +282,14 @@ protected long write(Node<VALUE> node) throws IOException | |
| return nodePosition; | ||
| } | ||
|
|
||
| protected String dumpNode(Node<VALUE> node, long nodePosition) | ||
| protected String dumpNode(NODE node, long nodePosition) | ||
| { | ||
| StringBuilder res = new StringBuilder(String.format("At %,d(%x) type %s child count %s nodeSize %,d branchSize %,d %s%s%n", | ||
| nodePosition, nodePosition, | ||
| TrieNode.typeFor(node, nodePosition), node.childCount(), node.nodeSize, node.branchSize, | ||
| node.hasOutOfPageChildren ? "C" : "", | ||
| node.hasOutOfPageInBranch ? "B" : "")); | ||
| for (Node<VALUE> child : node.children) | ||
| for (NODE child : node.children) | ||
| res.append(String.format("Child %2x at %,d(%x) type %s child count %s size %s nodeSize %,d branchSize %,d %s%s%n", | ||
| child.transition & 0xFF, | ||
| child.filePos, | ||
|
|
@@ -327,12 +326,12 @@ public PartialTail makePartialRoot() throws IOException | |
| } | ||
|
|
||
| @SuppressWarnings("DuplicatedCode") // intentionally duplicated in IncrementalDeepTrieWriterPageAware | ||
| protected long writePartial(Node<VALUE> node, DataOutputPlus dest, long baseOffset) throws IOException | ||
| protected long writePartial(NODE node, DataOutputPlus dest, long baseOffset) throws IOException | ||
| { | ||
| long startPosition = dest.position() + baseOffset; | ||
|
|
||
| List<Node<VALUE>> childrenToClear = new ArrayList<>(); | ||
| for (Node<VALUE> child : node.children) | ||
| List<NODE> childrenToClear = new ArrayList<>(); | ||
| for (NODE child : node.children) | ||
| { | ||
| if (child.filePos == -1) | ||
| { | ||
|
|
@@ -360,12 +359,12 @@ protected long writePartial(Node<VALUE> node, DataOutputPlus dest, long baseOffs | |
| node.nodeSize = (int) (endPosition - nodePosition); | ||
| } | ||
|
|
||
| for (Node<VALUE> child : childrenToClear) | ||
| for (NODE child : childrenToClear) | ||
| child.filePos = -1; | ||
| return nodePosition; | ||
| } | ||
|
|
||
| static class Node<Value> extends IncrementalTrieWriterBase.BaseNode<Value, Node<Value>> | ||
| static class Node<Value, NODE extends Node<Value, NODE>> extends IncrementalTrieWriterBase.BaseNode<Value, NODE> | ||
| { | ||
| /** | ||
| * Currently calculated size of the branch below this node, not including the node itself. | ||
|
|
@@ -397,9 +396,9 @@ static class Node<Value> extends IncrementalTrieWriterBase.BaseNode<Value, Node< | |
| } | ||
|
|
||
| @Override | ||
| Node<Value> newNode(byte transition) | ||
| NODE newNode(byte transition) | ||
| { | ||
| return new Node<>(transition & 0xFF); | ||
| return new Node<Value, NODE>(transition & 0xFF); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type mismatch: cannot convert from IncrementalTrieWriterPageAware.Node<Value,NODE> to NODEJava(16777235) |
||
| } | ||
|
|
||
| public long serializedPositionDelta(int i, long nodePosition) | ||
|
|
@@ -427,7 +426,7 @@ public long maxPositionDelta(long nodePosition) | |
|
|
||
| long minPlaced = 0; | ||
| long minUnplaced = 1; | ||
| for (Node<Value> child : children) | ||
| for (NODE child : children) | ||
| { | ||
| if (child.filePos != -1) | ||
| minPlaced = Math.min(minPlaced, child.filePos - nodePosition); | ||
|
|
@@ -438,10 +437,10 @@ else if (minUnplaced > 0) // triggers once | |
| return Math.min(minPlaced, minUnplaced); | ||
| } | ||
|
|
||
| NavigableSet<Node<Value>> getChildrenWithUnsetPosition() | ||
| NavigableSet<Node<Value, NODE>> getChildrenWithUnsetPosition() | ||
| { | ||
| NavigableSet<Node<Value>> result = new TreeSet<>(BRANCH_SIZE_COMPARATOR); | ||
| for (Node<Value> child : children) | ||
| NavigableSet<Node<Value, NODE>> result = new TreeSet<>(BRANCH_SIZE_COMPARATOR); | ||
| for (Node<Value, NODE> child : children) | ||
| if (child.filePos == -1) | ||
| result.add(child); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err: The method reset(NODE) in the type IncrementalTrieWriterBase<VALUE,DataOutputPlus,NODE> is not applicable for the arguments (IncrementalTrieWriterPageAware.Node<VALUE,NODE>)Java(67108979)