Package java.nio

Examples of java.nio.ByteBuffer.clear()


        hasMore = false;
        while (rs.next())
        {
          hasMore = true;
          buffer.clear();
          buffer.put(rs.getBytes("val"));
          curId = rs.getLong("id");
          event = event.reset(buffer, 0);
          GenericRecord record = _decoder.getGenericRecord(event);
          if (checkFilters(event, record))
View Full Code Here


            currentReadPosition += limit;
            readTasks.add(ListenableFutureTask.create(new Callable<ByteBuffer>() {
                @Override
                public ByteBuffer call() throws Exception {
                    final ByteBuffer buffer = availableBuffers.take();
                    buffer.clear();
                    buffer.limit(limit);
                    while (buffer.hasRemaining()) {
                        int read = channel.read(buffer, readStartingAt);
                        if (read == -1) {
                            throw new EOFException();
View Full Code Here

            final int allCRCExpected = allCRCBytes.getInt();
            final CRC32 allCRC = new CRC32();
            ByteBuffer entryBuffer = ByteBuffer.allocate(ENTRY_WITH_CHECKSUM_SIZE).order(ByteOrder.nativeOrder());

            while (true) {
                entryBuffer.clear();
                int read = 0;

                while (read < ENTRY_WITH_CHECKSUM_SIZE) {
                    final int readThisTime = pis.read(entryBuffer.array(), read, entryBuffer.capacity() - read);
                    if (readThisTime == -1) break;
View Full Code Here

                    pauseReset();
//                    System.out.println("Writing " + index);
                    final int size = excerpt.capacity();
                    int remaining;

                    bb.clear();
                    if (first) {
//                        System.out.println("wi " + index);
                        bb.putLong(index);
                        first = false;
                        remaining = size + TcpUtil.HEADER_SIZE;
View Full Code Here

                    while (!excerpt.index(index))
                        pause(delayNS);
                    int size = excerpt.capacity();
                    int remaining = size + TcpUtil.HEADER_SIZE;

                    bb.clear();
                    bb.putLong(index);
                    bb.putInt(size);
                    while (remaining > 0) {
                        int size2 = Math.min(remaining, bb.capacity());
                        bb.limit(size2);
View Full Code Here

                while (!closed) {
                    while (!excerpt.index(index)) {
//                        System.out.println("Waiting for " + index);
                        long now = System.currentTimeMillis();
                        if (sendInSync <= now && !first) {
                            bb.clear();
                            bb.putInt(IN_SYNC_LEN);
                            bb.flip();
                            IOTools.writeAll(socket, bb);
                            sendInSync = now + HEARTBEAT_INTERVAL_MS;
                        }
View Full Code Here

                        sc.socket().setTcpNoDelay(true);
                        while (sc.read(bb) >= 0) {
                            bb.flip();
//                            System.out.println("e "+bb.remaining());
                            IOTools.writeAllOrEOF(sc, bb);
                            bb.clear();
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    } finally {
                        sc.close();
View Full Code Here

                for (int i = 1; i <= WARMUP + RUNS; i++) {
                    long next = start + i * 1000000L / RATE;
                    do {
                        /* busy wait */
                    } while (System.nanoTime() < next);
                    time.clear();
                    // when it should have been sent, not when it was.
                    time.putInt(i);
                    time.putLong(next);
                    time.flip();
//                    System.out.println("w " + time.getInt(0) + " " + time.remaining());
View Full Code Here

            OutputStream out = response.getOutputStream();

            // read the bytes, returning them in the response
            while (in.read(buffer) != -1) {
                out.write(buffer.array(), 0, buffer.position());
                buffer.clear();
            }
            out.close();

        } catch (NotModifiedException e) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
View Full Code Here

            {
                if (buf.position() > 0)
                {
                    // flush encoded chars first...
                    sb.append(decode(buf, decoder));
                    buf.clear();
                }

                sb.append(ch);
            }
        }
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.