Examples of LongsSegment


Examples of com.fasterxml.util.membuf.base.LongsSegment

        if (_freeSegmentCount <= 0) { // no local buffers available yet
            if (_usedSegmentsCount >= _maxSegmentsToAllocate) { // except we are maxed out
                return false;
            }
            // if we are, let's try allocate: will be added to "free" segments first, then used
            LongsSegment newFree = _segmentAllocator.allocateSegments(1, _firstFreeSegment);
            if (newFree == null) {
                return false;
            }
            _freeSegmentCount += 1;
            _firstFreeSegment = newFree;
        }
        // should be set now so:
        final LongsSegment seg = _head;
        seg.finishWriting();
        // and allocate, init-for-writing new one:
        LongsSegment newSeg = _reuseFree().initForWriting();
        seg.relink(newSeg);
        _head = newSeg;
        if (!_head.tryAppend(value)) {
            throw new IllegalStateException("Should have room for a byte after allocation");
        }
View Full Code Here

Examples of com.fasterxml.util.membuf.base.LongsSegment

                // ok, but are allowed to grow that big?
                if ((_usedSegmentsCount + _freeSegmentCount + segmentsToAlloc) > _maxSegmentsToAllocate) {
                    return false;
                }
                // if we are, let's try allocate: will be added to "free" segments first, then used
                LongsSegment newFree = _segmentAllocator.allocateSegments(segmentsToAlloc, _firstFreeSegment);
                if (newFree == null) {
                    return false;
                }
                _freeSegmentCount += segmentsToAlloc;
                _firstFreeSegment = newFree;
View Full Code Here

Examples of com.fasterxml.util.membuf.base.LongsSegment

    protected void _doAppendChunked(long[] buffer, int offset, int length)
    {
        if (length < 1) {
            return;
        }
        LongsSegment seg = _head;
        while (true) {
            int actual = seg.tryAppend(buffer, offset, length);
            offset += actual;
            length -= actual;
            if (length == 0) { // complete, can leave
                return;
            }
            // otherwise, need another segment, so complete current write
            seg.finishWriting();
            // and allocate, init-for-writing new one:
            LongsSegment newSeg = _reuseFree().initForWriting();
            seg.relink(newSeg);
            _head = seg = newSeg;
        }
    }
View Full Code Here

Examples of com.fasterxml.util.membuf.base.LongsSegment

                // ok, but are allowed to grow that big?
                if ((_usedSegmentsCount + _freeSegmentCount + segmentsToAlloc) > _maxSegmentsToAllocate) {
                    return false;
                }
                // if we are, let's try allocate: will be added to "free" segments first, then used
                LongsSegment newFree = _segmentAllocator.allocateSegments(segmentsToAlloc, _firstFreeSegment);
                if (newFree == null) {
                    return false;
                }
                _freeSegmentCount += segmentsToAlloc;
                _firstFreeSegment = newFree;
View Full Code Here

Examples of com.fasterxml.util.membuf.base.LongsSegment

    protected void _doAppendChunked(long[] buffer, int offset, int length)
    {
        // first: append length prefix
        if (!_head.tryAppend(length)) {
            final LongsSegment seg = _head;
            seg.finishWriting();
            // and allocate, init-for-writing new one:
            LongsSegment newSeg = _reuseFree().initForWriting();
            seg.relink(newSeg);
            _head = newSeg;
            if (!_head.tryAppend(length)) {
                throw new IllegalStateException();
            }
        }
        // then payload
        if (length > 0) {
            LongsSegment seg = _head;
            while (true) {
                int actual = seg.tryAppend(buffer, offset, length);
                offset += actual;
                length -= actual;
                if (length == 0) { // complete, can leave
                    return;
                }
                // otherwise, need another segment, so complete current write
                seg.finishWriting();
                // and allocate, init-for-writing new one:
                LongsSegment newSeg = _reuseFree().initForWriting();
                seg.relink(newSeg);
                _head = seg = newSeg;
            }
        }
    }
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.