Package edu.brown.workload

Examples of edu.brown.workload.TransactionTrace


    /**
     * testFastPath
     */
    @Test
    public void testFastPath() throws Exception {
        TransactionTrace txn_trace = multip_trace;
        int base_partition = p_estimator.getBasePartition(txn_trace);
       
        List<QueryTrace> queries = txn_trace.getBatchQueries(1);
        assertFalse(queries.isEmpty());
        Statement stmts[] = new Statement[queries.size()];
        PartitionSet partitions[] = new PartitionSet[queries.size()];
        int idx = 0;
        for (QueryTrace q : queries) {
            stmts[idx] = q.getCatalogItem(catalogContext.database);
            assertNotNull(stmts[idx]);
            partitions[idx] = new PartitionSet();
            p_estimator.getAllPartitions(partitions[idx], q, base_partition);
            idx++;
        } // FOR
       
        MarkovEstimatorState states[] = new MarkovEstimatorState[2];
        MarkovEstimate ests[] = new MarkovEstimate[states.length];
        for (int i = 0; i < states.length; i++) {
            HStoreConf.singleton().site.markov_fast_path = (i != 0);
            states[i] = t_estimator.startTransaction(XACT_ID.getAndIncrement(), this.catalog_proc, txn_trace.getParams());
            assertNotNull(states[i]);
            assertNotNull(states[i].getLastEstimate());
            ests[i] = t_estimator.executeQueries(states[i], stmts, partitions);
            assertNotNull(ests[i]);
        } // FOR
View Full Code Here


    /**
     * testProcessTransactionTrace
     */
    @Test
    public void testProcessTransactionTrace() throws Exception {
        TransactionTrace txn_trace = singlep_trace;
        assertNotNull(txn_trace);
        MarkovEstimatorState s = this.t_estimator.processTransactionTrace(txn_trace);
        assertNotNull(s);
       
        MarkovEstimate initialEst = s.getInitialEstimate();
        assertNotNull(initialEst);
        assertTrue(initialEst.toString(), initialEst.isInitialized());
//        assertTrue(initialEst.toString(), initialEst.isSinglePartitionProbabilitySet());
        assertTrue(initialEst.toString(), initialEst.isAbortProbabilitySet());
//        assertTrue(initialEst.toString(), initialEst.getSinglePartitionProbability() < 1.0f);
        assertTrue(initialEst.toString(), initialEst.isConfidenceCoefficientSet());
        assertTrue(initialEst.toString(), initialEst.getConfidenceCoefficient() >= 0f);
        assertTrue(initialEst.toString(), initialEst.getConfidenceCoefficient() <= 1f);
        assertTrue(initialEst.toString(), initialEst.getMarkovPath().isEmpty() == false);
       
        // We should have an MarkovEstimate for each batch
        assertEquals(txn_trace.getBatchCount(), s.getEstimateCount());
        List<Estimate> estimates = s.getEstimates();
        for (int i = 0, cnt = txn_trace.getBatchCount(); i < cnt; i++) {
            List<QueryTrace> queries = txn_trace.getBatchQueries(i);
            assertFalse(queries.isEmpty());
           
            MarkovEstimate est = (MarkovEstimate)estimates.get(i);
            assertNotSame(initialEst, est);
            assertNotNull(est);
View Full Code Here

    // ----------------------------------------------------------------------------------
    // HELPER METHODS
    // ----------------------------------------------------------------------------------
   
    private TransactionTrace getTransactionTrace(Procedure proc, int w_id) throws Exception {
        TransactionTrace txn_trace = null;
        int partition = p_estimator.getHasher().hash(w_id);
        for (TransactionTrace tt : workload.getTraces(proc)) {
            // System.err.println(tt + " :: " + w_id + " / " + tt.getParam(0));
            if (partition == p_estimator.getBasePartition(tt)) {
                txn_trace = tt;
View Full Code Here

        } // FOR
        return (txn_trace);
    }
   
    private TransactionTrace[] getTransactionTraces(Procedure procs[], boolean differentWarehouse) throws Exception {
        TransactionTrace traces[] = new TransactionTrace[procs.length];
        int last = -1;
       
        // Different W_ID
        if (differentWarehouse) {
            for (int i = 0; i < procs.length; i++) {
View Full Code Here

        };
        Statement startStmts[] = {
            this.getStatement(procs[0], "updateStock"),
            null,
        };
        TransactionTrace traces[] = this.getTransactionTraces(procs, true);
       
        AbstractTransaction txns[] = new AbstractTransaction[procs.length];
        @SuppressWarnings("unchecked")
        List<CountedStatement> queries[] = (List<CountedStatement>[])(new ArrayList<?>[procs.length]);
        for (int i = 0; i < procs.length; i++) {
View Full Code Here

    public void testCanExecuteNonConflictingUniqueIndex() throws Exception {
        Procedure procs[] = {
            this.getProcedure(ostatByCustomerId.class),
            this.getProcedure(neworder.class),
        };
        TransactionTrace traces[] = this.getTransactionTraces(procs, true);
       
        AbstractTransaction txns[] = new AbstractTransaction[procs.length];
        @SuppressWarnings("unchecked")
        List<CountedStatement> queries[] = (List<CountedStatement>[])(new ArrayList<?>[procs.length]);
        for (int i = 0; i < procs.length; i++) {
View Full Code Here

    public void testCanExecuteConflictingUniqueIndex() throws Exception {
        Procedure procs[] = {
            this.getProcedure(ostatByCustomerId.class),
            this.getProcedure(neworder.class),
        };
        TransactionTrace traces[] = this.getTransactionTraces(procs, false);
       
        // We need need at least a TransactionTrace for all of the procedures
        // such that they have the same warehouse ids
        int w_id = -1;
        for (int w : TARGET_WAREHOUSES) {
View Full Code Here

        Statement catalog_stmt = CollectionUtil.first(catalog_proc.getStatements());
        assertNotNull(catalog_stmt);
        StmtParameter catalog_stmt_param = CollectionUtil.first(catalog_stmt.getParameters());
        assertNotNull(catalog_stmt_param);
       
        TransactionTrace txn_trace = CollectionUtil.first(workload.getTraces(catalog_proc));
        assertNotNull(txn_trace);
       
        ParameterSet params = new ParameterSet(txn_trace.getParams());
        for (ProcParameter catalog_param : catalog_proc.getParameters()) {
            if (catalog_param.getIsarray()) {
                Object inner[] = (Object[])params.toArray()[catalog_param.getIndex()];
                for (int i = 0; i < inner.length; i++) {
                    ParameterMapping pm = new ParameterMapping(catalog_stmt, 0, catalog_stmt_param, catalog_param, i, 1.0d);
View Full Code Here

        // This is to test our ability to handle a transaction with
        // a path that we haven't seen before.
       
        // Find the S_W_ID that's different than the base partition, and change
        // all of the elements in the array to that value.
        TransactionTrace txn_trace = (TransactionTrace)multip_trace.clone();
        int w_id = (Integer)txn_trace.getParam(0);
        Short s_w_ids[] = (Short[])txn_trace.getParam(5);
        short remote_w_id = -1;
        assert(s_w_ids.length > 0);
        for (int i = 0; i < s_w_ids.length; i++) {
            if (w_id != s_w_ids[i]) {
                remote_w_id = s_w_ids[i];
                break;
            }
        } // FOR
        assert(remote_w_id >= 0);
        assertNotSame(w_id, remote_w_id);
        Arrays.fill(s_w_ids, remote_w_id);
//        System.err.println("S_W_ID: " + Arrays.toString(s_w_ids));
        txn_trace.setParam(5, s_w_ids);
       
        MarkovEstimatorState state = t_estimator.startTransaction(XACT_ID.getAndIncrement(),
                                                                  this.catalog_proc,
                                                                  txn_trace.getParams());
        assertNotNull(state);
           
        // Even though it won't correctly identify the exact path that we're going to
        // take (i.e., what partitions the getStockInfo queries will need), the path
        // should be complete (i.e., we should see each Statement in NewOrder executed
        // at least once)
        MarkovEstimate initialEst = state.getInitialEstimate();
//        System.err.println("FIRST ESTIMATE:\n" + initialEst);
        List<MarkovVertex> initialPath = initialEst.getMarkovPath();
        assertFalse(initialPath.isEmpty());
        Set<Statement> seenStmts = new HashSet<Statement>();
        for (MarkovVertex v : initialPath) {
            Statement stmt = v.getCatalogItem();
            if ((stmt instanceof StatementWrapper) == false) {
                seenStmts.add(stmt);
            }
        } // FOR
        Procedure proc = txn_trace.getCatalogItem(catalogContext.database);
        for (Statement stmt : proc.getStatements()) {
            assertTrue(stmt.fullName(), seenStmts.contains(stmt));
        }
//        System.err.println(proc + "\n" + StringUtil.join("\n", proc.getStatements()));
//        System.err.println("=======================================");
View Full Code Here

    /**
     * testStartTransactionDtxn
     */
    @Test
    public void testStartTransactionDtxn() throws Exception {
        TransactionTrace txn_trace = multip_trace;
        long txn_id = XACT_ID.getAndIncrement();
        MarkovEstimatorState state = t_estimator.startTransaction(txn_id, this.catalog_proc, txn_trace.getParams());
        assertNotNull(state);
        assertNotNull(state.getLastEstimate());
       
        MarkovEstimate initialEst = state.getInitialEstimate();
        assertNotNull(initialEst);
View Full Code Here

TOP

Related Classes of edu.brown.workload.TransactionTrace

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.