Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.nioBuffer()


        final int messageSize = byteBuf.readableBytes();

        final long writtenBytes;
        if (byteBuf.nioBufferCount() == 1) {
            writtenBytes = javaChannel().write(byteBuf.nioBuffer());
        } else {
            writtenBytes = javaChannel().write(byteBuf.nioBuffers());
        }

        // did not write the message
View Full Code Here


                needsCopy = true;
            }
        }
        ByteBuffer nioData;
        if (!needsCopy) {
            nioData = data.nioBuffer();
        } else {
            data = alloc.directBuffer(dataLen).writeBytes(data);
            nioData = data.nioBuffer();
        }
        final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier());
View Full Code Here

        ByteBuffer nioData;
        if (!needsCopy) {
            nioData = data.nioBuffer();
        } else {
            data = alloc.directBuffer(dataLen).writeBytes(data);
            nioData = data.nioBuffer();
        }
        final MessageInfo mi = MessageInfo.createOutgoing(association(), null, packet.streamIdentifier());
        mi.payloadProtocolID(packet.protocolIdentifier());
        mi.streamNumber(packet.streamIdentifier());
View Full Code Here

                }
                ByteBuf buffer = allocHandle.allocate(config().getAllocator());
                boolean free = true;

                try {
                    ByteBuffer data = buffer.nioBuffer(buffer.writerIndex(), buffer.writableBytes());
                    MessageInfo messageInfo = ch.receive(data, null, notificationHandler);
                    if (messageInfo == null) {
                        return readMessages;
                    }
View Full Code Here

                ByteBuf data = packet.content();
                int dataLen = data.readableBytes();
                ByteBuffer nioData;

                if (data.nioBufferCount() != -1) {
                    nioData = data.nioBuffer();
                } else {
                    nioData = ByteBuffer.allocate(dataLen);
                    data.getBytes(data.readerIndex(), nioData);
                    nioData.flip();
                }
View Full Code Here

              break;
            case DATA_PAGE:
              valueReadSoFar += pageHeader.data_page_header.getNum_values();
              ByteBuf buf = allocator.buffer(pageHeader.compressed_page_size);
              lastPage = buf;
              ByteBuffer buffer = buf.nioBuffer(0, pageHeader.compressed_page_size);
              CompatibilityUtil.getBuf(in, buffer, pageHeader.compressed_page_size);
              return new Page(
                      decompressor.decompress(BytesInput.from(buffer, 0, pageHeader.compressed_page_size), pageHeader.getUncompressed_page_size()),
                      pageHeader.data_page_header.num_values,
                      pageHeader.uncompressed_page_size,
View Full Code Here


  @Override
  public ByteBuffer allocate(int sz) {
    ByteBuf bb = oContext.getAllocator().buffer(sz);
    ByteBuffer b = bb.nioBuffer(0, sz);
    allocatedBuffers.put(System.identityHashCode(b), bb);
    logger.debug("ParquetDirectByteBufferAllocator: Allocated "+sz+" bytes. Allocated ByteBuffer id: "+System.identityHashCode(b));
    return b;
  }
View Full Code Here

        final int oldPos = packet.position();
        if (wantsInboundHeapBuffer && packet.isDirect()) {
            newPacket = ctx.alloc().heapBuffer(packet.limit() - oldPos);
            newPacket.writeBytes(packet);
            oldPacket = packet;
            packet = newPacket.nioBuffer();
        } else {
            oldPacket = null;
            newPacket = null;
        }
View Full Code Here

    ByteBuf buf = buffer.getByteBuf();
    if (buf.nioBufferCount() > 1) {
      Iterator<ByteBuffer> buffers = Arrays.asList(buf.nioBuffers()).iterator();
      doWrite(buffers, position, handler);
    } else {
      ByteBuffer bb = buf.nioBuffer();
      doWrite(bb, position, bb.limit(),  handler);
    }
    return this;
  }
View Full Code Here

    ByteBuf buf = buffer.getByteBuf();
    if (buf.nioBufferCount() > 1) {
      Iterator<ByteBuffer> buffers = Arrays.asList(buf.nioBuffers()).iterator();
      doWrite(buffers, writePos, handler);
    } else {
      ByteBuffer bb = buf.nioBuffer();
      doWrite(bb, writePos, bb.limit(), handler);
    }
    writePos += length;
    return this;
  }
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.