Package org.voltdb.utils.DBBPool

Examples of org.voltdb.utils.DBBPool.BBContainer


             * Peek the first buffer and inspect it to see if it needs any special handling
             * If it is to large to use as part of a gathering write then branch and just focus on
             * writing the one
             */
            final int queuedForWrite = 0;
            final BBContainer peekedBuffer = m_queuedBuffers.peek();
            if (peekedBuffer.b.remaining() > MAX_GATHERING_WRITE) {
                /*
                 * If the buffer is not direct and it is this large it should be split up in separate writes
                 */
                if (!peekedBuffer.b.isDirect()) {
                    /**
                     * Split a big heap byte buffer into many smaller slices
                     * so Java doesn't allocate a bunch of direct ByteBuffers
                     */
                    //The source buffer for the slices that holds the memory goes in first
                    //so it will be discarded once all the slices have been read.
                    m_queuedBuffers.push(peekedBuffer);
                    final int originalPosition = peekedBuffer.b.position();
                    do {
                        final int amountToSplit = Math.min(peekedBuffer.b.remaining(), MAX_GATHERING_WRITE);
                        peekedBuffer.b.position(peekedBuffer.b.limit() - amountToSplit);
                        final BBContainer splice = DBBPool.wrapBB(peekedBuffer.b.slice());
                        m_queuedBuffers.push(splice);
                        m_messagesWritten--;//corrects message count
                        peekedBuffer.b.limit(peekedBuffer.b.position());
                        peekedBuffer.b.position(originalPosition);
                    }
View Full Code Here


             */
            if (b.remaining() < DBBPool.MAX_ALLOCATION_SIZE){
                m_queuedWrites.offer(new DeferredSerialization() {
                    @Override
                    public BBContainer serialize(final DBBPool pool) {
                        final BBContainer c = pool.acquire(b.remaining());
                        assert(c.b.isDirect());
                        c.b.put(b);
                        c.b.flip();
                        return c;
                    }
View Full Code Here

                    oldlist = m_queuedWrites2;
                    m_queuedWrites = m_queuedWrites1;
                }
            }
        }
        final BBContainer results[] = new BBContainer[oldlist.size()];
        int ii = 0;
        DeferredSerialization ds = null;
        int bytesQueued = 0;
        while ((ds = oldlist.poll()) != null) {
            results[ii] = ds.serialize(pool);
View Full Code Here

     * and will be freed when the thread terminates.
     */
    synchronized void shutdown() {
        int bytesReleased = 0;
        m_isShutdown = true;
        BBContainer c = null;
        while ((c = m_queuedBuffers.poll()) != null) {
            bytesReleased += c.b.remaining();
            c.discard();
        }
        updateQueued(-bytesReleased, false);
        DeferredSerialization ds = null;
        while ((ds = m_queuedWrites.poll()) != null) {
            ds.cancel();
View Full Code Here

        final StoredProcedureInvocation invocation =
            new StoredProcedureInvocation(0, procName, parameters);
        final FastSerializer fds = new FastSerializer();
        int size = 0;
        try {
            final BBContainer c = fds.writeObjectForMessaging(invocation);
            size = c.b.remaining();
            c.discard();
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
        return size;
    }
View Full Code Here

                     * overwrite the partition id that is not part of the
                     * serialization format
                     */
                    Container c = m_buffers.poll();
                    if (c == null) {
                        final BBContainer originContainer = DBBPool.allocateDirect(DEFAULT_CHUNKSIZE);
                        final ByteBuffer b = originContainer.b;
                        final long pointer = org.voltdb.utils.DBBPool.getBufferAddress(b);
                        c = new Container(b, pointer, originContainer);
                    }

View Full Code Here

            } else {
               
                final FastSerializer fs = new FastSerializer(m_pool, expectedSerializedSize);
//                FastSerializer fs = this.getSerializer();
//                fs.reset();
                BBContainer c = null;
                try {
                    c = fs.writeObjectForMessaging(invocation);
                } catch (IOException e) {
                    fs.getBBContainer().discard();
                    throw new RuntimeException(e);
View Full Code Here

        m_availableSnapshotBuffers.clear();
    }

    void initializeBufferPool() {
        for (int ii = 0; ii < SnapshotSiteProcessor.m_numSnapshotBuffers; ii++) {
            final BBContainer origin = org.voltdb.utils.DBBPool.allocateDirect(m_snapshotBufferLength);
            m_snapshotBufferOrigins.add(origin);
            long snapshotBufferAddress = 0;
            if (VoltDB.getLoadLibVOLTDB()) {
                snapshotBufferAddress = org.voltdb.utils.DBBPool.getBufferAddress(origin.b);
            }
            m_availableSnapshotBuffers.offer(new BBContainer(origin.b, snapshotBufferAddress) {
                @Override
                public void discard() {
                    m_availableSnapshotBuffers.offer(this);
                    m_onPotentialSnapshotWork.run();
                }
View Full Code Here

            final SnapshotTableTask currentTask = m_snapshotTableTasks.peek();           
            assert(currentTask != null);
            LOG.trace("SNAPSHOT TASK : "+currentTask+ " on partition :"+ partition_id+ " Target :"+currentTask.m_target);

            final int headerSize = currentTask.m_target.getHeaderSize();
            final BBContainer snapshotBuffer = m_availableSnapshotBuffers.poll();
            assert(snapshotBuffer != null);
            snapshotBuffer.b.clear();
            snapshotBuffer.b.position(headerSize);
            int serialized = 0;
           
View Full Code Here

        }
        return hasMoreChunks;
    }

    private static synchronized BBContainer getNextChunk() throws IOException {
        BBContainer c = null;
        while (c == null && m_saveFiles.peek() != null) {
            TableSaveFile f = m_saveFiles.peek();
            LOG.trace("File Channel Size :" + f.getFileChannel().size());
            LOG.trace("File Channel Position :" + f.getFileChannel().position());
            c = f.getNextChunk();
View Full Code Here

TOP

Related Classes of org.voltdb.utils.DBBPool.BBContainer

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.