Java 类org.apache.commons.collections15.set.ListOrderedSet 实例源码

项目:sstore-soft    文件:PlanNodeUtil.java   
/**
 * Get the set of columns
 * 
 * @param catalog_db
 * @param node
 * @return
 */
public static Collection<Column> getOutputColumnsForPlanNode(final Database catalog_db, AbstractPlanNode node) {
    final PlannerContext pcontext = PlannerContext.singleton();
    final Collection<Integer> planColumnIds = getOutputColumnIdsForPlanNode(node);

    final Set<Column> columns = new ListOrderedSet<Column>();
    for (Integer column_guid : planColumnIds) {
        PlanColumn planColumn = pcontext.get(column_guid);
        assert (planColumn != null);
        AbstractExpression exp = planColumn.getExpression();
        assert (exp != null);
        Collection<Column> exp_cols = ExpressionUtil.getReferencedColumns(catalog_db, exp);
        if (debug.val)
            LOG.debug(planColumn.toString() + " => " + exp_cols);
        columns.addAll(exp_cols);
    } // FOR

    return (columns);
}
项目:sstore-soft    文件:PlanNodeUtil.java   
/**
 * Get the set of columns
 * 
 * @param catalogContext
 * @param node
 * @return
 */
public static Collection<AbstractExpression> getOutputExpressionsForPlanNode(AbstractPlanNode node) {
    final PlannerContext pcontext = PlannerContext.singleton();
    final Collection<Integer> planColumnIds = getOutputColumnIdsForPlanNode(node);

    final Collection<AbstractExpression> exps = new ListOrderedSet<AbstractExpression>();
    for (Integer column_guid : planColumnIds) {
        PlanColumn planColumn = pcontext.get(column_guid);
        assert (planColumn != null);
        AbstractExpression exp = planColumn.getExpression();
        assert (exp != null);
        exps.add(exp);
    } // FOR

    return (exps);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * For a given base partition id, return the list of partitions that are on
 * same node as the base partition
 * 
 * @param catalog_db
 * @param base_partition
 * @return
 */
public static Collection<Partition> getLocalPartitions(Database catalog_db, int base_partition) {
    Set<Partition> partitions = new ListOrderedSet<Partition>();

    // First figure out what partition we are in the catalog
    Cluster catalog_clus = CatalogUtil.getCluster(catalog_db);
    assert (catalog_clus != null);
    Partition catalog_part = CatalogUtil.getPartitionById(catalog_clus, base_partition);
    assert (catalog_part != null);
    Site catalog_site = catalog_part.getParent();
    assert (catalog_site != null);
    Host catalog_host = catalog_site.getHost();
    assert (catalog_host != null);

    // Now look at what other partitions are on the same host that we are
    for (Site other_site : catalog_clus.getSites()) {
        if (other_site.getHost().equals(catalog_host) == false)
            continue;
        LOG.trace(catalog_host + " => " + CatalogUtil.debug(other_site.getPartitions()));
        CollectionUtil.addAll(partitions, other_site.getPartitions());
    } // FOR
    return (partitions);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * @param <T>
 * @param <U>
 * @param items
 * @param field
 * @param value
 * @return
 */
public static <T extends CatalogType, U> Set<T> findAll(Iterable<T> items, String field, U value) {
    Set<T> found = new ListOrderedSet<T>();
    for (T catalog_item : items) {
        assert (catalog_item != null);
        try {
            Object field_value = catalog_item.getField(field);
            if (field_value.equals(value))
                found.add(catalog_item);
        } catch (NullPointerException ex) {
            LOG.fatal(catalog_item + ": " + catalog_item.getFields());
            LOG.fatal(catalog_item + " does not have a field '" + field + "'");
            throw ex;
        }
    } // FOR
    return (found);
}
项目:sstore-soft    文件:CollectionUtil.java   
/**
 * Return the ith element of a set. Super lame
 * 
 * @param <T>
 * @param items
 * @param idx
 * @return
 */
public static <T> T get(Iterable<T> items, int idx) {
    if (items == null) {
        return (null);
    }
    else if (items instanceof List<?>) {
        return ((List<T>) items).get(idx);
    }
    else if (items instanceof ListOrderedSet<?>) {
        return ((ListOrderedSet<T>) items).get(idx);
    }
    else if (items instanceof SortedSet<?> && idx == 0) {
        SortedSet<T> set = (SortedSet<T>)items;
        return (set.isEmpty() ? null : set.first());
    }
    int ctr = 0;
    for (T t : items) {
        if (ctr++ == idx) return (t);
    }
    return (null);
}
项目:sstore-soft    文件:InnerGraphInformation.java   
/**
 * Get the lists of roots for this graph. 
 * This probably won't work if the graph is undirected
 * @return
 */
public synchronized Set<V> getRoots() {
    boolean recompute = false;

    // First time
    if (this.roots == null) {
        this.roots = new ListOrderedSet<V>();
        recompute = true;
    // Check whether it's been marked as dirty. If it hasn't, then
    // we know that our cache is still valid
    } else if (this.isDirty(DirtyIndex.ROOTS)) {
        recompute = true;
    }

    if (recompute) {
        this.roots.clear();
        for (V v : this.graph.getVertices()) {
            if (this.graph.getPredecessorCount(v) == 0) {
                this.roots.add(v);
            }
        } // FOR
        // Probably a race condition
        this.resetDirty(DirtyIndex.ROOTS);
    }
    return (Collections.unmodifiableSet(this.roots));
}
项目:sstore-soft    文件:TestCatalogUtil.java   
/**
 * testExtractInsertColumnSet
 */
public void testExtractInsertColumnSet() throws Exception {
    Table catalog_tbl = this.getTable("HISTORY");
    Procedure catalog_proc = this.getProcedure(paymentByCustomerId.class);
    Statement catalog_stmt = this.getStatement(catalog_proc, "insertHistory");

    assertNotNull(catalog_stmt);
    PredicatePairs cset = CatalogUtil.extractStatementPredicates(catalog_stmt, false, catalog_tbl);
    // System.out.println(cset.debug());

    // Column -> StmtParameter Index
    Set<Pair<Column, Integer>> expected_columns = new ListOrderedSet<Pair<Column, Integer>>();
    for (Column catalog_col : CatalogUtil.getSortedCatalogItems(catalog_tbl.getColumns(), "index")) {
        assertNotNull(catalog_col);
        expected_columns.add(Pair.of(catalog_col, catalog_col.getIndex()));
    } // FOR
    System.err.println(StringUtil.columns("EXPECTED:\n" + StringUtil.join("\n", expected_columns), "ACTUAL:\n" + StringUtil.join("\n", cset)));

    this.checkColumnSet(cset, expected_columns);
}
项目:s-store    文件:PlanNodeUtil.java   
/**
 * Get the set of columns
 * 
 * @param catalog_db
 * @param node
 * @return
 */
public static Collection<Column> getOutputColumnsForPlanNode(final Database catalog_db, AbstractPlanNode node) {
    final PlannerContext pcontext = PlannerContext.singleton();
    final Collection<Integer> planColumnIds = getOutputColumnIdsForPlanNode(node);

    final Set<Column> columns = new ListOrderedSet<Column>();
    for (Integer column_guid : planColumnIds) {
        PlanColumn planColumn = pcontext.get(column_guid);
        assert (planColumn != null);
        AbstractExpression exp = planColumn.getExpression();
        assert (exp != null);
        Collection<Column> exp_cols = ExpressionUtil.getReferencedColumns(catalog_db, exp);
        if (debug.val)
            LOG.debug(planColumn.toString() + " => " + exp_cols);
        columns.addAll(exp_cols);
    } // FOR

    return (columns);
}
项目:s-store    文件:PlanNodeUtil.java   
/**
 * Get the set of columns
 * 
 * @param catalogContext
 * @param node
 * @return
 */
public static Collection<AbstractExpression> getOutputExpressionsForPlanNode(AbstractPlanNode node) {
    final PlannerContext pcontext = PlannerContext.singleton();
    final Collection<Integer> planColumnIds = getOutputColumnIdsForPlanNode(node);

    final Collection<AbstractExpression> exps = new ListOrderedSet<AbstractExpression>();
    for (Integer column_guid : planColumnIds) {
        PlanColumn planColumn = pcontext.get(column_guid);
        assert (planColumn != null);
        AbstractExpression exp = planColumn.getExpression();
        assert (exp != null);
        exps.add(exp);
    } // FOR

    return (exps);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * For a given base partition id, return the list of partitions that are on
 * same node as the base partition
 * 
 * @param catalog_db
 * @param base_partition
 * @return
 */
public static Collection<Partition> getLocalPartitions(Database catalog_db, int base_partition) {
    Set<Partition> partitions = new ListOrderedSet<Partition>();

    // First figure out what partition we are in the catalog
    Cluster catalog_clus = CatalogUtil.getCluster(catalog_db);
    assert (catalog_clus != null);
    Partition catalog_part = CatalogUtil.getPartitionById(catalog_clus, base_partition);
    assert (catalog_part != null);
    Site catalog_site = catalog_part.getParent();
    assert (catalog_site != null);
    Host catalog_host = catalog_site.getHost();
    assert (catalog_host != null);

    // Now look at what other partitions are on the same host that we are
    for (Site other_site : catalog_clus.getSites()) {
        if (other_site.getHost().equals(catalog_host) == false)
            continue;
        LOG.trace(catalog_host + " => " + CatalogUtil.debug(other_site.getPartitions()));
        CollectionUtil.addAll(partitions, other_site.getPartitions());
    } // FOR
    return (partitions);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * @param <T>
 * @param <U>
 * @param items
 * @param field
 * @param value
 * @return
 */
public static <T extends CatalogType, U> Set<T> findAll(Iterable<T> items, String field, U value) {
    Set<T> found = new ListOrderedSet<T>();
    for (T catalog_item : items) {
        assert (catalog_item != null);
        try {
            Object field_value = catalog_item.getField(field);
            if (field_value.equals(value))
                found.add(catalog_item);
        } catch (NullPointerException ex) {
            LOG.fatal(catalog_item + ": " + catalog_item.getFields());
            LOG.fatal(catalog_item + " does not have a field '" + field + "'");
            throw ex;
        }
    } // FOR
    return (found);
}
项目:s-store    文件:CollectionUtil.java   
/**
 * Return the ith element of a set. Super lame
 * 
 * @param <T>
 * @param items
 * @param idx
 * @return
 */
public static <T> T get(Iterable<T> items, int idx) {
    if (items == null) {
        return (null);
    }
    else if (items instanceof List<?>) {
        return ((List<T>) items).get(idx);
    }
    else if (items instanceof ListOrderedSet<?>) {
        return ((ListOrderedSet<T>) items).get(idx);
    }
    else if (items instanceof SortedSet<?> && idx == 0) {
        SortedSet<T> set = (SortedSet<T>)items;
        return (set.isEmpty() ? null : set.first());
    }
    int ctr = 0;
    for (T t : items) {
        if (ctr++ == idx) return (t);
    }
    return (null);
}
项目:s-store    文件:InnerGraphInformation.java   
/**
 * Get the lists of roots for this graph. 
 * This probably won't work if the graph is undirected
 * @return
 */
public synchronized Set<V> getRoots() {
    boolean recompute = false;

    // First time
    if (this.roots == null) {
        this.roots = new ListOrderedSet<V>();
        recompute = true;
    // Check whether it's been marked as dirty. If it hasn't, then
    // we know that our cache is still valid
    } else if (this.isDirty(DirtyIndex.ROOTS)) {
        recompute = true;
    }

    if (recompute) {
        this.roots.clear();
        for (V v : this.graph.getVertices()) {
            if (this.graph.getPredecessorCount(v) == 0) {
                this.roots.add(v);
            }
        } // FOR
        // Probably a race condition
        this.resetDirty(DirtyIndex.ROOTS);
    }
    return (Collections.unmodifiableSet(this.roots));
}
项目:s-store    文件:TestCatalogUtil.java   
/**
 * testExtractInsertColumnSet
 */
public void testExtractInsertColumnSet() throws Exception {
    Table catalog_tbl = this.getTable("HISTORY");
    Procedure catalog_proc = this.getProcedure(paymentByCustomerId.class);
    Statement catalog_stmt = this.getStatement(catalog_proc, "insertHistory");

    assertNotNull(catalog_stmt);
    PredicatePairs cset = CatalogUtil.extractStatementPredicates(catalog_stmt, false, catalog_tbl);
    // System.out.println(cset.debug());

    // Column -> StmtParameter Index
    Set<Pair<Column, Integer>> expected_columns = new ListOrderedSet<Pair<Column, Integer>>();
    for (Column catalog_col : CatalogUtil.getSortedCatalogItems(catalog_tbl.getColumns(), "index")) {
        assertNotNull(catalog_col);
        expected_columns.add(Pair.of(catalog_col, catalog_col.getIndex()));
    } // FOR
    System.err.println(StringUtil.columns("EXPECTED:\n" + StringUtil.join("\n", expected_columns), "ACTUAL:\n" + StringUtil.join("\n", cset)));

    this.checkColumnSet(cset, expected_columns);
}
项目:sstore-soft    文件:PlanNodeUtil.java   
/**
 * @param node
 * @return
 */
public static Collection<Integer> getOutputColumnIdsForPlanNode(AbstractPlanNode node) {
    final Collection<Integer> planColumnIds = new ListOrderedSet<Integer>();

    // 2011-07-20: Using the AbstractExpressions is the more accurate way of
    // getting the
    // Columns referenced in the output
    // If this is Scan that has an inline Projection, grab those too
    if ((node instanceof AbstractScanPlanNode) && node.getInlinePlanNode(PlanNodeType.PROJECTION) != null) {
        ProjectionPlanNode prj_node = node.getInlinePlanNode(PlanNodeType.PROJECTION);
        planColumnIds.addAll(prj_node.getOutputColumnGUIDs());
        if (debug.val)
            LOG.debug(prj_node.getPlanNodeType() + ": " + planColumnIds);
    } else {
        planColumnIds.addAll(node.getOutputColumnGUIDs());
        if (debug.val)
            LOG.debug(node.getPlanNodeType() + ": " + planColumnIds);
    }

    // If this is an AggregatePlanNode, then we also need to include columns
    // computed in the aggregates
    if (node instanceof AggregatePlanNode) {
        AggregatePlanNode agg_node = (AggregatePlanNode) node;
        planColumnIds.addAll(agg_node.getAggregateColumnGuids());
        if (debug.val)
            LOG.debug(node.getPlanNodeType() + ": " + agg_node.getAggregateColumnGuids());
    }

    return (planColumnIds);
}
项目:sstore-soft    文件:ClusterConfiguration.java   
public Collection<Integer> getPartitionIds(String host, int site) {
    Set<Integer> ids = new ListOrderedSet<Integer>();
    for (PartitionConfiguration pc : this.getPartitions(host, site)) {
        ids.add(pc.partition);
    } // FOR
    return (ids);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Returns all the columns for this table that have a foreign key dependency
 * on another table
 * 
 * @param catalog_tbl
 * @return
 */
public static Collection<Column> getForeignKeyDependents(Table catalog_tbl) {
    Set<Column> found = new ListOrderedSet<Column>();
    for (Column catalog_col : catalog_tbl.getColumns()) {
        assert (catalog_col != null);
        if (!catalog_col.getConstraints().isEmpty()) {
            // System.out.println(catalog_col + ": " +
            // CatalogUtil.getConstraints(catalog_col.getConstraints()));
            if (!CatalogUtil.findAll(CatalogUtil.getConstraints(catalog_col.getConstraints()), "type", ConstraintType.FOREIGN_KEY.getValue()).isEmpty()) {
                found.add(catalog_col);
            }
        }
    } // FOR
    return (found);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Returns all the tables access/modified in all the Statements for this
 * Procedure
 * 
 * @param catalog_proc
 * @return
 * @throws Exception
 */
public static Collection<Table> getReferencedTables(Procedure catalog_proc) throws Exception {
    final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_proc);
    Set<Table> ret = cache.PROCEDURE_TABLES.get(catalog_proc);
    if (ret == null) {
        Set<Table> tables = new ListOrderedSet<Table>();
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            tables.addAll(CatalogUtil.getReferencedTables(catalog_stmt));
        } // FOR
        ret = Collections.unmodifiableSet(tables);
        cache.PROCEDURE_TABLES.put(catalog_proc, ret);
    }
    return (ret);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Returns all the columns access/modified in all the Statements for this
 * Procedure
 * 
 * @param catalog_proc
 * @return
 * @throws Exception
 */
public static Collection<Column> getReferencedColumns(Procedure catalog_proc) throws Exception {
    final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_proc);
    Set<Column> ret = cache.PROCEDURE_COLUMNS.get(catalog_proc);
    if (ret == null) {
        Set<Column> columns = new ListOrderedSet<Column>();
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            columns.addAll(CatalogUtil.getReferencedColumns(catalog_stmt));
        } // FOR
        ret = Collections.unmodifiableSet(columns);
        cache.PROCEDURE_COLUMNS.put(catalog_proc, ret);
    }
    return (ret);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Returns all of the procedures that access/modify the given table
 * 
 * @param catalog_tbl
 * @return
 * @throws Exception
 */
public static Collection<Procedure> getReferencingProcedures(Table catalog_tbl) throws Exception {
    Set<Procedure> ret = new ListOrderedSet<Procedure>();
    Database catalog_db = CatalogUtil.getDatabase(catalog_tbl);
    for (Procedure catalog_proc : catalog_db.getProcedures()) {
        if (catalog_proc.getSystemproc())
            continue;
        if (CatalogUtil.getReferencedTables(catalog_proc).contains(catalog_tbl)) {
            ret.add(catalog_proc);
        }
    } // FOR
    return (ret);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Return all the Columns used in ORDER BY clauses for the given Statement
 * 
 * @param catalog_stmt
 * @return
 */
public static Collection<Column> getOrderByColumns(Statement catalog_stmt) {
    if (debug.val)
        LOG.debug("Extracting order-by columns from statement " + CatalogUtil.getDisplayName(catalog_stmt));

    final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_stmt);
    Set<Column> ret = cache.STATEMENT_ORDERBY_COLUMNS.get(catalog_stmt);
    if (ret == null) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
        ret = new ListOrderedSet<Column>();
        try {
            AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
            assert (root != null);
            PlannerContext context = PlannerContext.singleton();
            for (OrderByPlanNode node : PlanNodeUtil.getPlanNodes(root, OrderByPlanNode.class)) {
                for (Integer guid : node.getSortColumnGuids()) {
                    PlanColumn pcol = context.get(guid);
                    assert (pcol != null);
                    ret.addAll(ExpressionUtil.getReferencedColumns(catalog_db, pcol.getExpression()));
                } // FOR
            } // FOR
        } catch (Throwable ex) {
            throw new RuntimeException("Failed to retrieve ORDER BY columns for " + catalog_stmt.fullName());
        }
        cache.STATEMENT_ORDERBY_COLUMNS.put(catalog_stmt, ret);
    }
    return (ret);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Return all of the tables referenced in the given AbstractPlanNode
 * Non-recursive.
 * 
 * @param catalog_db
 * @param node
 * @return
 * @throws Exception
 */
public static Collection<Table> getReferencedTablesForPlanNode(final Database catalog_db,
                                                               final AbstractPlanNode node) {
    final Set<Table> ret = new ListOrderedSet<Table>();
    try {
        CatalogUtil.getReferencedTablesForPlanNode(catalog_db, node, ret);
    } catch (Exception ex) {
        throw new RuntimeException("Failed to get referenced tables for " + node, ex);
    }
    return (ret);
}
项目:sstore-soft    文件:CatalogUtil.java   
/**
 * Return all of tables referenced in the PlanNode tree, regardless if they
 * are modified or not
 * 
 * @param catalog_db
 * @param root
 * @return
 */
public static Collection<Table> getReferencedTablesForTree(final Database catalog_db,
                                                           final AbstractPlanNode root) {
    final Set<Table> found = new ListOrderedSet<Table>();
    new PlanNodeTreeWalker(true) {
        @Override
        protected void callback(AbstractPlanNode element) {
            CatalogUtil.getReferencedTablesForPlanNode(catalog_db, element, found);
            return;
        }
    }.traverse(root);
    return (found);
}
项目:sstore-soft    文件:UniqueCombinationIterator.java   
/**
 * Find the next unique combination
 */
private void getNext() {
    assert (this.next == null);
    final boolean trace = LOG.isTraceEnabled();
    final boolean debug = LOG.isDebugEnabled();

    if (debug)
        LOG.debug("Finding next combination [call=" + (this.attempt_ctr++) + "]");

    boolean valid = false;
    Vector<Integer> buffer = null;
    for (int i = this.last.get(0); i < this.num_elements; i++) {
        if (trace)
            LOG.trace("\n" + this);

        buffer = new Vector<Integer>();
        buffer.setSize(this.combo_size);
        buffer.set(0, i);

        // We have a new combination!
        if (this.calculateCombinations(buffer, 1)) {
            if (trace)
                LOG.trace("Found new combination: " + buffer);
            valid = true;
            break;
        }
        if (trace)
            LOG.trace("No combination found that starts with index #" + i);
        buffer = null;
        this.initializeLast(i + 1);
    } // FOR

    if (trace)
        LOG.trace("VALID = " + valid);
    if (valid) {
        assert (this.combo_size == buffer.size());
        this.next = new ListOrderedSet<E>();
        for (int i = 0; i < this.combo_size; i++) {
            this.next.add(this.data.get(buffer.get(i)));
        } // FOR
        if (trace)
            LOG.trace("NEXT = " + this.next);

        // Increase the last position's counter so that it is different next
        // time
        this.last.set(this.combo_size - 1, this.last.lastElement() + 1);
        if (trace)
            LOG.trace("NEW LAST = " + this.last);

        this.finished = false;
    } else {
        this.finished = true;
    }
}
项目:sstore-soft    文件:InnerGraphInformation.java   
/**
 * Return the set of vertices that are descedants of the given vertices
 * @param vertex
 * @return
 */
public synchronized Set<V> getDescendants(V vertex) {
    boolean recompute = false;

    // First time
    if (this.descendants == null) {
        this.descendants = new ListOrderedSet<V>();
        recompute = true;
    // Check whether it's been marked as dirty. If it hasn't, then
    // we know that our cache is still valid
    } else if (this.isDirty(DirtyIndex.DESCENDANTS)) {
        recompute = true;
    }

    if (recompute) {
        this.descendants.clear();
        new VertexTreeWalker<V, E>(this.graph) {
            @Override
            protected void callback(V element) {
                descendants.add(element);
            }
        }.traverse(vertex);
        // Probably a race condition...
        this.resetDirty(DirtyIndex.DESCENDANTS);
    }
    return (Collections.unmodifiableSet(this.descendants));
}
项目:sstore-soft    文件:WorkloadSummarizer.java   
synchronized void add(CT catalog_item, String hash_str, T trace) {
    Map<String, Set<T>> m = this.get(catalog_item);
    if (m == null) {
        m = new ConcurrentHashMap<String, Set<T>>();
        this.put(catalog_item, m);
    }
    Set<T> s = m.get(hash_str);
    if (s == null) {
        s = new ListOrderedSet<T>();
        m.put(hash_str, s);
    }
    s.add(trace);
    this.has_duplicates = this.has_duplicates || s.size() > 1;
}
项目:sstore-soft    文件:FixWorkload.java   
/**
 * 
 * @param catalogContext
 * @throws Exception
 */
public static void addZipfianAffinity(ArgumentsParser args, double sigma) throws Exception {

    //
    // Figure out how many warehouses we have
    //
    ListOrderedSet<Integer> warehouses = new ListOrderedSet<Integer>();
    for (AbstractTraceElement<?> element : args.workload) {
        if (element instanceof TransactionTrace) {
            TransactionTrace xact = (TransactionTrace)element;
            if (!xact.getCatalogItemName().equals("neworder")) continue;
            warehouses.add(((Long)xact.getParam(0)).intValue());
        }
    } // FOR

    //
    // Create a synthetic affinity between different warehouses
    //
    Map<Integer, RandomDistribution.Zipf> distributions = new HashMap<Integer, RandomDistribution.Zipf>();
    Random rand = new Random();
    int num_warehouses = warehouses.size();
    for (Integer w_id : warehouses) {
        int other_id = w_id;
        while (other_id == w_id) other_id = warehouses.get(rand.nextInt(num_warehouses));
        distributions.put(w_id, new RandomDistribution.Zipf(rand, other_id, other_id + num_warehouses, sigma));
        //System.out.println(w_id + " => " + other_id);
    } // FOR
    FixWorkload.updateWorkloadWarehouses(args, distributions);
    return;
}
项目:sstore-soft    文件:DesignerHints.java   
public void addTablePartitionCandidate(Table catalog_tbl, Column catalog_col) {
    final String table_key = CatalogKey.createKey(catalog_tbl);
    final String column_key = CatalogKey.createKey(catalog_col);

    if (!this.force_table_partition.containsKey(table_key)) {
        this.force_table_partition.put(table_key, new ListOrderedSet<String>());
    }
    this.force_table_partition.get(table_key).add(column_key);
}
项目:sstore-soft    文件:DesignerHints.java   
public Collection<Column> getForcedTablePartitionCandidates(Table catalog_tbl) {
    final Database catalog_db = CatalogUtil.getDatabase(catalog_tbl);
    final String table_key = CatalogKey.createKey(catalog_tbl);
    ListOrderedSet<Column> ret = new ListOrderedSet<Column>();
    if (this.force_table_partition.containsKey(table_key)) {
        for (String column_key : this.force_table_partition.get(table_key)) {
            ret.add(CatalogKey.getFromKey(catalog_db, column_key, Column.class));
        } // FOR
    }
    return (ret);
}
项目:sstore-soft    文件:ConstraintPropagator.java   
protected Collection<VerticalPartitionColumn> getVerticalPartitionColumns(Table catalog_tbl) {
    Collection<VerticalPartitionColumn> vp_cols = new ListOrderedSet<VerticalPartitionColumn>();
    for (Collection<Column> cols : this.edge_cols_xref.values()) {
        for (Column catalog_col : cols) {
            if (catalog_col.getParent().equals(catalog_tbl) && catalog_col instanceof VerticalPartitionColumn) {
                vp_cols.add((VerticalPartitionColumn) catalog_col);
            }
        } // FOR
    } // FOR
    return (vp_cols);
}
项目:sstore-soft    文件:TestCollectionUtil.java   
/**
 * testPop
 */
@SuppressWarnings("unchecked")
public void testPop() {
    String expected[] = new String[11];
    DefaultRandomGenerator rng = new DefaultRandomGenerator();
    for (int i = 0; i < expected.length; i++) {
        expected[i] = rng.astring(1, 32);
    } // FOR

    Collection<String> collections[] = new Collection[] {
        CollectionUtil.addAll(new ListOrderedSet<String>(), expected),
        CollectionUtil.addAll(new HashSet<String>(), expected),
        CollectionUtil.addAll(new ArrayList<String>(), expected),
    };
    for (Collection<String> c : collections) {
        assertNotNull(c);
        assertEquals(c.getClass().getSimpleName(), expected.length, c.size());
        String pop = CollectionUtil.pop(c);
        assertNotNull(c.getClass().getSimpleName(), pop);
        assertEquals(c.getClass().getSimpleName(), expected.length-1, c.size());
        assertFalse(c.getClass().getSimpleName(), c.contains(pop));

        if (c instanceof List || c instanceof ListOrderedSet) {
            assertEquals(c.getClass().getSimpleName(), expected[0], pop);
        }
    } // FOR
}
项目:s-store    文件:PlanNodeUtil.java   
/**
 * @param node
 * @return
 */
public static Collection<Integer> getOutputColumnIdsForPlanNode(AbstractPlanNode node) {
    final Collection<Integer> planColumnIds = new ListOrderedSet<Integer>();

    // 2011-07-20: Using the AbstractExpressions is the more accurate way of
    // getting the
    // Columns referenced in the output
    // If this is Scan that has an inline Projection, grab those too
    if ((node instanceof AbstractScanPlanNode) && node.getInlinePlanNode(PlanNodeType.PROJECTION) != null) {
        ProjectionPlanNode prj_node = node.getInlinePlanNode(PlanNodeType.PROJECTION);
        planColumnIds.addAll(prj_node.getOutputColumnGUIDs());
        if (debug.val)
            LOG.debug(prj_node.getPlanNodeType() + ": " + planColumnIds);
    } else {
        planColumnIds.addAll(node.getOutputColumnGUIDs());
        if (debug.val)
            LOG.debug(node.getPlanNodeType() + ": " + planColumnIds);
    }

    // If this is an AggregatePlanNode, then we also need to include columns
    // computed in the aggregates
    if (node instanceof AggregatePlanNode) {
        AggregatePlanNode agg_node = (AggregatePlanNode) node;
        planColumnIds.addAll(agg_node.getAggregateColumnGuids());
        if (debug.val)
            LOG.debug(node.getPlanNodeType() + ": " + agg_node.getAggregateColumnGuids());
    }

    return (planColumnIds);
}
项目:s-store    文件:ClusterConfiguration.java   
public Collection<Integer> getPartitionIds(String host, int site) {
    Set<Integer> ids = new ListOrderedSet<Integer>();
    for (PartitionConfiguration pc : this.getPartitions(host, site)) {
        ids.add(pc.partition);
    } // FOR
    return (ids);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Returns all the columns for this table that have a foreign key dependency
 * on another table
 * 
 * @param catalog_tbl
 * @return
 */
public static Collection<Column> getForeignKeyDependents(Table catalog_tbl) {
    Set<Column> found = new ListOrderedSet<Column>();
    for (Column catalog_col : catalog_tbl.getColumns()) {
        assert (catalog_col != null);
        if (!catalog_col.getConstraints().isEmpty()) {
            // System.out.println(catalog_col + ": " +
            // CatalogUtil.getConstraints(catalog_col.getConstraints()));
            if (!CatalogUtil.findAll(CatalogUtil.getConstraints(catalog_col.getConstraints()), "type", ConstraintType.FOREIGN_KEY.getValue()).isEmpty()) {
                found.add(catalog_col);
            }
        }
    } // FOR
    return (found);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Returns all the tables access/modified in all the Statements for this
 * Procedure
 * 
 * @param catalog_proc
 * @return
 * @throws Exception
 */
public static Collection<Table> getReferencedTables(Procedure catalog_proc) throws Exception {
    final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_proc);
    Set<Table> ret = cache.PROCEDURE_TABLES.get(catalog_proc);
    if (ret == null) {
        Set<Table> tables = new ListOrderedSet<Table>();
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            tables.addAll(CatalogUtil.getReferencedTables(catalog_stmt));
        } // FOR
        ret = Collections.unmodifiableSet(tables);
        cache.PROCEDURE_TABLES.put(catalog_proc, ret);
    }
    return (ret);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Returns all the columns access/modified in all the Statements for this
 * Procedure
 * 
 * @param catalog_proc
 * @return
 * @throws Exception
 */
public static Collection<Column> getReferencedColumns(Procedure catalog_proc) throws Exception {
    final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_proc);
    Set<Column> ret = cache.PROCEDURE_COLUMNS.get(catalog_proc);
    if (ret == null) {
        Set<Column> columns = new ListOrderedSet<Column>();
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            columns.addAll(CatalogUtil.getReferencedColumns(catalog_stmt));
        } // FOR
        ret = Collections.unmodifiableSet(columns);
        cache.PROCEDURE_COLUMNS.put(catalog_proc, ret);
    }
    return (ret);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Returns all of the procedures that access/modify the given table
 * 
 * @param catalog_tbl
 * @return
 * @throws Exception
 */
public static Collection<Procedure> getReferencingProcedures(Table catalog_tbl) throws Exception {
    Set<Procedure> ret = new ListOrderedSet<Procedure>();
    Database catalog_db = CatalogUtil.getDatabase(catalog_tbl);
    for (Procedure catalog_proc : catalog_db.getProcedures()) {
        if (catalog_proc.getSystemproc())
            continue;
        if (CatalogUtil.getReferencedTables(catalog_proc).contains(catalog_tbl)) {
            ret.add(catalog_proc);
        }
    } // FOR
    return (ret);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Return all the Columns used in ORDER BY clauses for the given Statement
 * 
 * @param catalog_stmt
 * @return
 */
public static Collection<Column> getOrderByColumns(Statement catalog_stmt) {
    if (debug.val)
        LOG.debug("Extracting order-by columns from statement " + CatalogUtil.getDisplayName(catalog_stmt));

    final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_stmt);
    Set<Column> ret = cache.STATEMENT_ORDERBY_COLUMNS.get(catalog_stmt);
    if (ret == null) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
        ret = new ListOrderedSet<Column>();
        try {
            AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
            assert (root != null);
            PlannerContext context = PlannerContext.singleton();
            for (OrderByPlanNode node : PlanNodeUtil.getPlanNodes(root, OrderByPlanNode.class)) {
                for (Integer guid : node.getSortColumnGuids()) {
                    PlanColumn pcol = context.get(guid);
                    assert (pcol != null);
                    ret.addAll(ExpressionUtil.getReferencedColumns(catalog_db, pcol.getExpression()));
                } // FOR
            } // FOR
        } catch (Throwable ex) {
            throw new RuntimeException("Failed to retrieve ORDER BY columns for " + catalog_stmt.fullName());
        }
        cache.STATEMENT_ORDERBY_COLUMNS.put(catalog_stmt, ret);
    }
    return (ret);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Return all of the tables referenced in the given AbstractPlanNode
 * Non-recursive.
 * 
 * @param catalog_db
 * @param node
 * @return
 * @throws Exception
 */
public static Collection<Table> getReferencedTablesForPlanNode(final Database catalog_db,
                                                               final AbstractPlanNode node) {
    final Set<Table> ret = new ListOrderedSet<Table>();
    try {
        CatalogUtil.getReferencedTablesForPlanNode(catalog_db, node, ret);
    } catch (Exception ex) {
        throw new RuntimeException("Failed to get referenced tables for " + node, ex);
    }
    return (ret);
}
项目:s-store    文件:CatalogUtil.java   
/**
 * Return all of tables referenced in the PlanNode tree, regardless if they
 * are modified or not
 * 
 * @param catalog_db
 * @param root
 * @return
 */
public static Collection<Table> getReferencedTablesForTree(final Database catalog_db,
                                                           final AbstractPlanNode root) {
    final Set<Table> found = new ListOrderedSet<Table>();
    new PlanNodeTreeWalker(true) {
        @Override
        protected void callback(AbstractPlanNode element) {
            CatalogUtil.getReferencedTablesForPlanNode(catalog_db, element, found);
            return;
        }
    }.traverse(root);
    return (found);
}