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