Java 8 MappedByteBuffer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MappedByteBuffer class.

This code example shows how to use the following methods: putLong, force
 
    public void shutdown() { 
        this.flush();
 
        // unmap mappedByteBuffer 
        MapedFile.clean(this.mappedByteBuffer);
 
        try { 
            this.fileChannel.close();
        } 
        catch (IOException e) {
            e.printStackTrace();
        } 
    } 
 
 
    public void flush() { 
        this.mappedByteBuffer.putLong(0, this.physicMsgTimestamp);
        this.mappedByteBuffer.putLong(8, this.logicsMsgTimestamp);
        this.mappedByteBuffer.putLong(16, this.indexMsgTimestamp);

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: putLong, force
 
    public void shutdown() { 
        this.flush();
 
        // unmap mappedByteBuffer 
        MapedFile.clean(this.mappedByteBuffer);
 
        try { 
            this.fileChannel.close();
        } 
        catch (IOException e) {
            e.printStackTrace();
        } 
    } 
 
 
    public void flush() { 
        this.mappedByteBuffer.putLong(0, this.physicMsgTimestamp);
        this.mappedByteBuffer.putLong(8, this.logicsMsgTimestamp);
        this.mappedByteBuffer.putLong(16, this.indexMsgTimestamp);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: position, get
            throws IOException { 
        // ÒѾ­É¾³ý£¬²»ÓüÌÐø¶Á 
        if (this.deleted) {
            return; 
        } 
        mappedByteBuffer.position(offset);
        if (!loadItem) {
            final byte data = mappedByteBuffer.get();
            this.deleted = (data == (byte) 1 ? true : false);
        } 
        else { 
            final byte[] bytes = new byte[SIZE];
            mappedByteBuffer.get(bytes, 0, SIZE);
            this.deleted = (bytes[0] == (byte) 1 ? true : false);
            this.opItem = new OpItem();
            this.opItem.parse(bytes, 1, bytes.length - 1);
        } 
    } 
 
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: position, putLong, force
    { 
        try 
        { 
            if ( mappedBuffer != null )
            { 
                mappedStartPosition += mappedBuffer.position();
                mappedBuffer.force();
                mappedBuffer = null;
            } 
            if ( mapFail > 1000 )
            { 
                mapFail = -1;
            } 
            if ( mapFail > 0 )
            { 
                mapFail++;
                return; 
            } 
            mappedBuffer = fileChannel.map( MapMode.READ_WRITE,
                mappedStartPosition, MAPPED_SIZE );

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: position, remaining, duplicate
     * @return buffer with portion of file content 
     * @throws IOException on any fail of I/O operation 
     */ 
    public synchronized ByteBuffer readBytes(int length) throws IOException
    { 
        int remaining = buffer.remaining() - position;
        if (length > remaining)
            throw new IOException(String.format("mmap segment underflow; remaining is %d but %d requested",
                                                remaining, length));
 
        ByteBuffer bytes = buffer.duplicate();
        bytes.position(buffer.position() + position).limit(buffer.position() + position + length);
        position += length;
 
        return bytes;
    } 
 
    @Override 
    public final void readFully(byte[] buffer) throws IOException
    { 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 MappedByteBuffer Questions & Answers:

See Code Examples for Java 8 MappedByteBuffer Methods: