Package org.nustaq.offheap.bytez.onheap

Examples of org.nustaq.offheap.bytez.onheap.HeapBytez


        final FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
        conf.type = ConfType.UNSAFE;
        conf.setStreamCoderFactory( new FSTConfiguration.StreamCoderFactory() {
            @Override
            public FSTEncoder createStreamEncoder() {
                return new FSTBytezEncoder(conf, new HeapBytez(new byte[4096]));
            }
            @Override
            public FSTDecoder createStreamDecoder() {
                return new FSTBytezDecoder(conf);
            }
View Full Code Here


    }

    public OnHeapCoder(boolean sharedRefs) {
        conf = FSTConfiguration.createFastBinaryConfiguration();
        conf.setShareReferences(sharedRefs);
        writeTarget = new HeapBytez(new byte[0]);
        readTarget = new HeapBytez(new byte[0]);
        conf.setStreamCoderFactory(new FSTConfiguration.StreamCoderFactory() {
            @Override
            public FSTEncoder createStreamEncoder() {
                FSTBytezEncoder fstBytezEncoder = new FSTBytezEncoder(conf, writeTarget);
                fstBytezEncoder.setAutoResize(false);
View Full Code Here

    }

    @Override
    public void copyTo(BasicBytez other, long otherByteIndex, long myByteIndex, long lenBytes) {
        if ( other instanceof HeapBytez) {
            HeapBytez hp = (HeapBytez) other;
            unsafe.copyMemory(null,baseAdress+myByteIndex, hp.getBase(), hp.getOff()+otherByteIndex,lenBytes);
        } else {
            for ( long i = 0; i < lenBytes; i++ ) {
                other.put(otherByteIndex+i,get(myByteIndex+i));
            }
        }
View Full Code Here

     * set this struct pointer to base array at given offset (=bufoff+index)
     * @param base
     * @param offset direct offset to byte array element (=FSTStruct.bufoff+array index)
     */
    public void baseOn( byte base[], long offset, FSTStructFactory fac) {
        ___bytes = new HeapBytez(base); ___offset = offset; ___fac = fac;
    }
View Full Code Here

     * set this struct pointer to base array at given index
     * @param base
     * @param index
     */
    public void baseOn( byte base[], int index ) {
        ___bytes = new HeapBytez(base); ___offset = index;
        if ( ___fac == null )
            ___fac = FSTStructFactory.getInstance();
    }
View Full Code Here

    public FSTStruct createCopy() {
        if ( ! isOffHeap() ) {
            throw new RuntimeException("must be offheap to call this");
        }
        byte b[] = new byte[getByteSize()];
        HeapBytez res = new HeapBytez(b);
        getBytes(res,0);
        return ___fac.createStructWrapper(res,0);
    }
View Full Code Here

                bytes[count++] = in.readByte();
            }
        } else {
            in.read(bytes);
        }
        HeapBytez hb = new HeapBytez(bytes);
        return FSTStructFactory.getInstance().createStructWrapper(hb, 0);
    }
View Full Code Here

     */
    @Override
    public String readStringAsc() throws IOException {
        int len = readFInt();
        if (ascStringCache == null || ascStringCache.length() < len)
            ascStringCache = new HeapBytez(new byte[len]);
        ensureReadAhead(len);
//        System.arraycopy(input.buf, input.pos, ascStringCache, 0, len);
        input.copyTo(ascStringCache, 0, pos, len);
        pos += len;
        return new String(ascStringCache.getBase(), 0, 0, len);
View Full Code Here

        }
        this.inputStream = in;
        clnames.clear();
        pos = 0;
        if ( input == null )
            input = new HeapBytez(new byte[4096]);
        readUntil = 0;
    }
View Full Code Here

    @Override
    public void resetToCopyOf(byte[] bytes, int off, int len) {
        inputStream = null;
        if ( input == null ) {
            byte[] base = new byte[len];
            input = new HeapBytez(base,0,len);
        }
        if ( input.length() < len )
        {
            input = (HeapBytez) input.newInstance(len);
        }
View Full Code Here

TOP

Related Classes of org.nustaq.offheap.bytez.onheap.HeapBytez

Copyright © 2018 www.massapicom. 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.