public abstract class AbstractCommitter extends Object implements ICommitter
Basic implementation invoking the ICommitter.commit()
method every time a given
queue size threshold has been reached. Both additions and deletions count
towards the same queue size.
It is left to implementors to decide how to actually queue the
documents and how to perform commits.
Consider extending AbstractFileQueueCommitter
if you do not wish
to implement your own queue.
Subclasses implementing IXMLConfigurable
should allow this inner
configuration:
<queueSize>(max queue size before committing)</queueSize>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_QUEUE_SIZE
Default queue size.
|
protected int |
queueSize |
Constructor and Description |
---|
AbstractCommitter()
Constructor.
|
AbstractCommitter(int queueSize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String reference,
InputStream content,
com.norconex.commons.lang.map.Properties metadata)
Adds a new or modified document to the target destination.
|
boolean |
equals(Object obj) |
protected abstract long |
getInitialQueueDocCount()
Gets the initial document count, in case there are already documents
in the queue the first time the committer is used.
|
int |
getQueueSize()
Gets the queue size.
|
int |
hashCode() |
protected abstract void |
queueAddition(String reference,
InputStream content,
com.norconex.commons.lang.map.Properties metadata)
Queues a document to be added.
|
protected abstract void |
queueRemoval(String reference,
com.norconex.commons.lang.map.Properties metadata)
Queues a document to be deleted.
|
void |
remove(String reference,
com.norconex.commons.lang.map.Properties metadata)
Removes a document from the target destination.
|
void |
setQueueSize(int queueSize)
Sets the queue size.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
commit
public static final int DEFAULT_QUEUE_SIZE
protected int queueSize
public AbstractCommitter()
public AbstractCommitter(int queueSize)
queueSize
- queue sizepublic int getQueueSize()
public void setQueueSize(int queueSize)
queueSize
- queue sizepublic final void add(String reference, InputStream content, com.norconex.commons.lang.map.Properties metadata)
ICommitter
add
in interface ICommitter
reference
- document reference (e.g. URL)content
- document contentmetadata
- document metadataprotected abstract void queueAddition(String reference, InputStream content, com.norconex.commons.lang.map.Properties metadata)
reference
- document referencecontent
- document contentmetadata
- document metadatapublic final void remove(String reference, com.norconex.commons.lang.map.Properties metadata)
ICommitter
remove
in interface ICommitter
reference
- document reference (e.g. URL)metadata
- document metadataprotected abstract long getInitialQueueDocCount()
protected abstract void queueRemoval(String reference, com.norconex.commons.lang.map.Properties metadata)
reference
- document referencemetadata
- document metadataCopyright © 2009–2020 Norconex Inc.. All rights reserved.