Package edu.brown.hashing

Examples of edu.brown.hashing.AbstractHasher


     * testNewOrder
     */
    @Test
    public void testNewOrder() throws Exception {
        Procedure catalog_proc = this.getProcedure(neworder.class);
        AbstractHasher hasher = p_estimator.getHasher();
       
        long txn_id = 1000;
        for (short w_id = 1; w_id <= NUM_PARTITIONS; w_id++) {
            short remote_w_id = (short)rng.numberExcluding(1, NUM_PARTITIONS, w_id);
           
            // ORDER_LINE ITEMS
            int num_items = rng.number(TPCCConstants.MIN_OL_CNT, TPCCConstants.MAX_OL_CNT);
            int item_id[] = new int[num_items];
            short supware[] = new short[num_items];
            int quantity[] = new int[num_items];
            for (int i = 0; i < num_items; i++) {
                item_id[i] = rng.nextInt();
                supware[i] = remote_w_id;
                quantity[i] = rng.number(TPCCConstants.MIN_QUANTITY, TPCCConstants.MAX_QUANTITY);
            } // FOR
           
            Object args[] = {
                w_id,                   // W_ID
                (byte)rng.nextInt(10)// D_ID
                rng.nextInt(),          // C_ID
                new TimestampType(),    // TIMESTAMP
                item_id,                // ITEM_IDS
                supware,                // SUPPLY W_IDS
                quantity                // QUANTITIES
            };
           
            EstimatorState state = this.estimator.startTransaction(txn_id, catalog_proc, args);
            assertNotNull(state);
            assertEquals(txn_id, state.getTransactionId().longValue());
//            System.err.printf("W_ID=%d / S_W_ID=%s\n", w_id, remote_w_id);
           
            // Make sure that it identifies that we are a distributed transaction and
            // that we expect to touch both the W_ID partition and the REMOTE_W_ID partition
            Estimate est = state.getInitialEstimate();
            assertNotNull(est);
            PartitionSet partitions = est.getTouchedPartitions(thresholds);
            assertEquals(2, partitions.size());
            for (int expected : new int[]{ w_id, remote_w_id }) {
                expected = hasher.hash(expected);
                assertTrue(Integer.toString(expected) + "->" + partitions, partitions.contains(expected));
            } // FOR
            assertEquals(hasher.hash(w_id), state.getBasePartition());
            txn_id++;
        } // FOR
    }
View Full Code Here


        VoltTable vts[] = {
            CatalogUtil.getVoltTable(catalog_tbl),
            CatalogUtil.getVoltTable(catalog_tbl)
        };
        assertEquals(NUM_PARTITIONS, vts.length);
        AbstractHasher hasher = p_estimator.getHasher();
        Column sub_nbr = catalog_tbl.getColumns().getIgnoreCase("SUB_NBR");
        Column sf_type = catalog_tbl.getColumns().getIgnoreCase("SF_TYPE");
        Column start_time = catalog_tbl.getColumns().getIgnoreCase("START_TIME");
       
        for (int i = 0; i < NUM_TUPLES; i++) {
            Object row[] = VoltTableUtil.getRandomRow(catalog_tbl);
            row[0] = Integer.valueOf(i);
           
            // Column Fixes
            if (sub_nbr != null) row[sub_nbr.getIndex()] = row[0].toString();
            if (sf_type != null) row[sf_type.getIndex()] = 1l;
            if (start_time != null) row[start_time.getIndex()] = 1l;
           
            vts[hasher.hash(row[0])].addRow(row);
        } // FOR
        for (int i = 0; i < vts.length; i++) {
            PartitionExecutor executor = hstore_site.getPartitionExecutor(i);
            executor.loadTable((long)i, catalog_tbl, vts[i], false);
            // System.err.println(catalog_tbl + " - " + i + "\n" + VoltTableUtil.format(vts[i]) + "\n");
View Full Code Here

        SingleSitedCostModel cost_model = new SingleSitedCostModel(info.catalogContext);
        LOG.info("Generating cost model information for given PartitionPlan");
        cost_model.estimateWorkloadCost(info.catalogContext, this.info.workload);

        int num_partitions = info.catalogContext.numberOfPartitions;
        AbstractHasher hasher = new DefaultHasher(info.catalogContext, num_partitions);

        Collection<Table> roots = pplan.getNonReplicatedRoots();
        Map<Table, List<Integer>> table_partition_values = new HashMap<Table, List<Integer>>();
        for (Table catalog_tbl : info.catalogContext.database.getTables()) {
            table_partition_values.put(catalog_tbl, new ArrayList<Integer>());
View Full Code Here

    protected String getParamSignature(AbstractTraceElement<? extends CatalogType> element, List<? extends CatalogType> target_params) {
        Object params[] = element.getParams();
       
        String sig = (element.aborted ? "ABRT-" : "");
        if (target_params != null) {
            AbstractHasher hasher = p_estimator.getHasher();
            boolean first = true;
            for (CatalogType catalog_param : target_params) {
                // Skip types that are always unique (and not useful for partitioning)
                VoltType vtype = VoltType.get((catalog_param instanceof StmtParameter ? ((StmtParameter)catalog_param).getJavatype() :
                                                                                        ((ProcParameter)catalog_param).getType()));
                if (vtype == VoltType.STRING || vtype == VoltType.TIMESTAMP) continue;
               
                // Add a prefix to separate parameters
                if (first == false) sig += "|";
               
                // StmtParameter
                if (catalog_param instanceof StmtParameter) {
                    int idx = ((StmtParameter)catalog_param).getIndex();
                    sig += hasher.hash(params[idx]);
                   
                // ProcParameter
                } else if (catalog_param instanceof ProcParameter) {
                    ProcParameter catalog_procparam = (ProcParameter)catalog_param;
                    int idx = catalog_procparam.getIndex();
                   
                    // ARRAY
                    if (catalog_procparam.getIsarray()) {
                        Set<Integer> hashes = new TreeSet<Integer>();
                        for (Object o : (Object[])params[idx]) {
                            hashes.add(hasher.hash(o));
                        } // FOR
                        boolean first_hash = true;
                        for (Integer hash : hashes) {
                            if (first_hash == false) sig += ",";
                            sig += hash;
                            first_hash = false;
                        } // FOR
                    // SCALAR
                    } else {
                        sig += hasher.hash(params[idx]);       
                    }
                } else {
                    assert(false) : "Unexpected: " + catalog_param;
                }
                first = false;
View Full Code Here

TOP

Related Classes of edu.brown.hashing.AbstractHasher

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.