下面列出了com.google.common.collect.HashMultimap#get ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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...");
}
}
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;
}
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;
}
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;
}
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;
}
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);
}
}
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);
}
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;
}
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();
}
}
}
}
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();
}
}
}
}
}