org.neo4j.index.lucene
Class LuceneDataSource

java.lang.Object
  extended by org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
      extended by org.neo4j.index.lucene.LuceneDataSource
Direct Known Subclasses:
LuceneFulltextDataSource

public class LuceneDataSource
extends org.neo4j.kernel.impl.transaction.xaframework.XaDataSource

An XaDataSource optimized for the LuceneIndexService. This class is public because the XA framework requires it.


Field Summary
static org.apache.lucene.analysis.Analyzer LOWER_CASE_WHITESPACE_ANALYZER
          Default Analyzer for fulltext parsing.
 
Constructor Summary
LuceneDataSource(Map<Object,Object> params)
          Constructs this data source.
 
Method Summary
 void applyLog(ReadableByteChannel byteChannel)
          Attempts to apply a logical log to this data source.
 void close()
          Closes this data source.
protected  void deleteDocumentsUsingWriter(org.apache.lucene.index.IndexWriter writer, long nodeId, Object value)
           
 boolean deleteLogicalLog(long version)
          Deletes a log specific logical log.
protected  void fillDocument(org.apache.lucene.document.Document document, long nodeId, String key, Object value)
           
protected  org.apache.lucene.analysis.Analyzer getAnalyzer()
           
 long getCreationTime()
          Returns a timestamp when this data source was created.
 long getCurrentLogVersion()
          Returns the current version of this data source.
protected  String getDeleteDocumentsKey()
           
 LuceneIndexService getIndexService()
           
protected  org.apache.lucene.document.Field.Index getIndexStrategy(String key, Object value)
           
 ReadableByteChannel getLogicalLog(long version)
          Returns a readable byte channel of the specified logical log.
 long getRandomIdentifier()
          Returns a random identifier that gets generated when the data source is created.
 org.neo4j.kernel.impl.transaction.xaframework.XaConnection getXaConnection()
          Creates a XA connection to the resource this data source represents.
 boolean hasLogicalLog(long version)
          Tests if a specific logical log exists.
 void keepLogicalLogs(boolean keep)
          Sets wether logical logs should be saved upon rotation or not.
 void makeBackupSlave()
          Makes this data source a backup slave.
 void rotateLogicalLog()
          Rotates this logical log.
 void setAutoRotate(boolean rotate)
          Turns off/on auto rotate of logical logs.
protected  void setIndexService(LuceneIndexService indexService)
          This is here so that LuceneIndexService.formQuery(String, Object) can be used when getting stuff from inside a transaction.
 void setLogicalLogTargetSize(long size)
          Sets the target size of the logical log that will cause a rotation of the log if XaDataSource.setAutoRotate(boolean) is set to true.
 
Methods inherited from class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
getBranchId, getName, setBranchId, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOWER_CASE_WHITESPACE_ANALYZER

public static final org.apache.lucene.analysis.Analyzer LOWER_CASE_WHITESPACE_ANALYZER
Default Analyzer for fulltext parsing.

Constructor Detail

LuceneDataSource

public LuceneDataSource(Map<Object,Object> params)
                 throws InstantiationException
Constructs this data source.

Parameters:
params - XA parameters.
Throws:
InstantiationException - if the data source couldn't be instantiated
Method Detail

setIndexService

protected void setIndexService(LuceneIndexService indexService)
This is here so that LuceneIndexService.formQuery(String, Object) can be used when getting stuff from inside a transaction.

Parameters:
indexService - the LuceneIndexService instance which created it.

getIndexService

public LuceneIndexService getIndexService()

close

public void close()
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Closes this data source. Calling getXaConnection after this method has been invoked is illegal.

Specified by:
close in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource

getXaConnection

public org.neo4j.kernel.impl.transaction.xaframework.XaConnection getXaConnection()
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Creates a XA connection to the resource this data source represents.

Specified by:
getXaConnection in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns:
A connection to an XA resource

getAnalyzer

protected org.apache.lucene.analysis.Analyzer getAnalyzer()

deleteDocumentsUsingWriter

protected void deleteDocumentsUsingWriter(org.apache.lucene.index.IndexWriter writer,
                                          long nodeId,
                                          Object value)

getDeleteDocumentsKey

protected String getDeleteDocumentsKey()

fillDocument

protected void fillDocument(org.apache.lucene.document.Document document,
                            long nodeId,
                            String key,
                            Object value)

getIndexStrategy

protected org.apache.lucene.document.Field.Index getIndexStrategy(String key,
                                                                  Object value)

keepLogicalLogs

public void keepLogicalLogs(boolean keep)
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Sets wether logical logs should be saved upon rotation or not. Default is false.

Overrides:
keepLogicalLogs in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
keep - true means save, false means delete

getCreationTime

public long getCreationTime()
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns a timestamp when this data source was created. Note this is not the timestamp for the creation of the data source object instance, if the data source is for example a database timestamp is meant to be when the database was created.

Creation time together with random identifier can be used to uniqley identify a data source (since it is possible to have multiple sources of same type).

Overrides:
getCreationTime in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns:
timestamp when this datasource was created

getRandomIdentifier

public long getRandomIdentifier()
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns a random identifier that gets generated when the data source is created. Note with "created" we mean first time data source is created and not object creatoin.

Creation time together with random identifier can be used to uniqley identify a data source (since it is possible to have multiple sources of same type).

Overrides:
getRandomIdentifier in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns:
random identifier for this data source

getCurrentLogVersion

public long getCurrentLogVersion()
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns the current version of this data source. A invoke to the XaDataSource.rotateLogicalLog() when XaDataSource.keepLogicalLogs(boolean) is set to true will result in a log with that version created.

Overrides:
getCurrentLogVersion in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns:
the current version of the logical log

applyLog

public void applyLog(ReadableByteChannel byteChannel)
              throws IOException
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Attempts to apply a logical log to this data source.

Overrides:
applyLog in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
byteChannel - readable channel containing the logical log data
Throws:
IOException - if a problem with reading the log occurs

rotateLogicalLog

public void rotateLogicalLog()
                      throws IOException
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Rotates this logical log. If XaDataSource.keepLogicalLogs(boolean) is configured to true the log will be saved and can be retrieved with the XaDataSource.getLogicalLog(long) method. If not it will be deleted. Active transactions get copied to a new logical log.

Overrides:
rotateLogicalLog in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Throws:
IOException - if unable to read old log or write to new one

getLogicalLog

public ReadableByteChannel getLogicalLog(long version)
                                  throws IOException
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Returns a readable byte channel of the specified logical log.

Overrides:
getLogicalLog in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
version - version of the logical log
Returns:
readable byte channel of the logical log
Throws:
IOException - if no such log exist

hasLogicalLog

public boolean hasLogicalLog(long version)
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Tests if a specific logical log exists.

Overrides:
hasLogicalLog in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
version - the version of the logical log
Returns:
true if the log exists

deleteLogicalLog

public boolean deleteLogicalLog(long version)
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Deletes a log specific logical log.

Overrides:
deleteLogicalLog in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
version - version of log to delete
Returns:
true if the log existed and was deleted

setAutoRotate

public void setAutoRotate(boolean rotate)
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Turns off/on auto rotate of logical logs. Default is true.

Overrides:
setAutoRotate in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
rotate - true to turn on

setLogicalLogTargetSize

public void setLogicalLogTargetSize(long size)
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Sets the target size of the logical log that will cause a rotation of the log if XaDataSource.setAutoRotate(boolean) is set to true.

Overrides:
setLogicalLogTargetSize in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Parameters:
size - target size in bytes

makeBackupSlave

public void makeBackupSlave()
Description copied from class: org.neo4j.kernel.impl.transaction.xaframework.XaDataSource
Makes this data source a backup slave. This method can not be called while there are active transactions. Once set in "backup slave" mode no new transactions can start, the resource has to be closed and reopened for that.

Overrides:
makeBackupSlave in class org.neo4j.kernel.impl.transaction.xaframework.XaDataSource


Copyright © 2010 Neo4j. All Rights Reserved.