Package org.apache.lucene.store

Examples of org.apache.lucene.store.InputStream


    if (norm.bytes != null) {                     // can copy from cache
      System.arraycopy(norm.bytes, 0, bytes, offset, maxDoc());
      return;
    }

    InputStream normStream = (InputStream) norm.in.clone();
    try {                                         // read from disk
      normStream.seek(0);
      normStream.readBytes(bytes, offset, maxDoc());
    } finally {
      normStream.close();
    }
  }
View Full Code Here


   * @throws IOException
   *
   * @see #read
   */
  FieldInfos(Directory d, String name) throws IOException {
    InputStream input = d.openFile(name);
    try {
      read(input);
    } finally {
      input.close();
    }
  }
View Full Code Here

  FieldInfos() {
    add("", false);
  }

  FieldInfos(Directory d, String name) throws IOException {
    InputStream input = d.openFile(name);
    try {
      read(input);
    } finally {
      input.close();
    }
  }
View Full Code Here

  OutputStream output = directory.createFile(segment + ".f" + i);
  try {
    for (int j = 0; j < readers.size(); j++) {
      SegmentReader reader = (SegmentReader)readers.elementAt(j);
      BitVector deletedDocs = reader.deletedDocs;
      InputStream input = reader.normStream(fi.name);
            int maxDoc = reader.maxDoc();
      try {
        for (int k = 0; k < maxDoc; k++) {
    byte norm = input != null ? input.readByte() : (byte)0;
    if (deletedDocs == null || !deletedDocs.get(k))
      output.writeByte(norm);
        }
      } finally {
        if (input != null)
    input.close();
      }
    }
  } finally {
    output.close();
  }
View Full Code Here

  public final SegmentInfo info(int i) {
    return (SegmentInfo)elementAt(i);
  }

  public final void read(Directory directory) throws IOException {
    InputStream input = directory.openFile("segments");
    try {
      counter = input.readInt();      // read counter
      for (int i = input.readInt(); i > 0; i--) { // read segmentInfos
  SegmentInfo si = new SegmentInfo(input.readString(), input.readInt(),
           directory);
  addElement(si);
      }
    } finally {
      input.close();
    }
  }
View Full Code Here

  /** Constructs a bit vector from the file <code>name</code> in Directory
    <code>d</code>, as written by the {@link #write} method.
    */
  public BitVector(Directory d, String name) throws IOException {
    InputStream input = d.openFile(name);
    try {
      size = input.readInt();        // read size
      count = input.readInt();        // read count
      bits = new byte[(size >> 3) + 1];      // allocate bits
      input.readBytes(bits, 0, bits.length);    // read bits
    } finally {
      input.close();
    }
  }
View Full Code Here

    }
    return norm.bytes;
  }

  final void norms(String field, byte[] bytes, int offset) throws IOException {
    InputStream normStream = normStream(field);
    if (normStream == null)
      return;            // use zeros in array
    try {
      normStream.readBytes(bytes, offset, maxDoc());
    } finally {
      normStream.close();
    }
  }
View Full Code Here

  final InputStream normStream(String field) throws IOException {
    Norm norm = (Norm)norms.get(field);
    if (norm == null)
      return null;
    InputStream result = (InputStream)norm.in.clone();
    result.seek(0);
    return result;
  }
View Full Code Here

  private final Vector readDeleteableFiles() throws IOException {
    Vector result = new Vector();
    if (!directory.fileExists("deletable"))
      return result;

    InputStream input = directory.openFile("deletable");
    try {
      for (int i = input.readInt(); i > 0; i--)    // read file names
  result.addElement(input.readString());
    } finally {
      input.close();
    }
    return result;
  }
View Full Code Here

TOP

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

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.