Class Indexer2

  • All Implemented Interfaces:

    public class Indexer2
    extends Object
    implements TagValueListener

    Listens to tag-value events and passes on indexing events to an IndexStore. This is an update to Indexer that understands that indexed properties may not be at the top level.

    This class is provided to allow the indexing of arbitrary record-based text files. Indexer objects are built for a single file and the indexes are written to a single index store. To keep all of the reader offsets in sync with one another, you will almost certainly wish to use the getReader() method to retrieve a CountedBufferedReader instance if you want to read the byte-offset between calls to Below is an example of how to index a file.

     File fileToIndex; // get this from somewhere
     // don't forget to register all the apropreate keys to the factory first.
     BioIndexStore indexStore = bioIndxStrFact.createBioStore();
     Indexer indexer = new Indexer(fileToIndex, indexStore);
     indexer.setPrimaryKeyName("foo", new String[] { "foo" });
     indexer.addSecondaryKey("bar", new String[] { "x", "y", "bar"});
     indexer.addSecondaryKey("baz", new String[] { "z" });
     TagValueParser tvParser; // make this appropriate for your format
     TagValueListener listener; // make this appropriate for your format
                                // and forward all events to indexer
     Parser parser = new Parser();
     while(, tvParser, listener)
     ) {
    Matthew Pocock