Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/entry/ci/BitLocatorImpl.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.entry.ci; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import org.dancres.blitz.oid.OID; | |
6 | |
7 import org.dancres.blitz.entry.TupleLocator; | |
8 | |
9 import org.dancres.struct.BitIndex; | |
10 import org.dancres.struct.BitVisitor; | |
11 | |
12 /** | |
13 Used by CacheIndexer. | |
14 */ | |
15 class BitLocatorImpl implements TupleLocator { | |
16 private BitVisitor theHits; | |
17 private OID[] theOIDs; | |
18 private int theIndex = 0; | |
19 private OID theCurrent; | |
20 | |
21 BitLocatorImpl(BitIndex aHits, OID[] aListOfOIDs, boolean hitOnZero) { | |
22 theOIDs = aListOfOIDs; | |
23 theHits = aHits.getVisitor(hitOnZero); | |
24 } | |
25 | |
26 /** | |
27 Invoke this to load the next matching Tuple. | |
28 | |
29 @return <code>true</code> if there was a tuple, <code>false</code> | |
30 otherwise | |
31 */ | |
32 public boolean fetchNext() throws IOException { | |
33 int myNext; | |
34 | |
35 while ((myNext = theHits.getNext()) != -1) { | |
36 theCurrent = (OID) theOIDs[myNext]; | |
37 | |
38 if (theCurrent != null) | |
39 return true; | |
40 else { | |
41 /* | |
42 System.err.println("There should've been a OID here: " + | |
43 myNext); | |
44 */ | |
45 } | |
46 } | |
47 | |
48 return false; | |
49 } | |
50 | |
51 /** | |
52 @return the OID of the tuple just fetched with | |
53 <code>fetchNext</code> | |
54 */ | |
55 public OID getOID() { | |
56 return theCurrent; | |
57 } | |
58 | |
59 /** | |
60 When you've finished with the TupleLocator instance, call release. | |
61 */ | |
62 public void release() throws IOException { | |
63 // System.out.println("Iterated: " + theIndex); | |
64 } | |
65 } |