1 21 22 package org.apache.derby.impl.store.access.btree; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.services.io.Storable; 26 27 import org.apache.derby.iapi.error.StandardException; 28 29 import org.apache.derby.iapi.store.access.RowUtil; 30 31 import org.apache.derby.iapi.store.raw.ContainerHandle; 32 33 import org.apache.derby.iapi.types.DataValueDescriptor; 34 35 import org.apache.derby.iapi.types.SQLLongint; 36 import org.apache.derby.iapi.services.io.FormatableBitSet; 37 38 39 54 55 public class BranchRow 56 { 57 58 public static final long DUMMY_PAGE_NUMBER = 0xffffffffffffffffL; 59 60 66 68 71 private DataValueDescriptor[] branchrow = null; 72 73 76 77 81 private BranchRow() 82 { 83 } 84 85 private BranchRow(BTree btree) 86 throws StandardException 87 { 88 SQLLongint child_page = 89 new SQLLongint(ContainerHandle.INVALID_PAGE_NUMBER); 90 91 branchrow = btree.createBranchTemplate(child_page); 92 93 if (SanityManager.DEBUG) 94 { 95 SanityManager.ASSERT( 96 child_page == ((SQLLongint) branchrow[branchrow.length - 1])); 97 } 98 } 99 100 103 104 109 private SQLLongint getChildPage() 110 { 111 if (SanityManager.DEBUG) 113 { 114 SanityManager.ASSERT(branchrow != null); 115 SanityManager.ASSERT( 116 branchrow[branchrow.length - 1] instanceof SQLLongint); 117 } 118 119 return((SQLLongint) branchrow[branchrow.length - 1]); 120 } 121 122 125 126 133 public static BranchRow createEmptyTemplate(BTree btree) 134 throws StandardException 135 { 136 BranchRow newbranch = new BranchRow(btree); 137 138 return(new BranchRow(btree)); 139 } 140 141 158 public BranchRow createBranchRowFromOldBranchRow(long childpageno) 159 { 160 BranchRow newbranch = new BranchRow(); 161 162 165 166 newbranch.branchrow = new DataValueDescriptor[this.branchrow.length]; 167 System.arraycopy( 168 this.branchrow, 0, newbranch.branchrow, 0, 169 newbranch.branchrow.length - 1); 170 171 174 newbranch.branchrow[newbranch.branchrow.length - 1] = 175 new SQLLongint(childpageno); 176 177 return(newbranch); 178 } 179 180 196 public static BranchRow createBranchRowFromOldLeafRow( 197 DataValueDescriptor[] leafrow, 198 long childpageno) 199 { 200 BranchRow newbranch = new BranchRow(); 201 202 205 newbranch.branchrow = new DataValueDescriptor[leafrow.length + 1]; 206 207 System.arraycopy(leafrow, 0, newbranch.branchrow, 0, leafrow.length); 208 209 212 newbranch.branchrow[newbranch.branchrow.length - 1] = 213 new SQLLongint(childpageno); 214 215 return(newbranch); 216 } 217 218 227 protected DataValueDescriptor[] getRow() 228 { 229 return(this.branchrow); 230 } 231 232 237 protected void setPageNumber(long page_number) 238 { 239 getChildPage().setValue(page_number); 240 } 241 242 243 public String toString() 244 { 245 if (SanityManager.DEBUG) 246 { 247 return( 248 RowUtil.toString(branchrow) + 249 "child page: (" + getChildPage() + ")"); 250 } 251 else 252 { 253 return(null); 254 } 255 } 256 } 257 | Popular Tags |