You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/04/18 10:31:11 UTC
svn commit: r1469224 - in
/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing:
Main.java core/Indexer.java core/impl/IndexerImpl.java
Author: rwesten
Date: Thu Apr 18 08:31:10 2013
New Revision: 1469224
URL: http://svn.apache.org/r1469224
Log:
STANBOL-1047: The Entityhub Indexing Tool now support the postprocess, finalise commands in addition to init and index
Modified:
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/Main.java
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/Indexer.java
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/Main.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/Main.java?rev=1469224&r1=1469223&r2=1469224&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/Main.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/Main.java Thu Apr 18 08:31:10 2013
@@ -59,7 +59,9 @@ public class Main {
path = args[1];
}
if("init".equalsIgnoreCase(args[0]) ||
- "index".equalsIgnoreCase(args[0])){
+ "index".equalsIgnoreCase(args[0]) ||
+ "postprocess".equalsIgnoreCase(args[0]) ||
+ "finalise".equalsIgnoreCase(args[0])){
if(path != null){
indexer = factory.create(path);
} else {
@@ -71,6 +73,16 @@ public class Main {
}
if("index".equalsIgnoreCase(args[0])){
indexer.index();
+ } else if("postprocess".equalsIgnoreCase(args[0])){
+ indexer.initialiseIndexing();
+ indexer.skipIndexEntities();
+ indexer.postProcessEntities();
+ indexer.finaliseIndexing();
+ } else if ("finalise".equalsIgnoreCase(args[0])){
+ indexer.initialiseIndexing();
+ indexer.skipIndexEntities();
+ indexer.skipPostProcessEntities();
+ indexer.finaliseIndexing();
}
} else {
System.err.println("Unknown command "+args[0]+" (supported: init,index)\n\n");
@@ -87,10 +99,13 @@ public class Main {
"java -Xmx{size} -jar org.apache.stanbol.indexing.core-*" +
"-jar-with-dependencies.jar [options] init|index [configDir]",
"Indexing Commandline Utility: \n"+
- " size: Heap requirements depend on the dataset and the configuration.\n"+
- " 1024m should be a reasonable default.\n" +
- " init: Initialise the configuration with the defaults \n" +
- " index: Needed to start the indexing process\n" +
+ " size: Heap requirements depend on the dataset and the\n"+
+ " configuration. 1024m should be a reasonable default.\n" +
+ " init: Initialise the configuration with the defaults \n" +
+ " index: Needed to start the indexing process\n" +
+ " postprocess: Skip indexing and directly start with post-processing\n" +
+ " finalise: Skip indexing and post-processing; only finalises \n" +
+ " the index. \n"+
" configDir: the path to the configuration directory (default:" +
" user.dir)",
options,
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/Indexer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/Indexer.java?rev=1469224&r1=1469223&r2=1469224&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/Indexer.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/Indexer.java Thu Apr 18 08:31:10 2013
@@ -186,4 +186,19 @@ public interface Indexer {
*/
public abstract State getState();
+ /**
+ * Tells the indexer that the {@link #indexEntities()} step should be skipped.
+ * Will set the {@link #getState()} to {@link State#INDEXED} without indexing
+ * any Entities. Otherwise this has the same pre-requirements as calling
+ * {@link #indexEntities()}
+ */
+ public void skipIndexEntities();
+ /**
+ * Tells the Indexer to skip the {@link #postProcessEntities()} step. Will set
+ * the {@link #getState()} to {@link State#POSTPROCESSED} without performing
+ * any post processing.Otherwise this has the same pre-requirements as calling
+ * {@link #postProcessEntities()}
+ */
+ void skipPostProcessEntities();
+
}
\ No newline at end of file
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java?rev=1469224&r1=1469223&r2=1469224&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/impl/IndexerImpl.java Thu Apr 18 08:31:10 2013
@@ -370,6 +370,24 @@ public class IndexerImpl implements Inde
log.info(" ...finalisation completed");
}
@Override
+ public void skipPostProcessEntities() {
+ synchronized (stateSync) { //ensure that two threads do not start the
+ //initialisation at the same time ...
+ State state = getState();
+ if(state.ordinal() < State.INDEXED.ordinal()){
+ throw new IllegalStateException("The Indexer MUST BE already "+State.INDEXED+" when calling this Method!");
+ }
+ if(state == State.POSTPROCESSING){ //if state > INITIALISED
+ throw new IllegalStateException("Unable to skip post processing if postprocessing is already in progress!");
+ }
+ if(state.ordinal() >= state.POSTPROCESSED.ordinal()){
+ return; //already post processed
+ }
+ setState(State.POSTPROCESSED);
+ log.info("Skiped postprocessing ...");
+ }
+ }
+ @Override
public void postProcessEntities() {
synchronized (stateSync) { //ensure that two threads do not start the
//initialisation at the same time ...
@@ -381,7 +399,7 @@ public class IndexerImpl implements Inde
return; // ignore this call
}
setState(State.POSTPROCESSING);
- log.info("Indexing started ...");
+ log.info("PostProcessing started ...");
}
if(entityPostProcessors == null || entityPostProcessors.isEmpty()){
setState(State.POSTPROCESSED);
@@ -528,12 +546,30 @@ public class IndexerImpl implements Inde
return; // ignore this call
}
setState(State.FINALISING);
- log.info("Indexing started ...");
+ log.info("finalisation started ...");
}
indexingDestination.finalise();
setState(State.FINISHED);
}
@Override
+ public void skipIndexEntities() {
+ synchronized (stateSync) { //ensure that two threads do not start the
+ //initialisation at the same time ...
+ State state = getState();
+ if(state.ordinal() < State.INITIALISED.ordinal()){
+ throw new IllegalStateException("The Indexer MUST BE already "+State.INITIALISED+" when calling this Method!");
+ }
+ if(state == State.INDEXING){
+ throw new IllegalStateException("Unable to skip indexing if indexing is already in progress!");
+ }
+ if(state.ordinal() >= state.INDEXED.ordinal()){ //if state > INDEXING
+ return; //already in INDEXED state
+ }
+ setState(State.INDEXED);
+ log.info("Indexing of Entities skipped ...");
+ }
+ }
+ @Override
public void indexEntities() {
synchronized (stateSync) { //ensure that two threads do not start the
//initialisation at the same time ...