Package edu.brown.statistics

Examples of edu.brown.statistics.ObjectHistogram


        //
        final int start_id = 1;
        List<Integer> partitions = new ArrayList<Integer>();
        for (int i = start_id; i <= num_warehouses; i++) {
            File path = new File("histograms/" + i + ".hist");
            ObjectHistogram h = new ObjectHistogram();
            h.load(path, null);
            this.histograms.put(i, h);
            partitions.add(i);
        } // FOR

        int num_nodes = 5;
View Full Code Here


            return (this.root);
        }

        public void add(int hash0, int hash1) {
            if (!this.histograms.containsKey(hash0)) {
                this.histograms.put(hash0, new ObjectHistogram());
            }
            this.histograms.get(hash0).put(hash1);
        }
View Full Code Here

        SortedMap<Integer, ListOrderedSet<Integer>> partition_warehouse_xref = new TreeMap<Integer, ListOrderedSet<Integer>>();
        int num_partitions = args.hasher.getNumPartitions();
        System.out.println("Num of Partitions: " + num_partitions);
        for (int i = 0; i < num_partitions; i++) {
            partition_warehouse_xref.put(i, new ListOrderedSet<Integer>());
            histograms.put(i, new ObjectHistogram());
        }
        Set<Integer> warehouse_ids = new HashSet<Integer>();
        for (AbstractTraceElement<?> element : args.workload) {
            if (element instanceof TransactionTrace) {
                TransactionTrace xact = (TransactionTrace)element;
View Full Code Here

                TransactionTrace xact = (TransactionTrace)element;
                if (!xact.getCatalogItemName().equals("neworder")) continue;
                int w_id = ((Long)xact.getParam(0)).intValue();
                warehouse_ids.add(w_id);
                if (!histograms.containsKey(w_id)) {
                    histograms.put(w_id, new ObjectHistogram());
                }
            }
        } // FOR
        int num_warehouses = warehouse_ids.size();
        System.out.println("Num of Warehouses: " + num_warehouses);
        assert(num_warehouses <= 40);
       
        int changed_cnt = 0;
        int total = 0;
        Random rand = new Random();
        for (AbstractTraceElement<?> element : args.workload) {
            if (element instanceof TransactionTrace) {
                TransactionTrace xact = (TransactionTrace)element;
                if (!xact.getCatalogItemName().equals("neworder")) continue;
                int param_idx = 5;
                total++;
                Object ol_supply_ids[] = xact.getParam(param_idx);
                int orig_w_id = ((Long)xact.getParam(0)).intValue();
               
                RandomDistribution.DiscreteRNG rng = distributions.get(orig_w_id);
                if (rng == null) {
                    LOG.error("Original Warehouse Id: " + orig_w_id);
                    LOG.error(distributions);
                    System.exit(0);
                }
               
                //
                // Let there be some probability that we are going to go to another warehouse
                // to grab our data. For now we'll have all the remote items be in the same
                // warehouse
                //
                Integer remote_w_id = null;
                int updated_items = 0;
                if (rand.nextInt(100) <= OL_SUPPLY_REMOTE) {
                    remote_w_id = rng.nextInt();
                    if (remote_w_id >= num_warehouses) remote_w_id = (remote_w_id % num_warehouses) + 1;
                    histograms.get(orig_w_id).put(remote_w_id);
                } else {
                    histograms.get(orig_w_id).put(orig_w_id);
                }
               
                for (int i = 0; i < ol_supply_ids.length; i++) {
                    if (remote_w_id != null && rand.nextInt(100) <= OL_SUPPLY_REMOTE_ITEM) {
                        ol_supply_ids[i] = remote_w_id;
                        updated_items++;
                       
                        int getStockInfo_cnt = 0;
                        int updateStock_cnt = 0;
                        int createOrderLine_cnt = 0;
                        for (QueryTrace query : xact.getQueries()) {
                            if (query.getCatalogItemName().startsWith("getStockInfo")) {
                                if (getStockInfo_cnt++ == i) query.setParam(1, ol_supply_ids[i]);
                            } else if (query.getCatalogItemName().equals("updateStock")) {
                                if (updateStock_cnt++ == i) query.setParam(5, ol_supply_ids[i]);
                            } else if (query.getCatalogItemName().equals("createOrderLine")) {
                                if (createOrderLine_cnt++ == i) query.setParam(5, ol_supply_ids[i]);
                            }
                        } // FOR
                        //System.out.println(xact.debug(catalog_db));
                        //System.exit(1);
                    //
                    // If we're not changing it, at least make sure it's the same value as the procedure param
                    //
                    } else {
                        ol_supply_ids[i] = orig_w_id;
                    }
                } // FOR
                xact.setParam(param_idx, ol_supply_ids);
                if (updated_items > 0) changed_cnt++;
            }
        } // FOR
        LOG.info("Updated " + changed_cnt + "/" + total + " transactions");
       
        StringBuilder buffer = new StringBuilder();
        buffer.append("Warehouse Histograms:\n");
        for (Integer w_id : histograms.keySet()) {
            ObjectHistogram hist = histograms.get(w_id);
            buffer.append("Partition: " + w_id + " [" + distributions.get(w_id).getMin() + "]\n");
            buffer.append(hist).append("\n");
            hist.save(new File("histograms/" + w_id + ".hist"));
        } // FOR
        LOG.info(buffer.toString());
       
        return;
    }
View Full Code Here

                    type = Type.RANGE;
                }
            }
            if (debug.val) LOG.debug("Adding new attribute " + key + " [" + type + "]");
            this.attributes.put(key, type);
            this.attribute_histograms.put(key, new ObjectHistogram());
            this.attribute_types.put(key, VoltType.NULL);
        }
        // HACK
        if (val != null && (val.getClass().equals(int.class) || val.getClass().equals(Integer.class))) {
            val = new Long((Integer)val);
View Full Code Here

                            case BOOLEAN:
                                val = Boolean.valueOf(json_val);
                                break;
                            case RANGE: {
                                // Get the value type from the histogram
                                ObjectHistogram h = this.attribute_histograms.get(attr_key);
                                assert(h != null);
                                VoltType volt_type = h.getEstimatedType();
                                assert(volt_type != VoltType.INVALID);
                                val = VoltTypeUtil.getObjectFromString(volt_type, json_val);
                                break;
                            }
                            case STRING:
View Full Code Here

        }
       
        public void add(int source, int target) {
            this.map.put(source, target);
            this.distributions.put(source, new RandomDistribution.Zipf(RandomGenerator.this, target, target + this.range, this.zipf_sigma));
            this.histograms.put(source, new ObjectHistogram());
        }
View Full Code Here

        }

        public void add(int source, int target) {
            this.map.put(source, target);
            this.distributions.put(source, new RandomDistribution.Zipf(RandomGenerator.this, target, target + this.range, this.zipf_sigma));
            this.histograms.put(source, new ObjectHistogram());
        }
View Full Code Here

        }

        public void add(int source, int target) {
            this.map.put(source, target);
            this.distributions.put(source, new RandomDistribution.Zipf(RandomGenerator.this, target, target + this.range, this.zipf_sigma));
            this.histograms.put(source, new ObjectHistogram());
        }
View Full Code Here

TOP

Related Classes of edu.brown.statistics.ObjectHistogram

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.