Skip to content

Commit

Permalink
[GRAPHDB-57] implemented Lucene Index Optimize method
Browse files Browse the repository at this point in the history
  • Loading branch information
sunlounger committed Nov 30, 2011
1 parent 78c18b8 commit 34766d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Plugins/Index/Implementations/SonesLuceneIndex/LuceneIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ private IndexWriter GetIndexWriter()
return _IndexWriter;
}

private void CloseIndexWriter(IndexWriter myWriter)
private void CloseIndexWriter(IndexWriter myWriter, bool bOptimize=false)
{
myWriter.Optimize();
if (bOptimize) myWriter.Optimize();
myWriter.Close();
myWriter.Dispose();
}
Expand All @@ -104,6 +104,19 @@ private void CloseIndexReader(IndexReader myReader)
myReader.Dispose();
}

/// <summary>
/// Optimizes the index for fastest search.
/// </summary>
///
/// <exception cref="System.ArgumentNullException">
/// myEntry is NULL.
/// </exception>
public void Optimize()
{
var writer = GetIndexWriter();
CloseIndexWriter(writer, true);
}

/// <summary>
/// Adds the specified entry to the index.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ public override bool TryRemoveValue(IComparable myKey, long myValue)

public override void Optimize()
{
_LuceneIndex.Optimize();
}

public override void Clear()
Expand Down

0 comments on commit 34766d7

Please sign in to comment.