Examples of OffHeapMemory


Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     *
     * @param struct struct to add
     * @param structPos struct offset
     */
    public void add(byte[] struct, int structPos) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = null == bt ? OffHeapMemory.allocateMemory(len * structLength)
                    : OffHeapMemory.allocateMemoryOnHeap(bt, len * structLength);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, oh.length());
            oh.free();
            ohm = newOhm;
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

    /**
     * Shrinks array list capacity to current size
     */
    public void shrinkToFit() {
        long byteslen = size * structLength;
        OffHeapMemory oh = ohm;
        OffHeapMemory newOhm = null == bt ? OffHeapMemory.allocateMemory(byteslen)
                : OffHeapMemory.allocateMemoryOnHeap(bt, byteslen);
        oh.copy(0, newOhm, 0, byteslen);
        oh.free();
        ohm = newOhm;
        capacity = size;
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

    /**
     * {@inheritDoc}
     */
    @Override
    public OffHeapStructArray clone() {
        OffHeapMemory cloned = ohm.clone();
        return new OffHeapStructArray(cloned, structLength);
    }
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     * on capacity exceed.
     *
     * @param value value to add
     */
    public void add(long value) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = OffHeapMemory.allocateMemory(len * ELEMENT_LENGTH);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, oh.length());
            oh.free();
            ohm = newOhm;
            capacity = len;
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

    /**
     * {@inheritDoc}
     */
    @Override
    public OffHeapLongArray clone() {
        OffHeapMemory cloned = ohm.clone();
        return new OffHeapLongArray(cloned);
    }
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     *
     * @param header header to add
     * @param payload payload to add
     */
    public void add(long header, long payload) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity()) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = OffHeapMemory.allocateMemory(len * ELEMENT_LENGTH);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, ohm.length());
            oh.free();
            ohm = newOhm;
        }
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     *
     * @param struct struct to add
     * @param structPos struct offset
     */
    public void add(byte[] struct, int structPos) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity()) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = null == bt ? OffHeapMemory.allocateMemory(len * structLength)
                    : OffHeapMemory.allocateMemoryOnHeap(bt, len * structLength);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, ohm.length());
            oh.free();
            ohm = newOhm;
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     *
     * @param header header to add
     * @param payload payload to add
     */
    public void add(long header, int payload) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity()) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = OffHeapMemory.allocateMemory(len * ELEMENT_LENGTH);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, ohm.length());
            oh.free();
            ohm = newOhm;
        }
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     * @param header header to add
     * @param payload payload to add
     * @param payloadPos payload offset
     */
    public void add(long header, byte[] payload, int payloadPos) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity()) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = OffHeapMemory.allocateMemory(len * elementLength);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, ohm.length());
            oh.free();
            ohm = newOhm;
        }
View Full Code Here

Examples of com.alexkasko.unsafe.offheap.OffHeapMemory

     * on capacity exceed.
     *
     * @param value value to add
     */
    public void add(long value) {
        OffHeapMemory oh = ohm;
        long s = size;
        if (s == capacity()) {
            long len = s + (s < (MIN_CAPACITY_INCREMENT / 2) ? MIN_CAPACITY_INCREMENT : s >> 1);
            OffHeapMemory newOhm = OffHeapMemory.allocateMemory(len * ELEMENT_LENGTH);
            // maybe it's better to use Unsafe#reallocateMemory here
            oh.copy(0, newOhm, 0, ohm.length());
            oh.free();
            ohm = newOhm;
        }
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.