View Javadoc

1   package org.paneris.bibliomania.fti;
2   
3   import org.melati.poem.transaction.ToTidyList;
4   
5   import com.sleepycat.db.Db;
6   import com.sleepycat.db.DbException;
7   import com.sleepycat.db.Dbc;
8   import com.sleepycat.db.Dbt;
9   
10  public class IndexCursor implements ToTidyList.Closeable {
11    private final Dbc texts;
12    private final Dbt word_text;
13    private final Dbt occurrencesData;
14  
15    //private int wordID = -1;
16  
17    IndexCursor(IndexOther index) throws DbException {
18      texts = index.occurrencesOfWordInText.cursor(null, 0);
19      word_text = DbUtils.userMemDbt(IndexOther.wtBytesLength);
20      occurrencesData = DbUtils.userMemDbt(500);
21    }
22  
23    public boolean next() {
24      return DbUtils.get(texts, word_text, occurrencesData, Db.DB_NEXT, 500) == 0;
25    }
26  
27    public long textID() {
28      return IndexOther.getWT_textID(word_text.getData());
29    }
30  
31    public int wordID() {
32      return IndexOther.getWT_wordID(word_text.getData());
33    }
34  
35    public void close() {
36      try {
37        texts.close();
38      }
39      catch (Exception e) {}
40    }
41  }