Package org.apache.lucene.store

Examples of org.apache.lucene.store.RAMDirectory.createOutput()


  public void test1() throws IOException {
    RAMDirectory directory = new RAMDirectory();

    String name = "test";

    IndexOutput output = directory.createOutput(name, IOContext.DEFAULT);
    byte[] bs = "hello world".getBytes();
    output.writeBytes(bs, bs.length);
    output.close();

    IndexInput input = directory.openInput(name, IOContext.DEFAULT);
View Full Code Here


    Random random = new Random(seed);

    String name = "test2";
    long size = (10 * 1024 * 1024) + 13;

    IndexOutput output = directory.createOutput(name, IOContext.DEFAULT);
    writeRandomData(size, random, output);
    output.close();

    IndexInput input = directory.openInput(name, IOContext.DEFAULT);
    IndexInput testInput = new CacheIndexInput(null, name, input.clone(), cache);
View Full Code Here

      list.add(value);
      ref.copy(value);
      pool.copy(ref);
    }
    RAMDirectory dir = new RAMDirectory();
    IndexOutput stream = dir.createOutput("foo.txt");
    pool.writePool(stream);
    stream.flush();
    stream.close();
    IndexInput input = dir.openInput("foo.txt");
    assertEquals(pool.byteOffset + pool.byteUpto, stream.length());
View Full Code Here

        String fileNameIn = SegmentInfos.getCurrentSegmentFileName(dir);
        String fileNameOut = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
                                                                   "",
                                                                   1+gen);
        IndexInput in = dir.openInput(fileNameIn);
        IndexOutput out = dir.createOutput(fileNameOut);
        long length = in.length();
        for(int i=0;i<length-1;i++) {
          out.writeByte(in.readByte());
        }
        in.close();
View Full Code Here

        String fileNameIn = SegmentInfos.getCurrentSegmentFileName(dir);
        String fileNameOut = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
                                                                   "",
                                                                   1+gen);
        IndexInput in = dir.openInput(fileNameIn);
        IndexOutput out = dir.createOutput(fileNameOut);
        long length = in.length();
        for(int i=0;i<length-1;i++) {
          out.writeByte(in.readByte());
        }
        in.close();
View Full Code Here

      for (PackedInts.Mutable mutable : packedInts) {
        for (int i = 0; i < mutable.size(); ++i) {
          mutable.set(i, random().nextInt(maxValue));
        }

        IndexOutput out = directory.createOutput("packed-ints.bin", IOContext.DEFAULT);
        mutable.save(out);
        out.close();

        IndexInput in = directory.openInput("packed-ints.bin", IOContext.DEFAULT);
        PackedInts.Reader reader = PackedInts.getReader(in);
View Full Code Here

        String fileNameIn = SegmentInfos.getCurrentSegmentFileName(dir);
        String fileNameOut = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
                                                                   "",
                                                                   1+gen);
        IndexInput in = dir.openInput(fileNameIn);
        IndexOutput out = dir.createOutput(fileNameOut);
        long length = in.length();
        for(int i=0;i<length-1;i++) {
          out.writeByte(in.readByte());
        }
        in.close();
View Full Code Here

        String fileNameIn = SegmentInfos.getCurrentSegmentFileName(dir);
        String fileNameOut = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
                                                                   "",
                                                                   1+gen);
        IndexInput in = dir.openInput(fileNameIn);
        IndexOutput out = dir.createOutput(fileNameOut);
        long length = in.length();
        for(int i=0;i<length-1;i++) {
          out.writeByte(in.readByte());
        }
        in.close();
View Full Code Here

    private void checkStream(int size, int buffer) throws IOException {
        Random rand = new Random();
        byte[] data = new byte[size];
        rand.nextBytes(data);
        Directory dir = new RAMDirectory();
        OutputStream out = new IndexOutputStream(dir.createOutput("test"));
        if (buffer != 0) {
            out = new BufferedOutputStream(out, buffer);
        }
        out.write(data);
        out.close();
View Full Code Here

    private void checkStream(int size, int buffer) throws IOException {
        Random rand = new Random();
        byte[] data = new byte[size];
        rand.nextBytes(data);
        Directory dir = new RAMDirectory();
        IndexOutput out = dir.createOutput("test");
        out.writeBytes(data, data.length);
        out.close();
        InputStream in = new IndexInputStream(dir.openInput("test"));
        if (buffer != 0) {
            in = new BufferedInputStream(in, buffer);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.