Package java.nio

Examples of java.nio.MappedByteBuffer.position()


        if (entry == null) {
            return results;
        }
        buf = entry.getValue().getBuffer(false);
        buf.position((int) (start - entry.getKey()));

        MsgIterator it = new MsgIterator(buf, conf.allow_empty_message);

        while (it.hasNext()) {
            msg = it.next();
View Full Code Here


        if (entry == null) {
            return count;
        }
        buf = entry.getValue().getBuffer(false);
        buf.position((int) (start - entry.getKey()));

        MsgIterator it = new MsgIterator(buf, conf.allow_empty_message);

        while (it.hasNext()) {
            msg = it.next();
View Full Code Here

                MsgIterator it = new MsgIterator(buf, allowEmpty);
                while (it.hasNext()) {
                    Msg msg = it.next();
                    if (msg == null)
                        break;
                    pos = buf.position();
                }

                if (pos < ch.size()) {
                    ch.truncate(pos);
                    flushed_size = size = pos;
View Full Code Here

                    }
                });
                FileChannel fc = raf.getChannel();
                fileSize = (int)fc.size();
                mapBuf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fileSize);
                mapBuf.position(0);
                bufferRef = new WeakReference(mapBuf);
                fc.close();
            } catch (NullPointerException e) {
                throw new FontFormatException(e.toString());
            } catch (ClosedChannelException e) {
View Full Code Here

            if (mapN > mappedBuffers.length) // we have run out of data to read from
                break;
            MappedByteBuffer currentBuffer = mappedBuffers[mapN];
            if (offN > currentBuffer.limit())
                break;
            currentBuffer.position(offN);
            int bytesFromThisBuffer = Math.min(len, currentBuffer.remaining());
            currentBuffer.get(bytes, off, bytesFromThisBuffer);
            off += bytesFromThisBuffer;
            pos += bytesFromThisBuffer;
            totalRead += bytesFromThisBuffer;
View Full Code Here

        MappedByteBuffer rw = prepare(size);

        rw.put(createTarHeader(segmentId.toString(), size));
        rw.putLong(SEGMENT_MAGIC);
        int position = rw.position();

        rw.putInt(length);
        rw.putInt(referencedSegmentIds.size());
        rw.putLong(segmentId.getMostSignificantBits());
        rw.putLong(segmentId.getLeastSignificantBits());
View Full Code Here

        ro.limit(ro.position() + length);
        ro = ro.slice();

        rw.put(data, offset, length);

        int n = rw.position() % SEGMENT_SIZE;
        if (n > 0) {
            rw.put(PADDING_BYTES, 0, SEGMENT_SIZE - n);
        }

        SegmentReference previous = references.put(
View Full Code Here

            rw.putLong(head.getSegmentId().getMostSignificantBits());
            rw.putLong(head.getSegmentId().getLeastSignificantBits());
            rw.putInt(head.getOffset());
        }

        int n = rw.position() % SEGMENT_SIZE;
        if (n > 0) {
            rw.put(PADDING_BYTES, 0, SEGMENT_SIZE - n);
        }
    }
View Full Code Here

          blocks[block] = geoBlock;
          break;
        case BLOCKTYPE_COMPLEX:
          geoBlock = new byte[128 + 1];
          geoBlock[0] = type;
          geo.position(index);
          geo.get(geoBlock, 1, 128);
          index += 128;
          blocks[block] = geoBlock;
          break;
        case BLOCKTYPE_MULTILEVEL:
View Full Code Here

            }
          }
          int diff = index - orgIndex;
          geoBlock = new byte[diff + 1];
          geoBlock[0] = type;
          geo.position(orgIndex);
          geo.get(geoBlock, 1, diff);
          blocks[block] = geoBlock;
          break;
        default:
          throw new RuntimeException("Invalid geodata: " + rx + "_" + ry + "!");
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.