private void visitorAltBranch(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final long unfoundResult, short[] data) { int localJump = i + TrieParser.SIZE_OF_ALT_BRANCH; int jump = (((int)data[pos++])<<15) | (0x7FFF&data[pos++]); visit(that, localJump, visitor, source, localSourcePos, sourceLength, sourceMask, unfoundResult);// near byte visit(that, localJump+jump, visitor, source, localSourcePos, sourceLength, sourceMask, unfoundResult);// 2nd call with branch }
private void visitorAltBranch(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, short[] data) { int localJump = i + TrieParser.SIZE_OF_ALT_BRANCH; int jump = (((int)data[pos++])<<15) | (0x7FFF&data[pos++]); visit(that, localJump, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant);// near byte visit(that, localJump+jump, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant);// 2nd call with branch }
private void visitorAltBranch(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, short[] data) { int localJump = i + TrieParser.SIZE_OF_ALT_BRANCH; int jump = (((int)data[pos++])<<15) | (0x7FFF&data[pos++]); visit(that, localJump, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant);// near byte visit(that, localJump+jump, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant);// 2nd call with branch }
public void visit(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, long unfound, long noMatch) { visit(that, 0, visitor, source, localSourcePos, sourceLength, sourceMask, unfound, noMatch); }
public void visit(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, long unfound, long noMatch) { visit(that, 0, visitor, source, localSourcePos, sourceLength, sourceMask, unfound, noMatch); }
/** * Given a visitor reads every path unless visitor returns false on open, in that case that branch will not be followed. * When visit reaches the end the value of the byte array is returned. * * Use Cases: * * We have a "template" and need to find all the existing paths that match it. For example find which known topics match a new subscription in MQTT. * * //NOTE: if we add the new type TYPE_VALUE_BYTES * We have a new path and need to find all the values in the tree that match it. For example find which known subscriptions a new topic should go to in MQTT. * * TODO: Build test that rebuilds the full list of strings and their associated values. * * */ public void visit(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask) { visit(that, 0, visitor, source, localSourcePos, sourceLength, sourceMask, -1); }
/** * Given a visitor reads every path unless visitor returns false on open, in that case that branch will not be followed. * When visit reaches the end the value of the byte array is returned. * * Use Cases: * * We have a "template" and need to find all the existing paths that match it. For example find which known topics match a new subscription in MQTT. * * //NOTE: if we add the new type TYPE_VALUE_BYTES * We have a new path and need to find all the values in the tree that match it. For example find which known subscriptions a new topic should go to in MQTT. * * TODO: Build test that rebuilds the full list of strings and their associated values. * * */ public void visit(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask) { visit(that, 0, visitor, source, localSourcePos, sourceLength, sourceMask, -1, -1); }
/** * Given a visitor reads every path unless visitor returns false on open, in that case that branch will not be followed. * When visit reaches the end the value of the byte array is returned. * * Use Cases: * * We have a "template" and need to find all the existing paths that match it. For example find which known topics match a new subscription in MQTT. * * //NOTE: if we add the new type TYPE_VALUE_BYTES * We have a new path and need to find all the values in the tree that match it. For example find which known subscriptions a new topic should go to in MQTT. * * TODO: Build test that rebuilds the full list of strings and their associated values. * * */ public void visit(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask) { visit(that, 0, visitor, source, localSourcePos, sourceLength, sourceMask, -1, -1); }
private void visitorRun(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final long unfoundResult, short[] data) { byte caseMask = that.caseRuleMask; int r1 = data[pos]; int t1 = pos +1; int t2 = localSourcePos; while ((--r1 >= 0) && ((caseMask&data[t1++]) == (caseMask&source[sourceMask & t2++])) ) { //getting slash somewhere should not equal eachother. //matching characters while decrementing run length. } pos = t1; localSourcePos = t2; int r = r1; if (r >= 0) { return; } else { //int idx = pos + TrieParser.SIZE_OF_RUN-1; //visit(that, idx+run, visitor, source, localSourcePos+run, sourceLength, sourceMask, unfoundResult); //visit(that, pos, visitor, source, localSourcePos+run, sourceLength, sourceMask, unfoundResult); visit(that, pos, visitor, source, localSourcePos, sourceLength, sourceMask, unfoundResult); //** took run off localsourcePos. } }
private void visitorBranch(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final short[] data) { if (this.runLength<sourceLength) { //TrieMap data final int p = 1+pos; pos = (0==(0xFFFFFF&TrieParser.computeJumpMask((short) source[sourceMask & localSourcePos], data[pos]))) ? 3+pos : 2+p+((((int)data[p])<<15) | (0x7FFF&data[1+p])); visit(that, pos, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant);//only that jump } else{ return; } }
private void visitorBranch(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final long unfoundResult, short[] data) { if (this.runLength<sourceLength) { //TrieMap data final short[] data1 = data; final int p = 1+pos; pos = (0==(0xFFFFFF&TrieParser.computeJumpMask((short) source[sourceMask & localSourcePos], data[pos]))) ? 3+pos : 2+p+((((int)data1[p])<<15) | (0x7FFF&data1[1+p])); visit(that, pos, visitor, source, localSourcePos, sourceLength, sourceMask, unfoundResult);//only that jump } else{ return; } }
private void visitorBranch(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final short[] data) { if (this.runLength<sourceLength) { //TrieMap data final int p = 1+pos; pos = (0==(0xFFFFFF&TrieParser.computeJumpMask((short) source[sourceMask & localSourcePos], data[pos]))) ? 3+pos : 2+p+((((int)data[p])<<15) | (0x7FFF&data[1+p])); visit(that, pos, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant);//only that jump } else{ return; } }
private void visitorNumeric(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final long unfoundResult, int run) { int idx; int temp_pos=0; idx = i + TrieParser.SIZE_OF_VALUE_NUMERIC; int templateLimit = Integer.MAX_VALUE; if (this.runLength<sourceLength && (temp_pos = parseNumeric(that.ESCAPE_BYTE, this, source, localSourcePos, sourceLength, sourceMask, that.data[pos++]))<0){ return; } localSourcePos = temp_pos; //recurse into visit() visit(that, idx+run, visitor, source, localSourcePos, sourceLength, sourceMask, unfoundResult); }
private void visitorNumeric(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, int run) { int idx; int temp_pos=0; idx = i + TrieParser.SIZE_OF_VALUE_NUMERIC; int templateLimit = Integer.MAX_VALUE; if (this.runLength<sourceLength && (temp_pos = parseNumeric(that.ESCAPE_BYTE, this, source, localSourcePos, sourceLength, sourceMask, that.data[pos++]))<0){ return; } localSourcePos = temp_pos; //recurse into visit() visit(that, idx+run, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant); }
private void visitorNumeric(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, int run) { int idx; int temp_pos=0; idx = i + TrieParser.SIZE_OF_VALUE_NUMERIC; int templateLimit = Integer.MAX_VALUE; if (this.runLength<sourceLength && (temp_pos = parseNumeric(that.ESCAPE_BYTE, this, source, localSourcePos, sourceLength, sourceMask, that.data[pos++]))<0){ return; } localSourcePos = temp_pos; //recurse into visit() visit(that, idx+run, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant); }
private void visitorValueBytes(TrieParser that, final int i, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask) { int idx; int temp_pos; short stopValue; int byte_size = that.data[i+1]; stopValue = that.data[pos++]; idx = i + TrieParser.SIZE_OF_VALUE_BYTES; /* * This will result the position, after parsing all the bytes if any */ if((temp_pos=parseBytes(this, source, localSourcePos, byte_size-localSourcePos, sourceMask, stopValue))<0){ return; } localSourcePos = temp_pos; if(stopValue==byte_size){ byte_size = 0; } //recurse into visit() visit(that, idx+byte_size, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant); }
void collectAllSubscriptionLists(final byte[] backing, final int pos, final int len, final int mask) { //right after all the subscribers use the rest of the data if (null != visitor) { visitor.reset(subscriberLists, subscriberListSize*totalSubscriberLists); } else { visitor = new CollectTargetLists(subscriberLists, subscriberListSize*totalSubscriberLists); } localSubscriptionTrieReader.visit(localSubscriptionTrie, visitor, backing, pos, len, mask); subscriberLists = visitor.targetArray(); //must assign back in case we made it grow. }
private void visitorSafeEnd(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask) { recordSafePointEnd(this, localSourcePos, pos, that); pos += that.SIZE_OF_RESULT; if (sourceLength == localSourcePos) { this.result = useSafePointNow(this); //add to result set visitor.addToResult(this.result); return; } else{ //recurse visit visit(that, this.pos, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant); } }
private void visitorSafeEnd(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask, final long unfoundResult) { recordSafePointEnd(this, localSourcePos, pos, that); pos += that.SIZE_OF_RESULT; if (sourceLength == localSourcePos) { this.result = useSafePointNow(this); //add to result set visitor.addToResult(this.result); return; } else{ //recurse visit visit(that, this.pos, visitor, source, localSourcePos, sourceLength, sourceMask, unfoundResult); } }
private void visitorSafeEnd(TrieParser that, ByteSquenceVisitor visitor, byte[] source, int localSourcePos, int sourceLength, int sourceMask) { recordSafePointEnd(this, localSourcePos, pos, that); pos += that.SIZE_OF_RESULT; if (sourceLength == localSourcePos) { this.result = useSafePointNow(this); //add to result set visitor.addToResult(this.result); return; } else{ //recurse visit visit(that, this.pos, visitor, source, localSourcePos, sourceLength, sourceMask, this.unfoundConstant, this.noMatchConstant); } }