1 24 package org.objectweb.jalisto.se.query.index; 25 26 import org.objectweb.jalisto.se.impl.LogicalOid; 27 import org.objectweb.jalisto.se.api.ClassDescription; 28 import org.objectweb.jalisto.se.api.query.FielComparator; 29 import org.objectweb.jalisto.se.api.query.Index; 30 import org.objectweb.jalisto.se.api.query.IndexManager; 31 import org.objectweb.jalisto.se.impl.InFileAddress; 32 import org.objectweb.jalisto.se.query.IndexManagerImpl; 33 import org.objectweb.jalisto.se.query.btree.BTree; 34 35 import java.util.Set ; 36 37 public class IndexBTreeImpl implements Index { 38 39 public IndexBTreeImpl(InFileAddress ifa, int fieldIndex, 40 ClassDescription meta, IndexManagerImpl indexManager) { 41 this.tree = new BTree(this, fieldIndex, meta, indexManager); 43 this.ifa = ifa; 44 this.className = meta.getClassName(); 45 this.fieldName = meta.getFieldNames()[fieldIndex]; 46 } 47 48 public Set get(Object key) { 49 return tree.getOidsFor(key); 50 } 51 52 public FielComparator getComparator() { 53 return tree.getComparator(); 54 } 55 56 public Set keySet() { 57 return tree.getKeys(); 58 } 59 60 public void put(Object key, LogicalOid value) { 61 tree.addOid(key, value); 62 } 63 64 public void remove(Object key, LogicalOid logicalOid) { 65 tree.removeOid(key, logicalOid); 66 } 67 68 public InFileAddress getIfa() { 69 return ifa; 70 } 71 72 public void setIndexManager(IndexManager indexManager) { 73 tree.setIndexManager((IndexManagerImpl) indexManager); 74 } 75 76 public void deleteIndex() { 77 tree.deleteTree(); 78 } 79 80 public String toFullString() { 81 StringBuffer sb = new StringBuffer (); 82 sb.append("IndexBTreeImpl on class ").append(className); 83 sb.append(" and field ").append(fieldName); 84 sb.append(":\n").append(tree); 85 return sb.toString(); 86 } 87 88 public BTree getTree() { 89 return tree; 90 } 91 92 public String toString() { 93 return "IndexBTreeImpl(" + className + "," + fieldName + ")"; 94 } 95 96 private InFileAddress ifa; 97 private BTree tree; 98 private String className; 99 private String fieldName; 100 101 public static final short TYPE = 1; 102 } 103 | Popular Tags |