Package org.voltdb

Examples of org.voltdb.ParameterSet


        this.batch = new SQLStmt[1];
        this.args = new ParameterSet[1];
        int stmtCounters[] = { 0 };
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            this.batch[0] = new SQLStmt(catalog_stmt);
            this.args[0] = new ParameterSet(this.randomStatementParameters(catalog_stmt));
            this.planner = new BatchPlanner(this.batch, this.catalog_proc, p_estimator);
            this.touched_partitions.clear();
            BatchPlan plan = this.getPlan();
       
            List<WorkFragment.Builder> builders = new ArrayList<WorkFragment.Builder>();
View Full Code Here


        Statement stmts[] = new Statement[]{
            catalog_proc.getStatements().getIgnoreCase("ReplicatedInsert"),
            catalog_proc.getStatements().getIgnoreCase("ReplicatedSelect")
        };
        SQLStmt batch[] = new SQLStmt[stmts.length];
        ParameterSet params[] = new ParameterSet[stmts.length];
        int stmtCounters[] = new int[stmts.length];
        for (int i = 0; i < stmts.length; i++) {
            batch[i] = new SQLStmt(stmts[i]);
            params[i] = new ParameterSet(this.randomStatementParameters(stmts[i]));
            stmtCounters[i] = i;
        } // FOR
       
        BatchPlanner planner = new BatchPlanner(batch, catalog_proc, p_estimator);
        this.touched_partitions.clear();
View Full Code Here

public class TestParameterSet extends TestCase {
    ParameterSet params;

    @Override
    public void setUp() {
        params = new ParameterSet();
    }
View Full Code Here

    public void testNull() throws IOException {
        params.setParameters(new Object[]{null, null, null});
        ByteBuffer buf = ByteBuffer.wrap(FastSerializer.serialize(params));
        buf.rewind();

        ParameterSet out = new ParameterSet();
        out.readExternal(new FastDeserializer(buf));

        assertEquals(3, out.toArray().length);
        assertNull(out.toArray()[0]);
    }
View Full Code Here

    public void testStrings() throws IOException {
        params.setParameters(new Object[]{"foo"});
        ByteBuffer buf = ByteBuffer.wrap(FastSerializer.serialize(params));
        buf.rewind();

        ParameterSet out = new ParameterSet();
        out.readExternal(new FastDeserializer(buf));
        assertEquals(1, out.toArray().length);
        assertEquals("foo", out.toArray()[0]);
    }
View Full Code Here

        assertEquals(1, out.toArray().length);
        assertEquals("foo", out.toArray()[0]);
    }

    public void testStringsAsByteArray() throws IOException {
        params = new ParameterSet();
        params.setParameters(new Object[]{new byte[]{'f', 'o', 'o'}});
        ByteBuffer buf = ByteBuffer.wrap(FastSerializer.serialize(params));
        buf.rewind();

        ParameterSet out = new ParameterSet();
        out.readExternal(new FastDeserializer(buf));
        assertEquals(1, out.toArray().length);

        byte[] bin = (byte[]) out.toArray()[0];
        assertEquals(bin[0], 'f'); assertEquals(bin[1], 'o'); assertEquals(bin[2], 'o');
    }
View Full Code Here

        assertEquals(bin[0], 'f'); assertEquals(bin[1], 'o'); assertEquals(bin[2], 'o');
    }

    private boolean arrayLengthTester(Object[] objs)
    {
        params = new ParameterSet();
        params.setParameters(objs);
        boolean threw = false;
        try
        {
            ByteBuffer buf = ByteBuffer.wrap(FastSerializer.serialize(params));
View Full Code Here

            // what it's actually going to touch
            // The init callback obviously only needs to have the
            // partitions that are local at this site.
            partitions = new PartitionSet(request.getPartitionsList());

            ParameterSet procParams = null;
            if (request.hasProcParams()) {
                FastDeserializer fds = new FastDeserializer(request.getProcParams().asReadOnlyByteBuffer());
                try {
                    procParams = fds.readObject(ParameterSet.class);
                } catch (Exception ex) {
View Full Code Here

        if (debug.val)
            LOG.debug(String.format("%s - Converting raw prefetch parameter bytes into ParameterSets", ts));
       
        List<ByteString> rawParams = ts.getPrefetchRawParameterSets();
        int num_parameters = rawParams.size();
        ParameterSet params[] = new ParameterSet[num_parameters];
        for (int i = 0; i < params.length; i++) {
            fd.setBuffer(rawParams.get(i).asReadOnlyByteBuffer());
            try {
                params[i] = fd.readObject(ParameterSet.class);
            } catch (IOException ex) {
View Full Code Here

        BatchPlanner planner = this.planners.get().get(hashcode);
        if (planner == null) {
            planner = this.addPlanner(ts.getProcedure(), prefetchable, prefetchStmts);
        }
        assert(planner != null) : "Missing BatchPlanner for " + ts.getProcedure();
        final ParameterSet prefetchParams[] = new ParameterSet[planner.getBatchSize()];
        final int prefetchCounters[] = new int[planner.getBatchSize()];
        final ByteString prefetchParamsSerialized[] = new ByteString[prefetchParams.length];
        final int basePartition = ts.getBasePartition();
       
        // Makes a list of ByteStrings containing the ParameterSets that we need
        // to send over to the remote sites so that they can execute our
        // prefetchable queries
        Object proc_params[] = procParams.toArray();
        for (int i = 0; i < prefetchParams.length; i++) {
            CountedStatement counted_stmt = prefetchable.get(i);
            if (debug.val)
                LOG.debug(String.format("%s - Building ParameterSet for prefetchable query %s",
                          ts, counted_stmt));
            Object stmt_params[] = new Object[counted_stmt.statement.getParameters().size()];

            // Generates a new object array using a mapping from the
            // ProcParameter to the StmtParameter. This relies on a
            // ParameterMapping already being installed in the catalog
            for (StmtParameter catalog_param : counted_stmt.statement.getParameters().values()) {
                Collection<ParameterMapping> pmSets = this.catalogContext.paramMappings.get(
                                                                counted_stmt.statement,
                                                                counted_stmt.counter,
                                                                catalog_param);
                assert(pmSets != null) :
                    String.format("Unexpected null %s %s set for %s",
                                  counted_stmt, ParameterMapping.class.getSimpleName(), catalog_param);
                ParameterMapping pm = CollectionUtil.first(pmSets);
                assert(pm != null) :
                    String.format("Unexpected null %s for %s [%s]",
                                  ParameterMapping.class.getSimpleName(),
                                  catalog_param.fullName(), counted_stmt);
                assert(pm.statement_index == counted_stmt.counter) :
                    String.format("Mismatch StmtCounter for %s - Expected[%d] != Actual[%d]\n%s",
                                  counted_stmt, counted_stmt.counter, pm.statement_index, pm);
               
                if (pm.procedure_parameter.getIsarray()) {
                    try {
                        stmt_params[catalog_param.getIndex()] = ParametersUtil.getValue(procParams, pm);
                    } catch (Throwable ex) {
                        String msg = String.format("Unable to get %s value for %s in %s\n" +
                                               "ProcParams: %s\nParameterMapping: %s",
                                                   catalog_param.fullName(), ts, counted_stmt,
                                                   procParams, pm);
                        LOG.error(msg, ex);
                        throw new ServerFaultException(msg, ex, ts.getTransactionId());
                    }
                }
                else {
                    ProcParameter catalog_proc_param = pm.procedure_parameter;
                    assert(catalog_proc_param != null) :
                        "Missing mapping from " + catalog_param.fullName() + " to ProcParameter";
                    stmt_params[catalog_param.getIndex()] = proc_params[catalog_proc_param.getIndex()];
                }
            } // FOR (StmtParameter)
            prefetchParams[i] = new ParameterSet(stmt_params);
            prefetchCounters[i] = counted_stmt.counter;

            if (debug.val)
                LOG.debug(String.format("%s - [Prefetch %02d] %s -> %s",
                          ts, i, counted_stmt, prefetchParams[i]));
View Full Code Here

TOP

Related Classes of org.voltdb.ParameterSet

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.