Skip to content

Instantly share code, notes, and snippets.

@emmanuelbernard
Last active December 14, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmanuelbernard/5084039 to your computer and use it in GitHub Desktop.
Save emmanuelbernard/5084039 to your computer and use it in GitHub Desktop.
private class Indexer {
public void consumes(Iterator<Tuple> entityTuples) {
while (Tuple tuple = entityTuples.next() != null) {
Entry entry = convertToEntry(tuple);
pushToExecutorQueue(entry);
}
//pushToExecutorQueue, execute method
public execute() {
DocumentBuilder db = sf.getDocumentBuilderForEntry( e );
org.apache.luceneDocument transformation = db.buildDocument(db);
//apply sharding logic:
IndexManager targetIndex = sf.getIndexManager( ... )
targetIndex.writeAsBatchWork( transformation );
}
}
private static class Indexer implements Consumer {
private final SearchFactory sf;
//ctors
//invoked concurrently on some GridDialect implementations:
public void consume(Entry e) {
DocumentBuilder db = sf.getDocumentBuilderForEntry( e );
org.apache.luceneDocument transformation = db.buildDocument(db);
//apply sharding logic:
IndexManager targetIndex = sf.getIndexManager( ... )
targetIndex.writeAsBatchWork( transformation );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment