Esempio n. 1
0
  private void initialize(SegmentInfo si) throws IOException {
    segment = si.name;

    // Use compound file directory for some files, if it exists
    Directory cfsDir = directory();
    if (directory().fileExists(segment + ".cfs")) {
      cfsReader = new CompoundFileReader(directory(), segment + ".cfs");
      cfsDir = cfsReader;
    }

    // No compound file exists - use the multi-file format
    fieldInfos = new FieldInfos(cfsDir, segment + ".fnm");
    fieldsReader = new FieldsReader(cfsDir, segment, fieldInfos);

    tis = new TermInfosReader(cfsDir, segment, fieldInfos);

    // NOTE: the bitvector is stored using the regular directory, not cfs
    if (hasDeletions(si)) deletedDocs = new BitVector(directory(), segment + ".del");

    // make sure that all index files have been read or are kept open
    // so that if an index update removes them we'll still have them
    freqStream = cfsDir.openFile(segment + ".frq");
    proxStream = cfsDir.openFile(segment + ".prx");
    openNorms(cfsDir);

    if (fieldInfos.hasVectors()) { // open term vector files only as needed
      termVectorsReader = new TermVectorsReader(cfsDir, segment, fieldInfos);
    }
  }
Esempio n. 2
0
 private final void openNorms(Directory cfsDir) throws IOException {
   for (int i = 0; i < fieldInfos.size(); i++) {
     FieldInfo fi = fieldInfos.fieldInfo(i);
     if (fi.isIndexed) {
       String fileName = segment + ".f" + fi.number;
       // look first for re-written file, then in compound format
       Directory d = directory().fileExists(fileName) ? directory() : cfsDir;
       norms.put(fi.name, new Norm(d.openFile(fileName), fi.number));
     }
   }
 }