1 8 9 package com.sleepycat.je.tree; 10 11 import java.util.HashSet ; 12 import java.util.Iterator ; 13 import java.util.Set ; 14 15 import com.sleepycat.je.dbi.DatabaseId; 16 17 21 public class BINReference { 22 protected byte[] idKey; 23 private long nodeId; 24 private DatabaseId databaseId; 25 private Set deletedKeys; 27 BINReference(long nodeId, DatabaseId databaseId, byte[] idKey) { 28 this.nodeId = nodeId; 29 this.databaseId = databaseId; 30 this.idKey = idKey; 31 } 32 33 public long getNodeId() { 34 return nodeId; 35 } 36 37 public DatabaseId getDatabaseId() { 38 return databaseId; 39 } 40 41 public byte[] getKey() { 42 return idKey; 43 } 44 45 public byte[] getData() { 46 return null; 47 } 48 49 public void addDeletedKey(Key key) { 50 51 if (deletedKeys == null) { 52 deletedKeys = new HashSet (); 53 } 54 deletedKeys.add(key); 55 } 56 57 public void addDeletedKeys(BINReference other) { 58 59 if (deletedKeys == null) { 60 deletedKeys = new HashSet (); 61 } 62 if (other.deletedKeys != null) { 63 deletedKeys.addAll(other.deletedKeys); 64 } 65 } 66 67 public void removeDeletedKey(Key key) { 68 69 if (deletedKeys != null) { 70 deletedKeys.remove(key); 71 if (deletedKeys.size() == 0) { 72 deletedKeys = null; 73 } 74 } 75 } 76 77 public boolean hasDeletedKey(Key key) { 78 79 return (deletedKeys != null) && deletedKeys.contains(key); 80 } 81 82 public boolean deletedKeysExist() { 83 84 return ((deletedKeys != null) && (deletedKeys.size() > 0)); 85 } 86 87 public Iterator getDeletedKeyIterator() { 88 if (deletedKeys != null) { 89 return deletedKeys.iterator(); 90 } else { 91 return null; 92 } 93 } 94 95 98 public boolean equals(Object obj) { 99 if (this == obj) { 100 return true; 101 } 102 103 if (!(obj instanceof BINReference)) { 104 return false; 105 } 106 107 return ((BINReference) obj).nodeId == nodeId; 108 } 109 110 public int hashCode() { 111 return (int) nodeId; 112 } 113 114 public String toString() { 115 return "idKey=" + Key.getNoFormatString(idKey) + 116 " nodeId = " + nodeId + 117 " db=" + databaseId + 118 " deletedKeys=" + deletedKeys; 119 } 120 } 121 122 | Popular Tags |