/** * Returns the left most leaf from the current btree graph. * @throws IOException */ private BTreeNode<Key,Value> getLeftPeer(Transaction tx, BTreeNode<Key,Value> x) throws IOException { BTreeNode<Key,Value> cur = x; while( cur.parent !=null ) { if( cur.parent.children[0] == cur.getPageId() ) { cur = cur.parent; } else { for( int i=0; i < cur.parent.children.length; i ++) { if( cur.parent.children[i]==cur.getPageId() ) { return cur.parent.getChild(tx, i-1); } } throw new AssertionError("page "+x+" was decendent of "+cur.getPageId()); } } return null; }
public void printStructure(Transaction tx, PrintWriter out, String prefix) throws IOException { if( prefix.length()>0 && parent == null ) { throw new IllegalStateException("Cycle back to root node detected."); } if (parent == null) { prefix += "|"; out.println(prefix + getPageId()); } if( isBranch() ) { for(int i=0 ; i < children.length; i++) { BTreeNode<Key, Value> child = getChild(tx, i); if( i == children.length-1) { out.println(prefix+"\\- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")); child.printStructure(tx, out, prefix+" "); } else { out.println(prefix+"|- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")+" : "+keys[i]); child.printStructure(tx, out, prefix+" "); } } } }
rNode.setLeafData(rightKeys, rightValues); lNode.setLeafData(leftKeys, leftValues); lNode.setNext(rNode.getPageId()); setBranchData(v, new long[] { lNode.getPageId(), rNode.getPageId() }); } else { rNode.setNext(next); next = rNode.getPageId(); setLeafData(leftKeys, leftValues); rNode.setLeafData(rightKeys, rightValues); parent.promoteValue(tx, separator, rNode.getPageId());
idx = idx < 0 ? -(idx + 1) : idx + 1; BTreeNode<Key, Value> child = getChild(tx, idx); if( child.getPageId() == index.getPageId() ) { throw new IOException("BTree corrupted: Cycle detected.");
/** * Returns the left most leaf from the current btree graph. * @throws IOException */ private BTreeNode<Key,Value> getLeftPeer(Transaction tx, BTreeNode<Key,Value> x) throws IOException { BTreeNode<Key,Value> cur = x; while( cur.parent !=null ) { if( cur.parent.children[0] == cur.getPageId() ) { cur = cur.parent; } else { for( int i=0; i < cur.parent.children.length; i ++) { if( cur.parent.children[i]==cur.getPageId() ) { return cur.parent.getChild(tx, i-1); } } throw new AssertionError("page "+x+" was decendent of "+cur.getPageId()); } } return null; }
/** * Returns the left most leaf from the current btree graph. * @throws IOException */ private BTreeNode<Key,Value> getLeftPeer(Transaction tx, BTreeNode<Key,Value> x) throws IOException { BTreeNode<Key,Value> cur = x; while( cur.parent !=null ) { if( cur.parent.children[0] == cur.getPageId() ) { cur = cur.parent; } else { for( int i=0; i < cur.parent.children.length; i ++) { if( cur.parent.children[i]==cur.getPageId() ) { return cur.parent.getChild(tx, i-1); } } throw new AssertionError("page "+x+" was decendent of "+cur.getPageId()); } } return null; }
/** * Returns the left most leaf from the current btree graph. * @throws IOException */ private BTreeNode<Key,Value> getLeftPeer(Transaction tx, BTreeNode<Key,Value> x) throws IOException { BTreeNode<Key,Value> cur = x; while( cur.parent !=null ) { if( cur.parent.children[0] == cur.getPageId() ) { cur = cur.parent; } else { for( int i=0; i < cur.parent.children.length; i ++) { if( cur.parent.children[i]==cur.getPageId() ) { return cur.parent.getChild(tx, i-1); } } throw new AssertionError("page "+x+" was decendent of "+cur.getPageId()); } } return null; }
public void printStructure(Transaction tx, PrintWriter out, String prefix) throws IOException { if( prefix.length()>0 && parent == null ) { throw new IllegalStateException("Cycle back to root node detected."); } if (parent == null) { prefix += "|"; out.println(prefix + getPageId()); } if( isBranch() ) { for(int i=0 ; i < children.length; i++) { BTreeNode<Key, Value> child = getChild(tx, i); if( i == children.length-1) { out.println(prefix+"\\- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")); child.printStructure(tx, out, prefix+" "); } else { out.println(prefix+"|- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")+" : "+keys[i]); child.printStructure(tx, out, prefix+" "); } } } }
public void printStructure(Transaction tx, PrintWriter out, String prefix) throws IOException { if( prefix.length()>0 && parent == null ) { throw new IllegalStateException("Cycle back to root node detected."); } if (parent == null) { prefix += "|"; out.println(prefix + getPageId()); } if( isBranch() ) { for(int i=0 ; i < children.length; i++) { BTreeNode<Key, Value> child = getChild(tx, i); if( i == children.length-1) { out.println(prefix+"\\- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")); child.printStructure(tx, out, prefix+" "); } else { out.println(prefix+"|- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")+" : "+keys[i]); child.printStructure(tx, out, prefix+" "); } } } }
public void printStructure(Transaction tx, PrintWriter out, String prefix) throws IOException { if( prefix.length()>0 && parent == null ) { throw new IllegalStateException("Cycle back to root node detected."); } if (parent == null) { prefix += "|"; out.println(prefix + getPageId()); } if( isBranch() ) { for(int i=0 ; i < children.length; i++) { BTreeNode<Key, Value> child = getChild(tx, i); if( i == children.length-1) { out.println(prefix+"\\- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")); child.printStructure(tx, out, prefix+" "); } else { out.println(prefix+"|- "+child.getPageId()+(child.isBranch()?" ("+child.children.length+")":"")+" : "+keys[i]); child.printStructure(tx, out, prefix+" "); } } } }
rNode.setLeafData(rightKeys, rightValues); lNode.setLeafData(leftKeys, leftValues); lNode.setNext(rNode.getPageId()); setBranchData(v, new long[] { lNode.getPageId(), rNode.getPageId() }); } else { rNode.setNext(next); next = rNode.getPageId(); setLeafData(leftKeys, leftValues); rNode.setLeafData(rightKeys, rightValues); parent.promoteValue(tx, separator, rNode.getPageId());
rNode.setLeafData(rightKeys, rightValues); lNode.setLeafData(leftKeys, leftValues); lNode.setNext(rNode.getPageId()); setBranchData(v, new long[] { lNode.getPageId(), rNode.getPageId() }); } else { rNode.setNext(next); next = rNode.getPageId(); setLeafData(leftKeys, leftValues); rNode.setLeafData(rightKeys, rightValues); parent.promoteValue(tx, separator, rNode.getPageId());
rNode.setLeafData(rightKeys, rightValues); lNode.setLeafData(leftKeys, leftValues); lNode.setNext(rNode.getPageId()); setBranchData(v, new long[] { lNode.getPageId(), rNode.getPageId() }); } else { rNode.setNext(next); next = rNode.getPageId(); setLeafData(leftKeys, leftValues); rNode.setLeafData(rightKeys, rightValues); parent.promoteValue(tx, separator, rNode.getPageId());
idx = idx < 0 ? -(idx + 1) : idx + 1; BTreeNode<Key, Value> child = getChild(tx, idx); if( child.getPageId() == index.getPageId() ) { throw new IOException("BTree corrupted: Cycle detected.");
idx = idx < 0 ? -(idx + 1) : idx + 1; BTreeNode<Key, Value> child = getChild(tx, idx); if( child.getPageId() == index.getPageId() ) { throw new IOException("BTree corrupted: Cycle detected.");
idx = idx < 0 ? -(idx + 1) : idx + 1; BTreeNode<Key, Value> child = getChild(tx, idx); if( child.getPageId() == index.getPageId() ) { throw new IOException("BTree corrupted: Cycle detected.");