final void writeCachePrimer(final DataOutput dout) throws IOException { traverseLoaded((node) -> { byte[] midKey; try { if (!node.isLeaf()) { return; } int numKeys = node.numKeys(); if (numKeys > 1) { int highPos = numKeys & ~1; midKey = node.midKey(highPos - 2, node, highPos); } else if (numKeys == 1) { midKey = node.retrieveKey(0); } else { return; } } finally { node.releaseExclusive(); } // Omit entries with very large keys. Primer encoding format needs to change // for supporting larger keys. if (midKey.length < 0xffff) { dout.writeShort(midKey.length); dout.write(midKey); } }); // Terminator. dout.writeShort(0xffff); }
final void writeCachePrimer(final DataOutput dout) throws IOException { traverseLoaded((node) -> { byte[] midKey; try { if (!node.isLeaf()) { return; } int numKeys = node.numKeys(); if (numKeys > 1) { int highPos = numKeys & ~1; midKey = node.midKey(highPos - 2, node, highPos); } else if (numKeys == 1) { midKey = node.retrieveKey(0); } else { return; } } finally { node.releaseExclusive(); } // Omit entries with very large keys. Primer encoding format needs to change // for supporting larger keys. if (midKey.length < 0xffff) { dout.writeShort(midKey.length); dout.write(midKey); } }); // Terminator. dout.writeShort(0xffff); }
final void writeCachePrimer(final DataOutput dout) throws IOException { traverseLoaded((node) -> { byte[] midKey; try { if (!node.isLeaf()) { return; } int numKeys = node.numKeys(); if (numKeys > 1) { int highPos = numKeys & ~1; midKey = node.midKey(highPos - 2, node, highPos); } else if (numKeys == 1) { midKey = node.retrieveKey(0); } else { return; } } finally { node.releaseExclusive(); } // Omit entries with very large keys. Primer encoding format needs to change // for supporting larger keys. if (midKey.length < 0xffff) { dout.writeShort(midKey.length); dout.write(midKey); } }); // Terminator. dout.writeShort(0xffff); }
/** * Returns a new key between the low key in this node and the high key of another node. * * @see Utils#midKey */ byte[] midKey(int lowPos, Node highNode, int highPos) throws IOException { final /*P*/ byte[] lowPage = mPage; int lowLoc = p_ushortGetLE(lowPage, searchVecStart() + lowPos); int lowKeyLen = p_byteGet(lowPage, lowLoc); if (lowKeyLen < 0) { // Note: An optimized version wouldn't need to copy the whole key. return highNode.midKey(retrieveKeyAtLoc(lowPage, lowLoc), highPos); } lowLoc++; lowKeyLen++; final /*P*/ byte[] highPage = highNode.mPage; int highLoc = p_ushortGetLE(highPage, highNode.searchVecStart() + highPos); int highKeyLen = p_byteGet(highPage, highLoc); if (highKeyLen < 0) { // Note: An optimized version wouldn't need to copy the whole key. byte[] highKey = retrieveKeyAtLoc(highPage, highLoc); return p_midKeyLowPage(lowPage, lowLoc, lowKeyLen, highKey, 0); } return p_midKeyLowHighPage(lowPage, lowLoc, lowKeyLen, highPage, highLoc + 1); }
/** * Returns a new key between the low key in this node and the high key of another node. * * @see Utils#midKey */ byte[] midKey(int lowPos, Node highNode, int highPos) throws IOException { final /*P*/ byte[] lowPage = mPage; int lowLoc = p_ushortGetLE(lowPage, searchVecStart() + lowPos); int lowKeyLen = p_byteGet(lowPage, lowLoc); if (lowKeyLen < 0) { // Note: An optimized version wouldn't need to copy the whole key. return highNode.midKey(retrieveKeyAtLoc(lowPage, lowLoc), highPos); } lowLoc++; lowKeyLen++; final /*P*/ byte[] highPage = highNode.mPage; int highLoc = p_ushortGetLE(highPage, highNode.searchVecStart() + highPos); int highKeyLen = p_byteGet(highPage, highLoc); if (highKeyLen < 0) { // Note: An optimized version wouldn't need to copy the whole key. byte[] highKey = retrieveKeyAtLoc(highPage, highLoc); return p_midKeyLowPage(lowPage, lowLoc, lowKeyLen, highKey, 0); } return p_midKeyLowHighPage(lowPage, lowLoc, lowKeyLen, highPage, highLoc + 1); }
/** * Returns a new key between the low key in this node and the high key of another node. * * @see Utils#midKey */ byte[] midKey(int lowPos, Node highNode, int highPos) throws IOException { final /*P*/ byte[] lowPage = mPage; int lowLoc = p_ushortGetLE(lowPage, searchVecStart() + lowPos); int lowKeyLen = p_byteGet(lowPage, lowLoc); if (lowKeyLen < 0) { // Note: An optimized version wouldn't need to copy the whole key. return highNode.midKey(retrieveKeyAtLoc(lowPage, lowLoc), highPos); } lowLoc++; lowKeyLen++; final /*P*/ byte[] highPage = highNode.mPage; int highLoc = p_ushortGetLE(highPage, highNode.searchVecStart() + highPos); int highKeyLen = p_byteGet(highPage, highLoc); if (highKeyLen < 0) { // Note: An optimized version wouldn't need to copy the whole key. byte[] highKey = retrieveKeyAtLoc(highPage, highLoc); return p_midKeyLowPage(lowPage, lowLoc, lowKeyLen, highKey, 0); } return p_midKeyLowHighPage(lowPage, lowLoc, lowKeyLen, highPage, highLoc + 1); }
split = newSplitRight(newNode); split.setKey(tree, midKey(highestLeafPos(), snode, spos)); } catch (Throwable e) { cleanupSplit(e, newNode, split);
split = newSplitLeft(newNode); split.setKey(tree, midKey(okey, 0)); } catch (Throwable e) { cleanupSplit(e, newNode, split); split = newSplitRight(newNode); split.setKey(tree, midKey(pos - searchVecStart - 2, okey)); } catch (Throwable e) { cleanupSplit(e, newNode, split); mSplit.setKey(tree, newNode.midKey(newNode.highestKeyPos(), this, 0)); mSplit.setKey(tree, this.midKey(this.highestKeyPos(), newNode, 0));
split = newSplitLeft(newNode); setSplitKey(tree, split, midKey(okey, 0)); } catch (Throwable e) { cleanupSplit(e, newNode, split); split = newSplitRight(newNode); setSplitKey(tree, split, midKey(pos - searchVecStart - 2, okey)); } catch (Throwable e) { cleanupSplit(e, newNode, split); setSplitKey(tree, mSplit, newNode.midKey(newNode.highestKeyPos(), this, 0)); setSplitKey(tree, mSplit, this.midKey(this.highestKeyPos(), newNode, 0));
split = newSplitLeft(newNode); setSplitKey(tree, split, midKey(okey, 0)); } catch (Throwable e) { cleanupSplit(e, newNode, split); split = newSplitRight(newNode); setSplitKey(tree, split, midKey(pos - searchVecStart - 2, okey)); } catch (Throwable e) { cleanupSplit(e, newNode, split); setSplitKey(tree, mSplit, newNode.midKey(newNode.highestKeyPos(), this, 0)); setSplitKey(tree, mSplit, this.midKey(this.highestKeyPos(), newNode, 0));
newKey = midKey(highPos - 2, this, highPos);
newKey = midKey(highPos - 2, this, highPos);
newKey = midKey(highPos - 2, this, highPos);
newKey = midKey(highPos - 2, this, highPos);
newKey = midKey(highPos - 2, this, highPos);
Node highNode = highCursor.notSplitDirty(highFrame); try { midKey = lowNode.midKey(lowNode.highestLeafPos(), highNode, 0); } finally { highNode.releaseExclusive();
newKey = midKey(highPos - 2, this, highPos);