Java Code Examples for com.google.common.collect.HashMultimap#get()

The following examples show how to use com.google.common.collect.HashMultimap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexInfo.java    From datawave with Apache License 2.0 6 votes vote down vote up
protected Set<IndexMatch> buildNodeList(HashMultimap<String,JexlNode> ids, IndexMatchType type, boolean allowsDelayed, List<JexlNode> delayedNodes) {
    Set<IndexMatch> matches = Sets.newHashSet();
    for (String uid : ids.keySet()) {
        
        Set<JexlNode> nodes = ids.get(uid);
        // make sure that we have nodes, otherwise we are pruned to nothing
        if (nodes.size() > 1 || (allowsDelayed && (nodes.size() + delayedNodes.size()) > 1)) {
            JexlNodeSet nodeSet = new JexlNodeSet();
            nodeSet.addAll(nodes);
            nodeSet.addAll(delayedNodes);
            
            IndexMatch currentMatch = new IndexMatch(Sets.newHashSet(nodeSet.getNodes()), uid, type);
            matches.add(currentMatch);
        }
    }
    return matches;
}
 
Example 2
Source File: EdgeQueryLogic.java    From datawave with Apache License 2.0 6 votes vote down vote up
void pruneAndSetPreFilterValues(HashMultimap<String,String> prefilters) {
    HashMultimap<String,String> newMap = HashMultimap.create();
    long count = 0;
    for (String field : prefilters.keySet()) {
        Set<String> values = prefilters.get(field);
        if (values == null) {
            continue;
        }
        if (values.contains(PRE_FILTER_DISABLE_KEYWORD)) {
            continue;
        }
        if (values.size() < 1) {
            continue;
        }
        newMap.putAll(field, values);
        count++;
    }
    if (count <= config.getMaxPrefilterValues()) {
        if (count > 0) {
            prefilterValues = newMap;
        }
    } else {
        log.warn("Prefilter count exceeded threshold, ignoring...");
    }
}
 
Example 3
Source File: ASMHelper.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static byte[] alterMethods(String name, byte[] bytes, HashMultimap<String, MethodAlterator> altercators) {
	if (altercators.containsKey(name)) {
		ClassNode cnode = createClassNode(bytes);

		for (MethodAlterator injector : altercators.get(name)) {
			MethodNode method = findMethod(injector.method, cnode);
			if (method == null) {
				throw new RuntimeException("Method not found: " + injector.method);
			}

			injector.alter(method);
		}

		bytes = createBytes(cnode, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
	}
	return bytes;
}
 
Example 4
Source File: ASMHelper.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static byte[] alterMethods(String name, byte[] bytes, HashMultimap<String, MethodAlterator> altercators) {
	if (altercators.containsKey(name)) {
		ClassNode cnode = createClassNode(bytes);

		for (MethodAlterator injector : altercators.get(name)) {
			MethodNode method = findMethod(injector.method, cnode);
			if (method == null) {
				throw new RuntimeException("Method not found: " + injector.method);
			}

			injector.alter(method);
		}

		bytes = createBytes(cnode, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
	}
	return bytes;
}
 
Example 5
Source File: ASMHelper.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static byte[] alterMethods(String name, byte[] bytes, HashMultimap<String, MethodAlterator> altercators) {
	if (altercators.containsKey(name)) {
		ClassNode cnode = createClassNode(bytes);

		for (MethodAlterator injector : altercators.get(name)) {
			MethodNode method = findMethod(injector.method, cnode);
			if (method == null) {
				throw new RuntimeException("Method not found: " + injector.method);
			}

			injector.alter(method);
		}

		bytes = createBytes(cnode, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
	}
	return bytes;
}
 
Example 6
Source File: CubingUtils.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static Map<TblColRef, Dictionary<String>> buildDictionary(final CubeInstance cubeInstance,
        Iterable<List<String>> recordList) throws IOException {
    final List<TblColRef> columnsNeedToBuildDictionary = cubeInstance.getDescriptor()
            .listDimensionColumnsExcludingDerived(true);
    final HashMap<Integer, TblColRef> tblColRefMap = Maps.newHashMap();
    int index = 0;
    for (TblColRef column : columnsNeedToBuildDictionary) {
        tblColRefMap.put(index++, column);
    }

    HashMap<TblColRef, Dictionary<String>> result = Maps.newHashMap();

    HashMultimap<TblColRef, String> valueMap = HashMultimap.create();
    for (List<String> row : recordList) {
        for (int i = 0; i < row.size(); i++) {
            String cell = row.get(i);
            if (tblColRefMap.containsKey(i)) {
                valueMap.put(tblColRefMap.get(i), cell);
            }
        }
    }
    for (TblColRef tblColRef : valueMap.keySet()) {
        Set<String> values = valueMap.get(tblColRef);
        Dictionary<String> dict = DictionaryGenerator.buildDictionary(tblColRef.getType(),
                new IterableDictionaryValueEnumerator(values));
        result.put(tblColRef, dict);
    }
    return result;
}
 
Example 7
Source File: MemPool.java    From snowblossom with Apache License 2.0 5 votes vote down vote up
private static void populateLevelMap(HashMap<ChainHash, Transaction> working_map, HashMultimap<ChainHash, ChainHash> depends_on_map, HashMap<ChainHash, Integer> level_map, ChainHash tx, int level)
{
  if (!working_map.containsKey(tx)) return;

  if (level_map.containsKey(tx))
  {
    if (level_map.get(tx) <= level) return; //already lower or same
  }
  level_map.put(tx, level);

  for (ChainHash sub : depends_on_map.get(tx))
  {
    populateLevelMap(working_map, depends_on_map, level_map, sub, level - 1);
  }
}
 
Example 8
Source File: FluidTracker.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public synchronized void addManaCraft(World world, BlockPos pos, FluidCraftInstance crafter) {
	int dim = world.provider.getDimension();
	HashMultimap<BlockPos, FluidCraftInstance> worldCrafters = fluidCrafters.get(dim);
	if (worldCrafters == null) {
		worldCrafters = HashMultimap.create();
		fluidCrafters.put(dim, worldCrafters);
	}
	Set<FluidCraftInstance> crafterList = worldCrafters.get(pos);
	for (FluidCraftInstance manaCrafter : crafterList)
		if (manaCrafter.equals(crafter))
			return;
	if (world.getBlockState(pos).getBlock() == crafter.getFluid().getBlock())
		worldCrafters.put(pos, crafter);
}
 
Example 9
Source File: EntityOptimizer.java    From rya with Apache License 2.0 5 votes vote down vote up
private String getHighestPriorityKey(HashMultimap<String, StatementPattern> varMap) {

            double tempPriority = -1;
            double priority = -Double.MAX_VALUE;
            String priorityKey = "";
            Set<StatementPattern> bin = null;

            Set<String> keys = varMap.keySet();

            for (String s : keys) {
                bin = varMap.get(s);
                tempPriority = bin.size();
                tempPriority *= getCardinality(bin);
                tempPriority *= getMinCardSp(bin);

                // weight starQuery where common Var is constant slightly more -- this factor is subject
                // to change
                if (VarNameUtils.isConstant(s)) {
                    tempPriority *= 10;
                }
                if (tempPriority > priority) {
                    priority = tempPriority;
                    priorityKey = s;
                }
            }
            return priorityKey;
        }
 
Example 10
Source File: ParcelableAnalysis.java    From parceler with Apache License 2.0 5 votes vote down vote up
private void validateSingleProperty(HashMultimap<String, ? extends ASTReference<? extends ASTBase>> input){
    for (String key : input.keys()) {
        if(input.get(key).size() != 1){
            for (ASTReference<? extends ASTBase> reference : input.get(key)) {
                validator.error("Too many properties defined under " + key)
                        .element(reference.getReference())
                        .build();
            }
        }
    }
}
 
Example 11
Source File: ParcelableAnalysis.java    From parceler with Apache License 2.0 4 votes vote down vote up
private void validateConverters(HashMultimap<String, ASTReference<ASTMethod>> input, HashMultimap<String, ASTReference<ASTField>> fieldReferences, Map<String, ASTReference<ASTParameter>> parameterReferences){
    Set<String> keys = new HashSet<String>();
    keys.addAll(input.keySet());
    keys.addAll(fieldReferences.keySet());
    keys.addAll(parameterReferences.keySet());

    for (String key : keys) {
        boolean found = false;
        if(input.containsKey(key)){
            for (ASTReference<ASTMethod> reference : input.get(key)) {
                if(reference.getConverter() != null){
                    if(found){
                        validator.error("Only one ParcelConverter may be declared per property")
                                .element(reference.getReference())
                                .build();
                    }
                    found = true;
                }
            }
        }
        if(fieldReferences.containsKey(key)){
            for (ASTReference<ASTField> fieldReference : fieldReferences.get(key)) {
                if(fieldReference.getConverter() != null){
                    if(found){
                        validator.error("Only one ParcelConverter may be declared per property")
                                .element(fieldReference.getReference())
                                .build();
                    }
                    found = true;
                }
            }
        }
        if(parameterReferences.containsKey(key)){
            ASTReference<ASTParameter> parameterReference = parameterReferences.get(key);
            if(parameterReference.getConverter() != null){
                if(found){
                    validator.error("Only one ParcelConverter may be declared per property")
                            .element(parameterReference.getReference())
                            .build();
                }
            }
        }
    }
}