1 package com.daffodilwoods.daffodildb.server.datasystem.btree; 2 3 import com.daffodilwoods.database.resource.DException; 4 import com.daffodilwoods.database.utility.P; 5 import com.daffodilwoods.daffodildb.utils.BufferRange; 6 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._Index; 7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexKey; 8 9 12 13 public abstract class BTreeNavigator { 14 15 18 protected _IndexKey currentKey = null; 19 20 protected _Index btree; 21 22 public int status = -1; 23 24 public BTreeNavigator(_Index btree0) { 25 btree = btree0; 26 currentKey = btree.keyInstance(); 27 } 28 29 34 35 public boolean first() throws DException{ 36 37 boolean flag = btree.first(currentKey); 38 status = flag ? 0 : -1; 39 return flag; 40 } 41 42 47 48 public boolean next() throws DException { 49 boolean flag = btree.next(currentKey); 50 status = flag ? 0 : 1; 51 return flag; 52 } 53 54 59 public boolean last() throws DException{ 60 boolean flag = btree.last(currentKey); 61 status = flag ? 0 : 1; 62 return flag; 63 } 64 65 71 72 public boolean previous() throws DException{ 73 boolean flag = btree.previous(currentKey); 74 status = flag ? 0 : -1; 75 return flag; 76 } 77 78 public void move(Object key)throws DException{ 79 currentKey = (_IndexKey)key; 80 81 } 82 83 89 90 91 public abstract Object getKey()throws DException; 92 93 public abstract Object getValue()throws DException; 94 95 96 97 public abstract Object getCurrentKey() throws DException; 98 99 107 108 public abstract Object getColumnValues(int columnIndex) throws DException; 109 110 118 public abstract Object getColumnValues(int[] columnIndexes) throws DException; 119 120 121 public void setNodeAndPosition(Object node, int position)throws DException{ 122 currentKey.setNodeAndPosition(node,position); 123 status = (node == null || position == 0 ) ? -1 : 0; 124 } 125 } 126 | Popular Tags |