Example usage for com.google.common.collect Table putAll

List of usage examples for com.google.common.collect Table putAll

Introduction

In this page you can find the example usage for com.google.common.collect Table putAll.

Prototype

void putAll(Table<? extends R, ? extends C, ? extends V> table);

Source Link

Document

Copies all mappings from the specified table to this table.

Usage

From source file:com.rackspacecloud.blueflood.io.datastax.DAbstractMetricIO.java

/**
 * Fetch values for a list of {@link com.rackspacecloud.blueflood.types.Locator}
 * from the specified column family and range.
 *
 * This is a base behavior for most rollup types. IO subclasses can override
 * this behavior as they see fit./*from w w w  . j ava 2 s  . co m*/
 *
 * @param locators
 * @param columnFamily
 * @param range
 * @return
 */
protected <T extends Object> Table<Locator, Long, T> getValuesForLocators(final List<Locator> locators,
        String columnFamily, Range range) {

    Table<Locator, Long, T> locatorTimestampRollup = HashBasedTable.create();

    Map<Locator, List<ResultSetFuture>> resultSetFuturesMap = selectForLocatorListAndRange(columnFamily,
            locators, range);

    for (Map.Entry<Locator, List<ResultSetFuture>> entry : resultSetFuturesMap.entrySet()) {
        Locator locator = entry.getKey();
        List<ResultSetFuture> futures = entry.getValue();

        Table<Locator, Long, T> result = toLocatorTimestampValue(futures, locator, columnFamily, range);
        locatorTimestampRollup.putAll(result);
    }
    return locatorTimestampRollup;
}

From source file:com.android.sdklib.devices.DeviceManager.java

/**
 * Returns the known {@link Device} list.
 *
 * @param deviceFilter A combination of the {@link DeviceFilter} constants
 *                     or the constant {@link DeviceManager#ALL_DEVICES}.
 * @return A copy of the list of {@link Device}s. Can be empty but not null.
 *//*from  w w w .j  a va 2s.com*/
@NonNull
public Collection<Device> getDevices(@NonNull EnumSet<DeviceFilter> deviceFilter) {
    initDevicesLists();
    Table<String, String, Device> devices = HashBasedTable.create();
    if (mUserDevices != null && (deviceFilter.contains(DeviceFilter.USER))) {
        devices.putAll(mUserDevices);
    }
    if (mDefaultDevices != null && (deviceFilter.contains(DeviceFilter.DEFAULT))) {
        devices.putAll(mDefaultDevices);
    }
    if (mVendorDevices != null && (deviceFilter.contains(DeviceFilter.VENDOR))) {
        devices.putAll(mVendorDevices);
    }
    if (mSysImgDevices != null && (deviceFilter.contains(DeviceFilter.SYSTEM_IMAGES))) {
        devices.putAll(mSysImgDevices);
    }
    return Collections.unmodifiableCollection(devices.values());
}

From source file:es.usc.citius.composit.core.composition.network.DirectedAcyclicSMN.java

private final MatchTable<E, T> computeLeveledMatch() {
    Table<E, E, T> table = HashBasedTable.create();
    for (int level = 0; level < layers.numberOfLevels(); level++) {
        Set<Operation<E>> ops = layers.getOperationsAtLevel(level);
        Set<Operation<E>> followingOps = layers.getOperationsAfterLevel(level);
        for (Operation<E> source : ops) {
            for (Operation<E> target : followingOps) {
                // Compute full match between these operations
                // matcher -> matched
                MatchTable<E, T> matchResult = setMatcher.fullMatch(source.getSignature().getOutputs(),
                        target.getSignature().getInputs());
                table.putAll(matchResult.getMatchTable());
            }//from   ww w .  j  ava2  s . co m
        }
    }

    return new MatchTable<E, T>(table);
}

From source file:org.splevo.vpm.analyzer.semantic.lucene.finder.SharedTermFinder.java

@Override
public Table<String, String, Set<String>> findSimilarEntries() {

    Table<String, String, Set<String>> sharedTermTable = HashBasedTable.create();

    try {/*from  w w w.  ja va 2 s.  c o m*/
        IndexSearcher indexSearcher = new IndexSearcher(reader);

        // Iterate over all documents (VariationPoints).
        for (int i = 0; i < reader.maxDoc(); i++) {
            Document referenceDoc = indexSearcher.doc(i);

            if (referenceDoc.getField(Indexer.INDEX_CONTENT) != null) {
                Table<String, String, Set<String>> sharedTerms = buildQueryAndExecuteSearch(indexSearcher,
                        Indexer.INDEX_CONTENT, i, referenceDoc);
                sharedTermTable.putAll(sharedTerms);
            }

            if (matchComments && referenceDoc.getField(Indexer.INDEX_COMMENT) != null) {
                Table<String, String, Set<String>> sharedTerms = buildQueryAndExecuteSearch(indexSearcher,
                        Indexer.INDEX_COMMENT, i, referenceDoc);
                sharedTermTable.putAll(sharedTerms);
            }
        }
    } catch (IOException e) {
        logger.error("Failure while searching Lucene index.", e);
    }

    return sharedTermTable;
}

From source file:com.przemo.conjunctions.Joiner.java

/**
 * Builds a joined table, taking the set of rows and array of columns to include
 * @param frows//from w ww.  j ava2  s  . com
 * @param columnJoinName
 * @param cl
 * @param tables
 * @param resultingColumns
 * @return 
 */
protected Table buildJoinedTable(Set<Object> frows, String columnJoinName, Map cl, Table[] tables,
        String[] resultingColumns) {
    Table tr = HashBasedTable.create();
    if (resultingColumns != null) {
        //create the tables based on a resulting rows set
        for (Object r : frows) {
            Table nt = HashBasedTable.create();
            nt.put(r, columnJoinName, cl.get(r));
            int ti = 0;
            for (Table ct : tables) {
                for (String col : resultingColumns) {
                    if (ct.containsColumn(col) && !col.equals(columnJoinName)) {
                        Object v = ct.get(r, col);
                        if (v != null) {
                            if (nt.get(r, col) != null) {
                                col += "_" + ti;
                            }
                            nt.put(r, col, v);
                        }
                    }
                }
                ti++;
            }
            tr.putAll(nt);
        }
    }
    return tr;
}