Example usage for com.google.common.collect Multimap size

List of usage examples for com.google.common.collect Multimap size

Introduction

In this page you can find the example usage for com.google.common.collect Multimap size.

Prototype

int size();

Source Link

Document

Returns the number of key-value pairs in this multimap.

Usage

From source file:com.palantir.atlasdb.table.generation.ColumnValues.java

public static <T extends Persistable, V extends Persistable> Set<Cell> toCells(Multimap<T, V> map) {
    Set<Cell> ret = Sets.newHashSetWithExpectedSize(map.size());
    for (Entry<T, Collection<V>> e : map.asMap().entrySet()) {
        byte[] rowName = e.getKey().persistToBytes();
        for (Persistable val : e.getValue()) {
            ret.add(Cell.create(rowName, val.persistToBytes()));
        }//  ww  w  . j  a va  2s  . c  o m
    }
    return ret;
}

From source file:com.palantir.atlasdb.table.generation.ColumnValues.java

public static <T extends Persistable, V extends ColumnValue<?>> Map<Cell, byte[]> toCellValues(
        Multimap<T, V> map, long duration, TimeUnit durationTimeUnit) {
    Map<Cell, byte[]> ret = Maps.newHashMapWithExpectedSize(map.size());
    for (Entry<T, Collection<V>> e : map.asMap().entrySet()) {
        byte[] rowName = e.getKey().persistToBytes();
        for (V val : e.getValue()) {
            ret.put(Cell.create(rowName, val.persistColumnName(), duration, durationTimeUnit),
                    val.persistValue());
        }// ww w . j  av  a2  s .c o m
    }
    return ret;
}

From source file:org.agorava.core.utils.URLUtils.java

/**
 * @param parameters map to build the query string from
 * @return a query string corresponding to the map
 *//*from w  w w  .ja v  a  2  s.  c  om*/
private static String mapToQueryString(Multimap<String, Object> parameters) {
    if (parameters.size() == 0)
        return EMPTY_STRING;
    Multimap<String, String> urlEncodeMap = Multimaps.transformValues(parameters, new formUrlEncodeFunc());
    return queryMapJoiner.join(urlEncodeMap.entries());
}

From source file:com.zimbra.cs.mailbox.acl.AclPushTask.java

/**
 * @param mailboxIdUnderProcess/* ww  w. j  a  v  a  2 s  .  c  o  m*/
 * @param currentItemIdsProcessed
 * @throws ServiceException
 */
private static void deleteDbAclEntryForProcessedItems(Multimap<Integer, List<Integer>> currentItemIdsProcessed)
        throws ServiceException {
    if (currentItemIdsProcessed.size() != 0) {
        Collection<Entry<Integer, List<Integer>>> mailboxIds = currentItemIdsProcessed.entries();
        for (Entry<Integer, List<Integer>> entry : mailboxIds) {
            int mboxId = entry.getKey();
            List<Integer> itemIds = entry.getValue();
            for (int itemId : itemIds)
                DbPendingAclPush.deleteEntry(mboxId, itemId);
        }
    }
}

From source file:grakn.core.graql.gremlin.RelationTypeInference.java

private static Multimap<Variable, Type> getInstanceVarTypeMap(Set<Fragment> allFragments,
        Map<Variable, Type> labelVarTypeMap) {
    Multimap<Variable, Type> instanceVarTypeMap = HashMultimap.create();
    int oldSize;/*from  w w w . jav a  2 s. c om*/
    do {
        oldSize = instanceVarTypeMap.size();
        allFragments.stream().filter(fragment -> labelVarTypeMap.containsKey(fragment.start())) // restrict to types
                .filter(fragment -> fragment instanceof InIsaFragment || fragment instanceof InSubFragment) //
                .forEach(fragment -> instanceVarTypeMap.put(fragment.end(),
                        labelVarTypeMap.get(fragment.start())));
    } while (oldSize != instanceVarTypeMap.size());
    return instanceVarTypeMap;
}

From source file:org.eclipse.xtext.xbase.typesystem.util.Multimaps2.java

/**
 * Constructs an {@code ArrayListMultimap} with the same mappings as the specified multimap. It uses a linked map
 * internally..//from  w  w w .j a va  2  s . com
 * 
 * @param multimap
 *            the multimap whose contents are copied to this multimap
 */
public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap(Multimap<K, V> multimap) {
    int keySetSize = multimap.keySet().size();
    int expectedKeys = Math.max(keySetSize, 2);
    ListMultimap<K, V> result = newLinkedHashListMultimap(expectedKeys,
            Math.max(3, multimap.size() / expectedKeys));
    result.putAll(multimap);
    return result;
}

From source file:org.deephacks.confit.internal.jpa.JpaBean.java

/**
 * Finds the provided beans and initalize their properties and direct
 * references (but no further)./*from  w  w w  . j  a  v a  2s  .c o m*/
 */
public static List<Bean> findLazy(Set<BeanId> ids) {
    if (ids.size() == 0) {
        return new ArrayList<>();
    }
    JpaBeanQueryAssembler query = new JpaBeanQueryAssembler(ids);
    List<JpaProperty> allProperties = JpaProperty.findProperties(query.getIds());
    query.addProperties(allProperties);
    Multimap<BeanId, JpaRef> refs = JpaRef.findReferences(ids);
    if (refs.size() > 0) {
        query.addRefs(refs);
    }
    return query.assembleBeans();
}

From source file:org.deephacks.confit.internal.jpa.JpaBean.java

private static void collectRefs(Set<BeanId> predecessors, JpaBeanQueryAssembler query, int level) {
    if (--level < 0) {
        return;//from www  .jav  a2 s.c  o m
    }
    Multimap<BeanId, JpaRef> successors = JpaRef.findReferences(predecessors);
    if (successors.size() > 0) {
        query.addRefs(predecessors);
    }
    // only recurse successors we havent already visited to break circular references
    Set<BeanId> unvisitedSuccessors = new HashSet<>();
    for (JpaRef successor : successors.values()) {
        if (!query.contains(successor.getTarget())) {
            unvisitedSuccessors.add(successor.getTarget());
        }
    }
    if (unvisitedSuccessors.size() != 0) {
        // we have reached the end and found list successors
        collectRefs(unvisitedSuccessors, query, level);
    }
    query.addRefs(successors);
}

From source file:org.deephacks.tools4j.config.internal.core.jpa.JpaBean.java

private static void collectRefs(Set<BeanId> predecessors, JpaBeanQueryAssembler query) {
    Multimap<BeanId, JpaRef> successors = JpaRef.findReferences(predecessors);
    if (successors.size() > 0) {
        query.addRefs(predecessors);/*from   w w w .ja  v  a2 s.  co m*/
    }
    // only recurse successors we havent already visited to break circular references
    Set<BeanId> unvisitedSuccessors = new HashSet<BeanId>();
    for (JpaRef successor : successors.values()) {
        if (!query.contains(successor.getTarget())) {
            unvisitedSuccessors.add(successor.getTarget());
        }
    }
    if (unvisitedSuccessors.size() != 0) {
        // we have reached the end and found all successors
        collectRefs(unvisitedSuccessors, query);
    }
    query.addRefs(successors);
}

From source file:org.opendaylight.controller.config.yang.store.impl.ExtenderYangTracker.java

private static Set<URL> setFromMultimapValues(Multimap<Bundle, URL> bundlesToYangURLs) {
    Set<URL> urls = Sets.newHashSet(bundlesToYangURLs.values());
    Preconditions.checkState(bundlesToYangURLs.size() == urls.size());
    return urls;/*w  w  w .j ava  2  s .co  m*/
}