Examples of unsafeBytes()


Examples of org.elasticsearch.common.xcontent.XContentBuilder.unsafeBytes()

                        // if its a builder based response, and it was created with a CachedStreamOutput, we can release it
                        // after we write the response, and no need to do an extra copy because its not thread safe
                        XContentBuilder builder = ((XContentRestResponse) response).builder();
                        if (builder.payload() instanceof CachedStreamOutput.Entry) {
                            releaseContentListener = new NettyTransport.CacheFutureListener((CachedStreamOutput.Entry) builder.payload());
                            ChannelBuffer buf = ChannelBuffers.wrappedBuffer(builder.unsafeBytes(), 0, builder.unsafeBytesLength());
                            writeBuffer = ChannelBuffers.wrappedBuffer(writeBuffer, buf);
                        } else if (response.contentThreadSafe()) {
                            ChannelBuffer buf = ChannelBuffers.wrappedBuffer(builder.unsafeBytes(), 0, builder.unsafeBytesLength());
                            writeBuffer = ChannelBuffers.wrappedBuffer(writeBuffer, buf);
                        } else {
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder.unsafeBytes()

                        if (builder.payload() instanceof CachedStreamOutput.Entry) {
                            releaseContentListener = new NettyTransport.CacheFutureListener((CachedStreamOutput.Entry) builder.payload());
                            ChannelBuffer buf = ChannelBuffers.wrappedBuffer(builder.unsafeBytes(), 0, builder.unsafeBytesLength());
                            writeBuffer = ChannelBuffers.wrappedBuffer(writeBuffer, buf);
                        } else if (response.contentThreadSafe()) {
                            ChannelBuffer buf = ChannelBuffers.wrappedBuffer(builder.unsafeBytes(), 0, builder.unsafeBytesLength());
                            writeBuffer = ChannelBuffers.wrappedBuffer(writeBuffer, buf);
                        } else {
                            writeBuffer.writeBytes(response.content(), 0, response.contentLength());
                        }
                    } else {
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder.unsafeBytes()

                // if its a builder based response, and it was created with a CachedStreamOutput, we can release it
                // after we write the response, and no need to do an extra copy because its not thread safe
                XContentBuilder builder = ((XContentRestResponse) response).builder();
                if (builder.payload() instanceof CachedStreamOutput.Entry) {
                    releaseContentListener = new NettyTransport.CacheFutureListener((CachedStreamOutput.Entry) builder.payload());
                    buf = ChannelBuffers.wrappedBuffer(builder.unsafeBytes(), 0, builder.unsafeBytesLength());
                } else if (response.contentThreadSafe()) {
                    buf = ChannelBuffers.wrappedBuffer(response.content(), 0, response.contentLength());
                } else {
                    buf = ChannelBuffers.copiedBuffer(response.content(), 0, response.contentLength());
                }
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

    @JRubyMethod(name = "get_string")
    public IRubyObject get_string(ThreadContext context, IRubyObject offArg) {
        long off = getOffset(offArg);
        int len = (int) getMemoryIO().indexOf(off, (byte) 0);
        ByteList bl = new ByteList(len);
        getMemoryIO().get(off, bl.unsafeBytes(), bl.begin(), len);
        bl.length(len);
        return context.getRuntime().newString(bl);
    }
    @JRubyMethod(name = "get_string")
    public IRubyObject get_string(ThreadContext context, IRubyObject offArg, IRubyObject lenArg) {
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

        int len = (int) getMemoryIO().indexOf(off, (byte) 0, maxlen);
        if (len < 0 || len > maxlen) {
            len = maxlen;
        }
        ByteList bl = new ByteList(len);
        getMemoryIO().get(off, bl.unsafeBytes(), bl.begin(), len);
        bl.length(len);
        return context.getRuntime().newString(bl);
    }
    @JRubyMethod(name = "put_string", required = 2, optional = 1)
    public IRubyObject put_string(ThreadContext context, IRubyObject[] args) {
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

        boolean nulTerminate = true;
        if (args.length > 2) {
            len = Math.min(Util.int32Value(args[2]) - 1, len);
            nulTerminate = false;
        }
        getMemoryIO().put(off, bl.unsafeBytes(), bl.begin(), len);
        if (nulTerminate) {
            getMemoryIO().putByte(off + bl.length(), (byte) 0);
        }
        return this;
    }
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

        }
        public void put(Ruby runtime, IRubyObject ptr, IRubyObject value) {
            MemoryIO io = getMemoryIO(ptr).getMemoryIO(offset);
            if (!io.isNull()) {
                ByteList bl = value.convertToString().getByteList();
                io.put(0, bl.unsafeBytes(), bl.begin(), bl.length());
                io.putByte(bl.length(), (byte) 0);
            }
        }

        public IRubyObject get(Ruby runtime, IRubyObject ptr) {
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

                return runtime.getNil();
            }
            int len = (int) io.indexOf(0, (byte) 0, Integer.MAX_VALUE);
            ByteList bl = new ByteList(len);
            bl.length(len);
            io.get(0, bl.unsafeBytes(), bl.begin(), len);
       
            return runtime.newString(bl);
        }
        static StructLayout.Member create(long offset) { return new StringMember(offset); }
    }
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

        public void put(Ruby runtime, IRubyObject ptr, IRubyObject value) {
            MemoryIO io = getMemoryIO(ptr);
            ByteList bl = value.convertToString().getByteList();
            // Clamp to no longer than
            int len = Math.min(bl.length(), size - 1);
            io.put(offset, bl.unsafeBytes(), bl.begin(), len);
            io.putByte(offset + len, (byte) 0);
        }

        public IRubyObject get(Ruby runtime, IRubyObject ptr) {
            MemoryIO io = getMemoryIO(ptr);
View Full Code Here

Examples of org.jruby.util.ByteList.unsafeBytes()

            if (len < 0) {
                len = size;
            }
            ByteList bl = new ByteList(len);
            bl.length(len);
            io.get(0, bl.unsafeBytes(), bl.begin(), len);
       
            return runtime.newString(bl);
        }
        static StructLayout.Member create(long offset, int size) {
            return new CharArrayMember(offset, size);
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.