Package org.elasticsearch.common.io.stream

Examples of org.elasticsearch.common.io.stream.ByteBufferStreamInput


        }
    }
      
    private void doTest(byte bytes[]) throws IOException {
        ByteBuffer bb = ByteBuffer.wrap(bytes);
        StreamInput rawIn = new ByteBufferStreamInput(bb);
        Compressor c = CompressorFactory.defaultCompressor();
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        OutputStreamStreamOutput rawOs = new OutputStreamStreamOutput(bos);
        StreamOutput os = c.streamOutput(rawOs);
       
        Random r = getRandom();
        int bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(getRandom(), 1, 70000);
        int prepadding = r.nextInt(70000);
        int postpadding = r.nextInt(70000);
        byte buffer[] = new byte[prepadding + bufferSize + postpadding];
        r.nextBytes(buffer); // fill block completely with junk
        int len;
        while ((len = rawIn.read(buffer, prepadding, bufferSize)) != -1) {
            os.write(buffer, prepadding, len);
        }
        os.close();
        rawIn.close();
       
        // now we have compressed byte array
       
        byte compressed[] = bos.toByteArray();
        ByteBuffer bb2 = ByteBuffer.wrap(compressed);
        StreamInput compressedIn = new ByteBufferStreamInput(bb2);
        StreamInput in = c.streamInput(compressedIn);
       
        // randomize constants again
        bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(getRandom(), 1, 70000);
        prepadding = r.nextInt(70000);
View Full Code Here


        return new ByteBufferBytesReference(dup);
    }

    @Override
    public StreamInput streamInput() {
        return new ByteBufferStreamInput(buffer);
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.io.stream.ByteBufferStreamInput

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.