public void save() throws IOException { // must own the write lock of the monitor if (!hasChanged()) return; this.diskIndex.separator = this.separator; this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex); this.memoryIndex = new MemoryIndex(); } public void startQuery() {
/** * Reset memory and disk indexes. * * @throws IOException */ public void reset() throws IOException { this.memoryIndex = new MemoryIndex(); this.diskIndex = new DiskIndex(this.diskIndex.indexLocation); this.diskIndex.initialize(false/*do not reuse the index file*/); } public void save() throws IOException {
public void stopQuery() { if (this.diskIndex != null) this.diskIndex.stopQuery(); } @Override
private void writeCategories(FileOutputStream stream) throws IOException { char[][] categoryNames = this.categoryTables.keyTable; Object[] tables = this.categoryTables.valueTable; for (int i = 0, l = categoryNames.length; i < l; i++) if (categoryNames[i] != null) writeCategoryTable(categoryNames[i], (HashtableOfObject) tables[i], stream); this.categoryTables = null; } private void writeCategoryTable(char[] categoryName, HashtableOfObject wordsToDocs, FileOutputStream stream) throws IOException {
public void startQuery() { if (this.diskIndex != null) this.diskIndex.startQuery(); } public void stopQuery() {
private int readStreamInt(InputStream stream) throws IOException { if (this.bufferIndex + 4 >= this.bufferEnd) { readStreamBuffer(stream); } int val = (this.streamBuffer[this.bufferIndex++] & 0xFF) << 24; val += (this.streamBuffer[this.bufferIndex++] & 0xFF) << 16; val += (this.streamBuffer[this.bufferIndex++] & 0xFF) << 8; return val + (this.streamBuffer[this.bufferIndex++] & 0xFF); } private void writeAllDocumentNames(String[] sortedDocNames, FileOutputStream stream) throws IOException {
public void save() throws IOException { // must own the write lock of the monitor if (!hasChanged()) return; int numberOfChanges = this.memoryIndex.docsToReferences.elementSize; this.diskIndex.separator = this.separator; this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex); this.memoryIndex = new MemoryIndex(); if (numberOfChanges > 1000) System.gc(); // reclaim space if the MemoryIndex was very BIG } public void startQuery() {
/** * Reset memory and disk indexes. * * @throws IOException */ public void reset() throws IOException { this.memoryIndex = new MemoryIndex(); this.diskIndex = new DiskIndex(this.diskIndex.indexLocation); this.diskIndex.initialize(false/*do not reuse the index file*/); } public void save() throws IOException {
private void writeCategories(FileOutputStream stream) throws IOException { char[][] categoryNames = this.categoryTables.keyTable; Object[] tables = this.categoryTables.valueTable; for (int i = 0, l = categoryNames.length; i < l; i++) if (categoryNames[i] != null) writeCategoryTable(categoryNames[i], (HashtableOfObject) tables[i], stream); this.categoryTables = null; } private void writeCategoryTable(char[] categoryName, HashtableOfObject wordsToDocs, FileOutputStream stream) throws IOException {
public void stopQuery() { if (this.diskIndex != null) this.diskIndex.stopQuery(); } public String toString() {
public void startQuery() { if (this.diskIndex != null) this.diskIndex.startQuery(); } public void stopQuery() {
public void save() throws IOException { // must own the write lock of the monitor if (!hasChanged()) return; int numberOfChanges = this.memoryIndex.docsToReferences.elementSize; this.diskIndex.separator = this.separator; this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex); this.memoryIndex = new MemoryIndex(); if (numberOfChanges > 1000) System.gc(); // reclaim space if the MemoryIndex was very BIG } public void startQuery() {
/** * Reset memory and disk indexes. * * @throws IOException */ public void reset() throws IOException { this.memoryIndex = new MemoryIndex(); this.diskIndex = new DiskIndex(this.diskIndex.indexLocation); this.diskIndex.initialize(false/*do not reuse the index file*/); } public void save() throws IOException {
private void writeCategories(FileOutputStream stream) throws IOException { char[][] categoryNames = this.categoryTables.keyTable; Object[] tables = this.categoryTables.valueTable; for (int i = 0, l = categoryNames.length; i < l; i++) if (categoryNames[i] != null) writeCategoryTable(categoryNames[i], (HashtableOfObject) tables[i], stream); this.categoryTables = null; } private void writeCategoryTable(char[] categoryName, HashtableOfObject wordsToDocs, FileOutputStream stream) throws IOException {
public void save() throws IOException { // must own the write lock of the monitor if (!hasChanged()) return; int numberOfChanges = this.memoryIndex.docsToReferences.elementSize; this.diskIndex.separator = this.separator; this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex); this.memoryIndex = new MemoryIndex(); if (numberOfChanges > 1000) System.gc(); // reclaim space if the MemoryIndex was very BIG } public void startQuery() {
/** * Reset memory and disk indexes. * * @throws IOException */ public void reset() throws IOException { this.memoryIndex = new MemoryIndex(); this.diskIndex = new DiskIndex(this.diskIndex.indexLocation); this.diskIndex.initialize(false/*do not reuse the index file*/); } public void save() throws IOException {
public void save() throws IOException { // must own the write lock of the monitor if (!hasChanged()) return; int numberOfChanges = this.memoryIndex.docsToReferences.elementSize; this.diskIndex.separator = this.separator; this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex); this.memoryIndex = new MemoryIndex(); if (numberOfChanges > 1000) System.gc(); // reclaim space if the MemoryIndex was very BIG } public void startQuery() {
/** * Reset memory and disk indexes. * * @throws IOException */ public void reset() throws IOException { this.memoryIndex = new MemoryIndex(); this.diskIndex = new DiskIndex(this.diskIndex.indexLocation); this.diskIndex.initialize(false/*do not reuse the index file*/); } public void save() throws IOException {
public void save() throws IOException { // must own the write lock of the monitor if (!hasChanged()) return; int numberOfChanges = this.memoryIndex.docsToReferences.elementSize; this.diskIndex.separator = this.separator; this.diskIndex = this.diskIndex.mergeWith(this.memoryIndex); this.memoryIndex = new MemoryIndex(); if (numberOfChanges > 1000) System.gc(); // reclaim space if the MemoryIndex was very BIG } public void startQuery() {
public Index(IndexLocation location, String containerPath, boolean reuseExistingFile) throws IOException { this.containerPath = containerPath; this.monitor = new ReadWriteMonitor(); this.memoryIndex = new MemoryIndex(); this.diskIndex = new DiskIndex(location); this.diskIndex.initialize(reuseExistingFile); if (reuseExistingFile) this.separator = this.diskIndex.separator; } public void addIndexEntry(char[] category, char[] key, String containerRelativePath) {