Package org.apache.lucene.store

Examples of org.apache.lucene.store.OutputStream


    }
    return result;
  }

  private final void writeDeleteableFiles(Vector files) throws IOException {
    OutputStream output = directory.createFile("deleteable.new");
    try {
      output.writeInt(files.size());
      for (int i = 0; i < files.size(); i++)
  output.writeString((String)files.elementAt(i));
    } finally {
      output.close();
    }
    directory.renameFile("deleteable.new", "deletable");
  }
View Full Code Here


    quickSort(postings, left + 1, hi);
  }

  private final void writePostings(Posting[] postings, String segment)
       throws IOException {
    OutputStream freq = null, prox = null;
    TermInfosWriter tis = null;

    try {
      freq = directory.createFile(segment + ".frq");
      prox = directory.createFile(segment + ".prx");
      tis = new TermInfosWriter(directory, segment, fieldInfos);
      TermInfo ti = new TermInfo();

      for (int i = 0; i < postings.length; i++) {
  Posting posting = postings[i];

  // add an entry to the dictionary with pointers to prox and freq files
  ti.set(1, freq.getFilePointer(), prox.getFilePointer());
  tis.add(posting.term, ti);
 
  // add an entry to the freq file
  int f = posting.freq;
  if (f == 1)          // optimize freq=1
    freq.writeVInt(1);        // set low bit of doc num.
  else {
    freq.writeVInt(0);        // the document number
    freq.writeVInt(f);        // frequency in doc
  }
 
  int lastPosition = 0;        // write positions
  int[] positions = posting.positions;
  for (int j = 0; j < f; j++) {      // use delta-encoding
    int position = positions[j];
    prox.writeVInt(position - lastPosition);
    lastPosition = position;
  }
      }
    }
    finally {
      if (freq != null) freq.close();
      if (prox != null) prox.close();
      if (tis  != nulltis.close();
    }
  }
View Full Code Here

    Enumeration fields  = doc.fields();
    while (fields.hasMoreElements()) {
      Field field = (Field)fields.nextElement();
      if (field.isIndexed()) {
  int fieldNumber = fieldInfos.fieldNumber(field.name());
  OutputStream norm = directory.createFile(segment + ".f" + fieldNumber);
  try {
    norm.writeByte(Similarity.norm(fieldLengths[fieldNumber]));
  } finally {
    norm.close();
  }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.store.OutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.