Package edu.brown.utils

Examples of edu.brown.utils.PartitionSet$Itr


        // -------------------------------
       
        // Figure out what partitions they tried to touch so that we can make sure to lock
        // those when the txn is restarted
        boolean malloc = false;
        PartitionSet predict_touchedPartitions = null;
        if (status == Status.ABORT_RESTART ||
            status == Status.ABORT_EVICTEDACCESS ||
            status == Status.ABORT_SPECULATIVE) {
           
            predict_touchedPartitions = new PartitionSet(orig_ts.getPredictTouchedPartitions());
            malloc = true;
        }
        else if (orig_ts.getRestartCounter() <= 2) { // FIXME
            // HACK: Ignore ConcurrentModificationException
            // This can occur if we are trying to requeue the transactions but there are still
            // pieces of it floating around at this site that modify the TouchedPartitions histogram
            predict_touchedPartitions = new PartitionSet();
            malloc = true;
            Collection<Integer> orig_touchedPartitions = orig_ts.getTouchedPartitions().values();
            while (true) {
                try {
                    predict_touchedPartitions.addAll(orig_touchedPartitions);
                } catch (ConcurrentModificationException ex) {
                    continue;
                }
                break;
            } // WHILE
        } else {
            if (debug.val)
                LOG.warn(String.format("Restarting %s as a dtxn using all partitions\n%s", orig_ts, orig_ts.debug()));
            predict_touchedPartitions = this.catalogContext.getAllPartitionIds();
        }
       
        // -------------------------------
        // MISPREDICTION
        // -------------------------------
        if (status == Status.ABORT_MISPREDICT && orig_error instanceof MispredictionException) {
            MispredictionException ex = (MispredictionException)orig_error;
            Collection<Integer> partitions = ex.getPartitions().values();
            assert(partitions.isEmpty() == false) :
                "Unexpected empty MispredictionException PartitionSet for " + orig_ts;

            if (predict_touchedPartitions.containsAll(partitions) == false) {
                if (malloc == false) {
                    // XXX: Since the MispredictionException isn't re-used, we can
                    //      probably reuse the PartitionSet
                    predict_touchedPartitions = new PartitionSet(predict_touchedPartitions);
                    malloc = true;
                }
                predict_touchedPartitions.addAll(partitions);
            }
            if (trace.val)
                LOG.trace(orig_ts + " Mispredicted Partitions: " + partitions);
        }
       
        if (predict_touchedPartitions.contains(base_partition) == false) {
            if (malloc == false) {
                predict_touchedPartitions = new PartitionSet(predict_touchedPartitions);
                malloc = true;
            }
            predict_touchedPartitions.add(base_partition);
        }
        if (predict_touchedPartitions.isEmpty()) {
            if (debug.val)
                LOG.warn(String.format("Restarting %s as a dtxn using all partitions\n%s",
                         orig_ts, orig_ts.debug()));
            predict_touchedPartitions = this.catalogContext.getAllPartitionIds();
        }
       
        // -------------------------------
        // NEW TXN INITIALIZATION
        // -------------------------------
        boolean predict_readOnly = orig_ts.getProcedure().getReadonly(); // FIXME
        boolean predict_abortable = true; // FIXME
       
        LocalTransaction new_ts = this.txnInitializer.createLocalTransaction(
                orig_ts,
                base_partition,
                predict_touchedPartitions,
                predict_readOnly,
                predict_abortable);
        assert(new_ts != null);

        // -------------------------------
        // ANTI-CACHING REQUEUE
        // -------------------------------
        if (status == Status.ABORT_EVICTEDACCESS && orig_error instanceof EvictedTupleAccessException) {
            if (this.anticacheManager == null) {
                String message = "Got eviction notice but anti-caching is not enabled";
                LOG.warn(message);
                throw new ServerFaultException(message, orig_error, orig_ts.getTransactionId());
            }
           
            EvictedTupleAccessException error = (EvictedTupleAccessException)orig_error;
            short block_ids[] = error.getBlockIds();
            int tuple_offsets[] = error.getTupleOffsets();

            Table evicted_table = error.getTable(this.catalogContext.database);
            new_ts.setPendingError(error, false);

            if (debug.val)
                LOG.debug(String.format("Added aborted txn to %s queue. Unevicting %d blocks from %s (%d).",
                          AntiCacheManager.class.getSimpleName(), block_ids.length, evicted_table.getName(), evicted_table.getRelativeIndex()));
           
            if (orig_ts.getBasePartition() != error.getPartitionId() && !this.isLocalPartition(error.getPartitionId())) {
                new_ts.setOldTransactionId(orig_ts.getTransactionId());
            }
            this.anticacheManager.queue(new_ts, error.getPartitionId(), evicted_table, block_ids, tuple_offsets);
           
           
        }
           
        // -------------------------------
        // REGULAR TXN REQUEUE
        // -------------------------------
        else {
            if (debug.val) {
                LOG.debug(String.format("Re-executing %s as new %s-partition %s on partition %d " +
                          "[restarts=%d, partitions=%s]%s",
                          orig_ts,
                          (predict_touchedPartitions.size() == 1 ? "single" : "multi"),
                          new_ts,
                          base_partition,
                          new_ts.getRestartCounter(),
                          predict_touchedPartitions,
                          (trace.val ? "\n"+orig_ts.debug() : "")));
View Full Code Here


            } // FOR
            stmt_params.put(catalog_stmt, params);
           
            // Then get the list of partitions that it will access
            // This should always be *all* partitions
            PartitionSet partitions = new PartitionSet();
            p_estimator.getAllPartitions(partitions, catalog_stmt, params, base_partition);
            assertNotNull(partitions);
            assertEquals(CatalogUtil.getNumberOfPartitions(clone_db), partitions.size());
        } // FOR
       
        // Now apply the optimized queries
        // The number of partitions that our Statements touch should be reduced to one
        vpc.applyUpdate();
        assert(vpc.isUpdateApplied());
        for (Statement catalog_stmt : vpc.getOptimizedQueries()) {
            Object params[] = stmt_params.get(catalog_stmt);
            assertNotNull(params);
            PartitionSet partitions = new PartitionSet();
            p_estimator.getAllPartitions(partitions, catalog_stmt, params, base_partition);
            assertNotNull(partitions);
            assertEquals(1, partitions.size());
        } // FOR

    }
View Full Code Here

        // If we get here, then we should definitely have a MarkovGraph
        MarkovGraph markov = state.getMarkovGraph();
        assert(markov != null);
           
        MarkovVertex current = state.getCurrent();
        PartitionSet touchedPartitions = state.getTouchedPartitions();
        MarkovVertex next_v = null;
        MarkovEdge next_e = null;
        Statement last_stmt = null;
        int stmt_idxs[] = null;

        // We can cache what the path is based on the first and last query in the batch
        // We only want to do this for batches that are large enough.
        if (hstore_conf.site.markov_endpoint_caching &&
                batch_size >= hstore_conf.site.markov_batch_caching_min) {
            assert(current != null);
            if (debug.val)
                LOG.debug("Attempting cache look-up for last statement in batch: " + Arrays.toString(catalog_stmts));
           
            state.cache_last_partitions.clear();
            state.cache_past_partitions.clear();
           
            PartitionSet last_partitions;
            stmt_idxs = new int[batch_size];
            for (int i = 0; i < batch_size; i++) {
                last_stmt = catalog_stmts[i];
                last_partitions = partitions[batch_size - 1];
                stmt_idxs[i] = state.updateQueryInstanceCount(last_stmt);
View Full Code Here

        if (queryCounter < 0) queryCounter = state.updateQueryInstanceCount(catalog_stmt);
        assert(markov != null);
       
        // Examine all of the vertices that are adjacent to our current vertex
        // and see which vertex we are going to move to next
        PartitionSet touchedPartitions = state.getTouchedPartitions();
        MarkovVertex current = state.getCurrent();
        assert(current != null);
        MarkovVertex next_v = null;
        MarkovEdge next_e = null;
       
View Full Code Here

            int batch_size = e.getValue().size();
            if (trace.val) LOG.trace(String.format("Batch #%d: %d traces", e.getKey(), batch_size));
           
            // Generate the data structures we will need to give to the TransactionEstimator
            Statement catalog_stmts[] = new Statement[batch_size];
            PartitionSet partitions[] = new PartitionSet[batch_size];
            this.populateQueryBatch(e.getValue(), s.getBasePartition(), catalog_stmts, partitions);
       
            synchronized (s.getMarkovGraph()) {
                this.executeQueries(s, catalog_stmts, partitions);
            } // SYNCH
View Full Code Here

        int i = 0;
        boolean readOnly = true;
        for (QueryTrace query_trace : queries) {
            assert(query_trace != null);
            catalog_stmts[i] = query_trace.getCatalogItem(catalogContext.database);
            partitions[i] = new PartitionSet();
            this.p_estimator.getAllPartitions(partitions[i], query_trace, base_partition);
            assert(partitions[i].isEmpty() == false) : "No partitions for " + query_trace;
            readOnly = readOnly && catalog_stmts[i].getReadonly();
            i++;
        } // FOR
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public <T extends EstimatorState> T startTransactionImpl(Long txn_id, int base_partition, Procedure catalog_proc, Object[] args) {
        String procName = catalog_proc.getName();
        FixedEstimatorState ret = new FixedEstimatorState(this.catalogContext, txn_id, base_partition);
        PartitionSet partitions = null;
        PartitionSet readonly = EMPTY_PARTITION_SET;
       
        // SUB_NBR HACK
        if (this.subnbrHack.contains(procName)) {
            int idx = (procName.equalsIgnoreCase("UpdateLocation") ? 1 : 0);
            long s_id = Long.valueOf(args[idx].toString());
View Full Code Here

    @Override
    public <T extends EstimatorState> T startTransactionImpl(Long txn_id, int base_partition, Procedure catalog_proc, Object[] args) {
        String procName = catalog_proc.getName();
        FixedEstimatorState ret = new FixedEstimatorState(this.catalogContext, txn_id, base_partition);
       
        PartitionSet partitions = null;
        PartitionSet readonly = null;
        if (procName.equalsIgnoreCase("neworder")) {
            partitions = this.newOrder(ret, args);
            readonly = EMPTY_PARTITION_SET;
        }
        else if (procName.startsWith("payment")) {
            int hash_w_id = this.getPartition((Short)args[0]);
            int hash_c_w_id = this.getPartition((Short)args[3]);
            if (hash_w_id == hash_c_w_id) {
                partitions = this.catalogContext.getPartitionSetSingleton(hash_w_id);
            } else {
                partitions = new PartitionSet();
                partitions.add(hash_w_id);
                partitions.add(hash_c_w_id);
            }
            readonly = EMPTY_PARTITION_SET;
        }
View Full Code Here

        final Short w_id = (Short)args[0];
        assert(w_id != null);
        short s_w_ids[] = (short[])args[5];
       
        int base_partition = this.getPartition(w_id.shortValue());
        PartitionSet touchedPartitions = this.catalogContext.getPartitionSetSingleton(base_partition);
        assert(touchedPartitions != null) : "base_partition = " + base_partition;
        for (int i = 0; i < s_w_ids.length; i++) {
            if (s_w_ids[i] != w_id) {
                if (this.neworder_prefetchables != null) {
                    for (CountedStatement cntStmt : this.getNewOrderPrefetchables(i)) {
                        state.addPrefetchableStatement(cntStmt);
                    } // FOR
                }
                if (touchedPartitions.size() == 1) {
                    touchedPartitions = new PartitionSet(base_partition);
                }
                touchedPartitions.add(this.getPartition(s_w_ids[i]));
            }
        } // FOR
        if (debug.val)
            LOG.debug(String.format("NewOrder - [W_ID=%d / S_W_IDS=%s] => [BasePartition=%s / Partitions=%s]",
                      w_id, Arrays.toString(s_w_ids),
View Full Code Here

        }
        @SuppressWarnings("unchecked")
        @Override
        protected <T extends EstimatorState> T startTransactionImpl(Long txn_id, int base_partition, Procedure catalog_proc, Object[] args) {
            FixedEstimatorState ret = new FixedEstimatorState(this.catalogContext, txn_id, base_partition);
            PartitionSet partitions = this.catalogContext.getPartitionSetSingleton(base_partition);
            PartitionSet readonly = EMPTY_PARTITION_SET;
            ret.createInitialEstimate(partitions, readonly, EMPTY_PARTITION_SET);
            return ((T)ret);
        }
View Full Code Here

TOP

Related Classes of edu.brown.utils.PartitionSet$Itr

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.