Example usage for org.apache.lucene.index ParallelCompositeReader ParallelCompositeReader

List of usage examples for org.apache.lucene.index ParallelCompositeReader ParallelCompositeReader

Introduction

In this page you can find the example usage for org.apache.lucene.index ParallelCompositeReader ParallelCompositeReader.

Prototype

public ParallelCompositeReader(CompositeReader... readers) throws IOException 

Source Link

Document

Create a ParallelCompositeReader based on the provided readers; auto-closes the given readers on #close() .

Usage

From source file:edu.utsa.sifter.IndexResource.java

License:Apache License

@Path("index")
@POST//from  w ww .ja v a 2  s  .co m
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public IndexInfo openIndex(IndexInfo idx) {
    if (idx.Id == null) {
        idx.Id = new String(Hex.encodeHex(Hasher.digest(idx.Path.getBytes())));
    }
    idx.Id = idx.Id.toLowerCase();

    IndexReader rdr = State.Indices.get(idx.Id);
    if (rdr == null) {
        try {
            final File evPath = new File(idx.Path);
            final File primaryIdx = new File(evPath, "primary-idx");
            final File somIdx = new File(evPath, "som-idx");
            DirectoryReader parallel[] = new DirectoryReader[2];
            parallel[0] = DirectoryReader.open(FSDirectory.open(primaryIdx));
            parallel[1] = DirectoryReader.open(FSDirectory.open(somIdx));

            rdr = new ParallelCompositeReader(parallel);
        } catch (IOException ex) {
            HttpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
        }
    }
    if (rdr != null) {
        idx.NumDocs = rdr.numDocs();

        State.Indices.put(idx.Id, rdr);
        State.IndexLocations.put(idx.Id, idx);
    }
    return idx;
}