org.openanzo.common.rdb.layout.indexer
Class LiteralIndexer

java.lang.Object
  extended by org.openanzo.indexer.lucene.LuceneIndexerBase
      extended by org.openanzo.common.rdb.layout.indexer.LiteralIndexer
All Implemented Interfaces:
IIndexer

public class LiteralIndexer
extends LuceneIndexerBase

Indexer for Anzo Literals based on Lucene.

Author:
Wing Yung ( wingyung@us.ibm.com )

Constructor Summary
LiteralIndexer()
          Create new LiteralIndexer
 
Method Summary
 void clear()
          Clears the contents of the index.
 void close()
          Closes the resources used by the indexer.
static org.apache.lucene.document.Document createDocument(long id, org.openrdf.model.Literal literal)
          Create a new document which indexes a Literal and its ID
 boolean index(int id, java.lang.Object obj)
          Adds the object to the index.
 void initialize(java.util.Properties properties)
          Initializes the indexer.
 java.util.List<java.lang.Long> query(java.lang.String queryStr)
          Search the indexer for literals that match the query pattern
 int rebuild(java.lang.Object seedObject)
          Rebuilds the index given the seed object.
 void remove(int id, java.lang.Object obj)
          Removes the object from the index.
 
Methods inherited from class org.openanzo.indexer.lucene.LuceneIndexerBase
initialize, postIndex, postRemove, preIndex, preRemove
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LiteralIndexer

public LiteralIndexer()
Create new LiteralIndexer

Method Detail

initialize

public void initialize(java.util.Properties properties)
                throws IndexerException
Description copied from class: LuceneIndexerBase
Initializes the indexer. The properties object should contain the location of the directory containing the index (org.openanzo.indexer.lucene.indexLocation) and whether or not the index should be cleared upon initialization (org.openanzo.indexer.indexClear). Note that there are additional Lucene properties that can be set via Java system properties. For example, org.apache.lucene.writeLockTimeout (in ms)

Specified by:
initialize in interface IIndexer
Overrides:
initialize in class LuceneIndexerBase
Parameters:
properties - configuration for the indexer, usually comes from a .properties file
Throws:
IndexerException - if there were errors initializing the indexer

query

public java.util.List<java.lang.Long> query(java.lang.String queryStr)
                                     throws IndexerException
Search the indexer for literals that match the query pattern

Parameters:
queryStr - query string to run
Returns:
list of literal IDs that match query
Throws:
IndexerException

clear

public void clear()
           throws IndexerException
Description copied from interface: IIndexer
Clears the contents of the index.

Specified by:
clear in interface IIndexer
Overrides:
clear in class LuceneIndexerBase
Throws:
IndexerException

close

public void close()
           throws IndexerException
Description copied from class: LuceneIndexerBase
Closes the resources used by the indexer. Closes the IndexModifier.

Specified by:
close in interface IIndexer
Overrides:
close in class LuceneIndexerBase
Throws:
IndexerException

index

public boolean index(int id,
                     java.lang.Object obj)
              throws IndexerException
Description copied from interface: IIndexer
Adds the object to the index.

Specified by:
index in interface IIndexer
Specified by:
index in class LuceneIndexerBase
Parameters:
id - id of the indexer, generated by preIndex()
obj - object to add to the index.
Returns:
true if indexing object was successfull
Throws:
IndexerException

remove

public void remove(int id,
                   java.lang.Object obj)
            throws IndexerException
Description copied from interface: IIndexer
Removes the object from the index.

Specified by:
remove in interface IIndexer
Specified by:
remove in class LuceneIndexerBase
Parameters:
id - id of the indexer, generated by preIndex()
obj - object to remove from the index.
Throws:
IndexerException

createDocument

public static org.apache.lucene.document.Document createDocument(long id,
                                                                 org.openrdf.model.Literal literal)
Create a new document which indexes a Literal and its ID

Parameters:
id - of literal
literal - literal value
Returns:
new Document

rebuild

public int rebuild(java.lang.Object seedObject)
            throws IndexerException
Description copied from interface: IIndexer
Rebuilds the index given the seed object.

Parameters:
seedObject - object used to rebuild the entire index
Returns:
id of the indexer
Throws:
IndexerException


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.