1 6 7 package com.jofti.btree; 8 9 import com.jofti.oswego.concurrent.FIFOReadWriteLock; 10 import com.jofti.oswego.concurrent.ReadWriteLock; 11 12 13 14 15 16 23 abstract public class Node implements INode{ 24 25 public final ReadWriteLock nodeLock = new FIFOReadWriteLock(); 26 27 protected int entryNumber = 0; 28 29 30 protected Object [] split(Object [] tempEntries, int entryNumber) { 31 Object [] entriesList = new Object [2]; 33 34 36 int splitPoint = (entryNumber / 2); 37 38 Object [] newSplitValues = new Object [BTree.getMaxNodeSize()]; 39 40 41 int endPoint = entryNumber - splitPoint; 42 System.arraycopy(tempEntries,splitPoint,newSplitValues,0,endPoint); 44 45 EntrySplitWrapper splitWrapper = new EntrySplitWrapper(); 46 splitWrapper.size = endPoint; 47 splitWrapper.entries = newSplitValues; 48 49 for(int i=splitPoint;i<entryNumber;i++){ 51 tempEntries[i]=null; 52 } 53 54 EntrySplitWrapper replacementWrapper = new EntrySplitWrapper(); 55 replacementWrapper.size = splitPoint; 56 replacementWrapper.entries = tempEntries; 57 58 59 60 entriesList[0] =replacementWrapper; 61 entriesList[1]=splitWrapper; 62 return entriesList; 63 64 } 65 66 67 68 71 public ReadWriteLock getNodeLock() 72 { 73 return nodeLock; 74 } 75 76 79 public boolean isLeaf(){ 80 return false; 81 } 82 83 } 84 | Popular Tags |