public class Neo4jItemReader<T> extends AbstractPaginatedDataItemReader<T> implements org.springframework.beans.factory.InitializingBean
Restartable ItemReader
that reads objects from the graph database Neo4j
via a paging technique.
It executes cypher queries built from the statement fragments provided to
retrieve the requested data. The query is executed using paged requests of
a size specified in AbstractPaginatedDataItemReader.setPageSize(int)
. Additional pages are requested
as needed when the AbstractItemCountingItemStreamItemReader.read()
method is called. On restart, the reader
will begin again at the same number item it left off at.
Performance is dependent on your Neo4J configuration (embedded or remote) as well as page size. Setting a fairly large page size and using a commit interval that matches the page size should provide better performance.
This implementation is thread-safe between calls to
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
, however you
should set saveState=false
if used in a multi-threaded
environment (no restart available).
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
page, pageSize, results
Constructor and Description |
---|
Neo4jItemReader() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Checks mandatory properties
|
protected Iterator<T> |
doPageRead()
Method this
ItemStreamReader delegates to
for the actual work of reading a page. |
void |
setMatchStatement(String matchStatement)
An optional match fragment of the cypher query.
|
void |
setOrderByStatement(String orderByStatement)
A list of properties to order the results by.
|
void |
setResultConverter(org.springframework.data.neo4j.conversion.ResultConverter resultConverter)
Set the converter used to convert node to the targetType.
|
void |
setReturnStatement(String returnStatement)
The return statement of the cypher query.
|
void |
setStartStatement(String startStatement)
The start segment of the cypher query.
|
void |
setTargetType(Class targetType)
The object type to be returned from each call to
AbstractItemCountingItemStreamItemReader.read() |
void |
setTemplate(org.springframework.data.neo4j.template.Neo4jOperations template)
Used to perform operations against the Neo4J database.
|
void |
setWhereStatement(String whereStatement)
An optional where fragement of the cypher query.
|
doClose, doOpen, doRead, jumpToItem, setPageSize
close, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
getExecutionContextKey, setExecutionContextName, setName
public void setStartStatement(String startStatement)
startStatement
- the start fragment of the cypher query.public void setReturnStatement(String returnStatement)
returnStatement
- the return fragment of the cypher query.public void setMatchStatement(String matchStatement)
matchStatement
- the match fragment of the cypher querypublic void setWhereStatement(String whereStatement)
whereStatement
- where fragment of the cypher querypublic void setOrderByStatement(String orderByStatement)
orderByStatement
- order by fragment of the cypher query.public void setTemplate(org.springframework.data.neo4j.template.Neo4jOperations template)
template
- the Neo4jOperations instance to useNeo4jOperations
public void setTargetType(Class targetType)
AbstractItemCountingItemStreamItemReader.read()
targetType
- the type of object to return.public void setResultConverter(org.springframework.data.neo4j.conversion.ResultConverter resultConverter)
DefaultConverter
is used.resultConverter
- the converter to use.protected Iterator<T> doPageRead()
AbstractPaginatedDataItemReader
ItemStreamReader
delegates to
for the actual work of reading a page. Each time
this method is called, the resulting Iterator
should contain the items read within the next page.
Iterator
is empty or null when it is
returned, this ItemReader
will assume that the
input has been exhausted.doPageRead
in class AbstractPaginatedDataItemReader<T>
Iterator
containing the items within a page.Copyright © 2014 Pivotal. All rights reserved.