1 package net.obsearch.storage.tc;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.util.Iterator;
22 import java.util.NoSuchElementException;
23 import net.obsearch.storage.CloseIterator;
24 import net.obsearch.exception.OBException;
25 import net.obsearch.exception.OBStorageException;
26 import net.obsearch.storage.OBStorageConfig;
27 import net.obsearch.storage.OBStoreLong;
28 import net.obsearch.storage.TupleLong;
29
30 import com.sleepycat.bind.tuple.LongBinding;
31
32 import com.sleepycat.je.DatabaseEntry;
33
34 import com.sleepycat.bind.tuple.TupleOutput;
35 import com.sleepycat.bind.tuple.TupleInput;
36
37 import com.sleepycat.je.Database;
38 import com.sleepycat.je.DatabaseException;
39 import com.sleepycat.je.OperationStatus;
40 import java.nio.ByteBuffer;
41
42 import tokyocabinet.DBM;
43 import net.obsearch.storage.OBStoreFactory;
44
45
46
47
48
49
50
51
52 public final class TCOBStorageLong extends AbstractTCOBStorage<TupleLong>
53 implements OBStoreLong {
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 public TCOBStorageLong(String name, DBM db, OBStoreFactory fact,
71 OBStorageConfig storageConf) throws OBStorageException, OBException {
72 super(name, db, fact, storageConf);
73 }
74
75 public net.obsearch.OperationStatus delete(long key)
76 throws OBStorageException {
77 return super.delete(getBytes(key));
78 }
79
80
81
82
83
84
85
86
87 private byte[] getBytes(long value) {
88 return fact.serializeLong(value);
89 }
90
91
92
93
94
95
96
97 public long bytesToValue(byte[] entry) {
98 return fact.deSerializeLong(entry);
99 }
100
101 public byte[] getValue(long key) throws IllegalArgumentException,
102 OBStorageException {
103 return super.getValue(getBytes(key));
104 }
105
106 public net.obsearch.OperationStatus put(long key, byte[] value)
107 throws IllegalArgumentException, OBStorageException {
108 return super.put(getBytes(key), value);
109 }
110
111 public CloseIterator<TupleLong> processRange(long low, long high) {
112 throw new IllegalArgumentException();
113 }
114
115 public CloseIterator<TupleLong> processRangeNoDup(long low, long high)
116 throws OBStorageException {
117 throw new IllegalArgumentException();
118
119 }
120
121 public CloseIterator<TupleLong> processRangeReverse(long low, long high)
122 throws OBStorageException {
123 throw new IllegalArgumentException();
124
125 }
126
127 public CloseIterator<TupleLong> processRangeReverseNoDup(long low, long high)
128 throws OBStorageException {
129 throw new IllegalArgumentException();
130
131 }
132
133 public CloseIterator<TupleLong> processAll() throws OBStorageException {
134 return new LongIterator();
135 }
136
137
138
139
140
141
142
143
144
145
146 final class LongIterator extends CursorIterator<TupleLong> {
147
148 private LongIterator() throws OBStorageException {
149 super();
150 }
151
152 protected TupleLong createTuple(byte[] key, byte[] value) {
153 return new TupleLong(bytesToValue(key), value);
154 }
155 }
156
157 @Override
158 public byte[] prepareBytes(byte[] in) {
159 return in;
160 }
161 }