/************* methods *****************************/ public void positionAt(int offsetIntoBlock) { this.offsetIntoBlock = offsetIntoBlock; tokenLength = UVIntTool.getInt(block, offsetIntoBlock); tokenOffsetIntoBlock = offsetIntoBlock + UVIntTool.numBytes(tokenLength); int parentStartPositionIndex = tokenOffsetIntoBlock + tokenLength; int offsetWidth; if(nodeType == ColumnNodeType.FAMILY) { offsetWidth = blockMeta.getFamilyOffsetWidth(); } else if(nodeType == ColumnNodeType.QUALIFIER) { offsetWidth = blockMeta.getQualifierOffsetWidth(); } else { offsetWidth = blockMeta.getTagsOffsetWidth(); } parentStartPosition = (int) UFIntTool.fromBytes(block, parentStartPositionIndex, offsetWidth); }
/********************* methods *******************/ public ColumnReader populateBuffer(int offsetIntoColumnData) { clearColumnBuffer(); int nextRelativeOffset = offsetIntoColumnData; while (true) { int absoluteOffset = 0; if (nodeType == ColumnNodeType.FAMILY) { absoluteOffset = blockMeta.getAbsoluteFamilyOffset() + nextRelativeOffset; } else if (nodeType == ColumnNodeType.QUALIFIER) { absoluteOffset = blockMeta.getAbsoluteQualifierOffset() + nextRelativeOffset; } else { absoluteOffset = blockMeta.getAbsoluteTagsOffset() + nextRelativeOffset; } columnNodeReader.positionAt(absoluteOffset); columnOffset -= columnNodeReader.getTokenLength(); columnLength += columnNodeReader.getTokenLength(); columnNodeReader.prependTokenToBuffer(columnOffset); if (columnNodeReader.isRoot()) { return this; } nextRelativeOffset = columnNodeReader.getParentStartPosition(); } }
/*********************** construct ******************************/ // pass in blockMeta so we can initialize buffers big enough for all cells in the block public PrefixTreeArrayScanner(PrefixTreeBlockMeta blockMeta, int rowTreeDepth, int rowBufferLength, int qualifierBufferLength, int tagsBufferLength) { this.rowNodes = new RowNodeReader[rowTreeDepth]; for (int i = 0; i < rowNodes.length; ++i) { rowNodes[i] = new RowNodeReader(); } this.rowBuffer = new byte[rowBufferLength]; this.familyBuffer = new byte[PrefixTreeBlockMeta.MAX_FAMILY_LENGTH]; this.familyReader = new ColumnReader(familyBuffer, ColumnNodeType.FAMILY); this.qualifierBuffer = new byte[qualifierBufferLength]; this.tagsBuffer = new byte[tagsBufferLength]; this.qualifierReader = new ColumnReader(qualifierBuffer, ColumnNodeType.QUALIFIER); this.tagsReader = new ColumnReader(tagsBuffer, ColumnNodeType.TAGS); this.timestampDecoder = new TimestampDecoder(); this.mvccVersionDecoder = new MvccVersionDecoder(); }
public boolean isRoot() { if (nodeType == ColumnNodeType.FAMILY) { return offsetIntoBlock == blockMeta.getAbsoluteFamilyOffset(); } else if (nodeType == ColumnNodeType.QUALIFIER) { return offsetIntoBlock == blockMeta.getAbsoluteQualifierOffset(); } else { return offsetIntoBlock == blockMeta.getAbsoluteTagsOffset(); } }
/******************** construct *******************/ public ColumnReader(byte[] columnBuffer, ColumnNodeType nodeType) { this.columnBuffer = columnBuffer; this.nodeType = nodeType; this.columnNodeReader = new ColumnNodeReader(columnBuffer, nodeType); }
/*************** construct **************************/ public ColumnNodeWriter(PrefixTreeBlockMeta blockMeta, TokenizerNode builderNode, ColumnNodeType nodeType) { this.blockMeta = blockMeta; this.builderNode = builderNode; this.nodeType = nodeType; calculateTokenLength(); }
public void writeBytes(OutputStream os) throws IOException { int parentOffsetWidth; if (this.nodeType == ColumnNodeType.FAMILY) { parentOffsetWidth = blockMeta.getFamilyOffsetWidth(); } else if (this.nodeType == ColumnNodeType.QUALIFIER) { parentOffsetWidth = blockMeta.getQualifierOffsetWidth(); } else { parentOffsetWidth = blockMeta.getTagsOffsetWidth(); } UVIntTool.writeBytes(tokenLength, os); os.write(token); UFIntTool.writeBytes(parentOffsetWidth, parentStartPosition, os); }
/****************** methods *******************************/ public ColumnSectionWriter compile() { if (this.nodeType == ColumnNodeType.FAMILY) { // do nothing. max family length fixed at Byte.MAX_VALUE } else if (this.nodeType == ColumnNodeType.QUALIFIER) { blockMeta.setMaxQualifierLength(tokenizer.getMaxElementLength()); } else { blockMeta.setMaxTagsLength(tokenizer.getMaxElementLength()); } compilerInternals(); return this; }
protected void compileQualifiers() { blockMeta.setNumUniqueQualifiers(qualifierDeduplicator.size()); qualifierDeduplicator.compile(); qualifierTokenizer.addAll(qualifierDeduplicator.getSortedRanges()); qualifierWriter.reconstruct(blockMeta, qualifierTokenizer, ColumnNodeType.QUALIFIER); qualifierWriter.compile(); int numQualifierBytes = qualifierWriter.getNumBytes(); blockMeta.setNumQualifierBytes(numQualifierBytes); totalBytes += numQualifierBytes; }
protected void compileFamilies() { blockMeta.setNumUniqueFamilies(familyDeduplicator.size()); familyDeduplicator.compile(); familyTokenizer.addAll(familyDeduplicator.getSortedRanges()); familyWriter.reconstruct(blockMeta, familyTokenizer, ColumnNodeType.FAMILY); familyWriter.compile(); int numFamilyBytes = familyWriter.getNumBytes(); blockMeta.setNumFamilyBytes(numFamilyBytes); totalBytes += numFamilyBytes; }
protected void compileTags() { blockMeta.setNumUniqueTags(tagsDeduplicator.size()); tagsDeduplicator.compile(); tagsTokenizer.addAll(tagsDeduplicator.getSortedRanges()); tagsWriter.reconstruct(blockMeta, tagsTokenizer, ColumnNodeType.TAGS); tagsWriter.compile(); int numTagBytes = tagsWriter.getNumBytes(); blockMeta.setNumTagsBytes(numTagBytes); totalBytes += numTagBytes; }