Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public TrieMemoryIndex(StorageAttachedIndex index)
@Override
public synchronized long add(DecoratedKey key, Clustering<?> clustering, ByteBuffer value)
{
//pranav: this one
value = index.termType().asIndexBytes(value);
final PrimaryKey primaryKey = index.hasClustering() ? index.keyFactory().create(key, clustering)
: index.keyFactory().create(key);
Expand Down Expand Up @@ -147,6 +148,9 @@ public KeyRangeIterator search(QueryContext queryContext, Expression expression,
case CONTAINS_KEY:
case CONTAINS_VALUE:
return exactMatch(expression, keyRange);
case LIKE_PREFIX:
//TODO: this needs to be handled cleaner way
expression.upper = null;
case RANGE:
KeyRangeIterator keyIterator = rangeMatch(expression, keyRange);
int keyCount = (int) keyIterator.getMaxKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ public float[] decomposeVector(ByteBuffer byteBuffer)

public boolean supports(Operator operator)
{
if (operator == Operator.LIKE ||
operator == Operator.LIKE_CONTAINS ||
operator == Operator.LIKE_PREFIX ||
if (operator == Operator.LIKE || operator == Operator.LIKE_PREFIX)
return true;
if (operator == Operator.LIKE_CONTAINS ||
operator == Operator.LIKE_MATCHES ||
operator == Operator.LIKE_SUFFIX ||
operator == Operator.IN) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Copy link
Contributor Author

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)

}

@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();
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down