Package org.voltdb.messaging

Examples of org.voltdb.messaging.FastSerializer$BufferGrowCallback


   
                //
                // We then stick a serialized version of PlanNodeTree into a PlanFragment
                //
                try {
                    FastSerializer fs = new FastSerializer(false, false); // C++ needs little-endian
                    fs.write(json.getBytes());
                    String hexString = fs.getHexEncodedBytes();
                    planFragment.setPlannodetree(hexString);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw compiler.new VoltCompilerException(e.getMessage());
                }
View Full Code Here


           
            if (m_useMultipleThreads) {
                cxn.createWork(now, invocation.getClientHandle(), invocation.getProcName(), invocation, cb);
            } 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);
                }
                cxn.createWork(now, invocation.getClientHandle(), invocation.getProcName(), c, cb);
            }
//            final String invocationName = invocation.getProcName();
View Full Code Here

     * @return
     */
    @SuppressWarnings("unused")
    private FastSerializer getSerializer() {
        Thread t = Thread.currentThread();
        FastSerializer fs = this.m_serializers.get(t);
        if (fs == null) {
            fs = new FastSerializer(m_pool);
            this.m_serializers.put(t, fs);
        }
        assert(fs != null);
        return (fs);
    }
View Full Code Here

            final int[] input_depIds,
            final int[] output_depIds,
            final ParameterSet[] parameterSets, final int numParameterSets, final long txnId,
            final long lastCommittedTxnId, final long undoToken) {
        // big endian, not direct
        final FastSerializer fser = new FastSerializer();
        try {
            for (int i = 0; i < numFragmentIds; ++i) {
                parameterSets[i].writeExternal(fser);
            }
        } catch (final IOException exception) {
            throw new RuntimeException(exception);
        }

        m_data.clear();
        m_data.putInt(cmd.m_id);
        m_data.putLong(txnId);
        m_data.putLong(lastCommittedTxnId);
        m_data.putLong(undoToken);
        m_data.putInt(numFragmentIds);
        m_data.putInt(numParameterSets);
        for (int i = 0; i < numFragmentIds; ++i) {
            m_data.putLong(planFragmentIds[i]);
        }
        /** PAVLO **/
        for (int i = 0; i < numFragmentIds; ++i) {
            m_data.putInt(input_depIds[i]);
        }
        for (int i = 0; i < numFragmentIds; ++i) {
            m_data.putInt(output_depIds[i]);
        }
        /** PAVLO **/
        m_data.put(fser.getBuffer());

        try {
            m_data.flip();
            m_connection.write();
        } catch (final Exception e) {
View Full Code Here

    public DependencySet executePlanFragment(final long planFragmentId, final int outputDepId,
            final int inputDepId, final ParameterSet parameterSet, final long txnId,
            final long lastCommittedTxnId, final long undoToken)
            throws EEException {
        // big endian, not direct
        final FastSerializer fser = new FastSerializer();
        try {
            parameterSet.writeExternal(fser);
        } catch (final IOException exception) {
            throw new RuntimeException(exception);
        }

        m_data.clear();
        m_data.putInt(Commands.PlanFragment.m_id);
        m_data.putLong(txnId);
        m_data.putLong(lastCommittedTxnId);
        m_data.putLong(undoToken);
        m_data.putLong(planFragmentId);
        m_data.putInt(outputDepId);
        m_data.putInt(inputDepId);
        m_data.put(fser.getBuffer());

        try {
            m_data.flip();
            m_connection.write();
        } catch (final Exception e) {
View Full Code Here

    @Override
    public VoltTable executeCustomPlanFragment(final String plan, int outputDepId,
            int inputDepId, final long txnId, final long lastCommittedTxnId,
            final long undoQuantumToken) throws EEException
    {
        final FastSerializer fser = new FastSerializer();
        try {
            fser.writeString(plan);
        } catch (final IOException exception) {
            throw new RuntimeException(exception);
        }

        m_data.clear();
        m_data.putInt(Commands.CustomPlanFragment.m_id);
        m_data.putLong(txnId);
        m_data.putLong(lastCommittedTxnId);
        m_data.putLong(undoQuantumToken);
        m_data.putInt(outputDepId);
        m_data.putInt(inputDepId);
        m_data.put(fser.getBuffer());

        try {
            m_data.flip();
            m_connection.write();
        } catch (final Exception e) {
View Full Code Here

    public int hashinate(Object value, int partitionCount)
    {
        ParameterSet parameterSet = new ParameterSet(true);
        parameterSet.setParameters(value);

        final FastSerializer fser = new FastSerializer();
        try {
            parameterSet.writeExternal(fser);
        } catch (final IOException exception) {
            throw new RuntimeException(exception);
        }

        m_data.clear();
        m_data.putInt(Commands.Hashinate.m_id);
        m_data.putInt(partitionCount);
        m_data.put(fser.getBuffer());
        try {
            m_data.flip();
            m_connection.write();

            m_connection.readStatusByte();
View Full Code Here

        String hostname = ConnectionUtil.getHostnameOrAddress();
        m_file = file;
        m_tableName = tableName;
        m_fos = new FileOutputStream(file);
        m_channel = m_fos.getChannel();
        final FastSerializer fs = new FastSerializer();
        fs.writeInt(0);//CRC
        fs.writeInt(0);//Header length placeholder
        fs.writeByte(1);//Indicate the snapshot was not completed, set to true for the CRC calculation, false later
        for (int ii = 0; ii < 4; ii++) {
            fs.writeInt(version[ii]);//version
        }
        fs.writeLong(createTime);
        fs.writeInt(hostId);
        fs.writeString(hostname);
        fs.writeString(clusterName);
        fs.writeString(databaseName);
        fs.writeString(tableName.toUpperCase());
        fs.writeBoolean(isReplicated);
        if (!isReplicated) {
            fs.writeArray(partitionIds);
            fs.writeInt(numPartitions);
        }
        final BBContainer container = fs.getBBContainer();
        container.b.position(4);
        container.b.putInt(container.b.remaining() - 4);
        container.b.position(0);

        FastSerializer schemaSerializer = new FastSerializer();
        schemaTable.writeExternal(schemaSerializer);
        final BBContainer schemaContainer = schemaSerializer.getBBContainer();
        schemaContainer.b.limit(schemaContainer.b.limit() - 4);//Don't want the row count
        schemaContainer.b.position(schemaContainer.b.position() + 4);//Don't want total table length

        final CRC32 crc = new CRC32();
        ByteBuffer aggregateBuffer = ByteBuffer.allocate(container.b.remaining() + schemaContainer.b.remaining());
View Full Code Here

        // Serialize the results
        Hstoreservice.Status status = Hstoreservice.Status.OK;
        String extra = null;
        ClientResponseImpl response = new ClientResponseImpl(-1, clientHandle, -1, status, results, extra);
        response.setClientHandle(clientHandle);
        FastSerializer out = new FastSerializer();
        try {
            out.writeObject(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        return out.getBytes();
    }
View Full Code Here

            final long lastCommittedSpHandle,
            final long uniqueId,
            final long undoToken)
    {
        // big endian, not direct
        final FastSerializer fser = new FastSerializer();
        try {
            for (int i = 0; i < numFragmentIds; ++i) {
                // pset can be ByteBuffer or ParameterSet instance
                if (parameterSets[i] instanceof ByteBuffer) {
                    fser.write((ByteBuffer) parameterSets[i]);
                }
                else {
                    ParameterSet pset = (ParameterSet) parameterSets[i];
                    ByteBuffer buf = ByteBuffer.allocate(pset.getSerializedSize());
                    pset.flattenToBuffer(buf);
                    buf.flip();
                    fser.write(buf);
                }
            }
        } catch (final IOException exception) {
            fser.discard();
            throw new RuntimeException(exception);
        }

        // if inputDepIds is null, make a bunch of dummies
        long[] inputDepIds = inputDepIdsIn;
        if (inputDepIds == null) {
            inputDepIds = new long[numFragmentIds];
            for (int i = 0; i < inputDepIds.length; i++) {
                inputDepIds[0] = -1;
            }
        }

        m_data.clear();
        m_data.putInt(cmd.m_id);
        m_data.putLong(txnId);
        m_data.putLong(spHandle);
        m_data.putLong(lastCommittedSpHandle);
        m_data.putLong(uniqueId);
        m_data.putLong(undoToken);
        m_data.putInt(numFragmentIds);
        for (int i = 0; i < numFragmentIds; ++i) {
            m_data.putLong(planFragmentIds[i]);
        }
        for (int i = 0; i < numFragmentIds; ++i) {
            m_data.putLong(inputDepIds[i]);
        }
        m_data.put(fser.getBuffer());
        fser.discard();

        try {
            m_data.flip();
            m_connection.write();
        } catch (final Exception e) {
View Full Code Here

TOP

Related Classes of org.voltdb.messaging.FastSerializer$BufferGrowCallback

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.