Refine search
@Override public void appendLister(String name, AnalysisEventListener listener) { if (!listeners.containsKey(name)) { listeners.put(name, listener); } }
public synchronized <T extends Serializable> void updateTaskStatistics(MapRedStats mapRedStats, RunningJob rj, String taskId) throws IOException, JSONException { if (tasks.containsKey(taskId)) { tasks.get(taskId).updateMapRedStatsJson(mapRedStats, rj); } }
public void addAggregationExprsForClause(String clause, LinkedHashMap<String, ASTNode> aggregationTrees) { if (destToAggregationExprs.containsKey(clause)) { destToAggregationExprs.get(clause).putAll(aggregationTrees); } else { destToAggregationExprs.put(clause, aggregationTrees); } }
public String route(int jobId, List<String> addressList) { // cache clear if (System.currentTimeMillis() > CACHE_VALID_TIME) { jobLRUMap.clear(); CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24; } // init lru LinkedHashMap<String, String> lruItem = jobLRUMap.get(jobId); if (lruItem == null) { /** * LinkedHashMap * a、accessOrder:ture=访问顺序排序(get/put时排序);false=插入顺序排期; * b、removeEldestEntry:新增元素时将会调用,返回true时会删除最老元素;可封装LinkedHashMap并重写该方法,比如定义最大容量,超出是返回true即可实现固定长度的LRU算法; */ lruItem = new LinkedHashMap<String, String>(16, 0.75f, true); jobLRUMap.putIfAbsent(jobId, lruItem); } // put for (String address: addressList) { if (!lruItem.containsKey(address)) { lruItem.put(address, address); } } // load String eldestKey = lruItem.entrySet().iterator().next().getKey(); String eldestValue = lruItem.get(eldestKey); return eldestValue; }
@VisibleForTesting static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) { LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap(); // Search parent first, since it's the order ClassLoader#loadClass() uses. ClassLoader parent = classloader.getParent(); if (parent != null) { entries.putAll(getClassPathEntries(parent)); } for (URL url : getClassLoaderUrls(classloader)) { if (url.getProtocol().equals("file")) { File file = toFile(url); if (!entries.containsKey(file)) { entries.put(file, classloader); } } } return ImmutableMap.copyOf(entries); }
/** * Add the key and return it's index code. If the key already is present, the previous * index code is returned and no insertion is done. * * @param key key to add * @return index of the key */ public int addKey(String key) { if (key == null) { throw new NullPointerException(); } int nextIndex = keys.size(); //final Integer mapIndex = keys.putIfAbsent(key, nextIndex); final Integer mapIndex; if (!keys.containsKey(key)) { mapIndex = keys.put(key, nextIndex); } else { mapIndex = keys.get(key); } return mapIndex == null ? nextIndex : mapIndex; }
public Builder parameterizedWith( String name, TypeReference.Bound bound ) { if ( typeParameters == null ) { typeParameters = new LinkedHashMap<>(); } else if ( typeParameters.containsKey( name ) ) { throw new IllegalArgumentException( name + " defined twice" ); } typeParameters.put( name, bound ); return this; }
public void addAggregationExprsForClause(String clause, LinkedHashMap<String, ASTNode> aggregationTrees) { if (destToAggregationExprs.containsKey(clause)) { destToAggregationExprs.get(clause).putAll(aggregationTrees); } else { destToAggregationExprs.put(clause, aggregationTrees); } }
/** * * @param a * Statement within the region * * @return The PDGNode that contains that unit, if this unit is in this region. */ public PDGNode unit2PDGNode(Unit u) { if (this.m_unit2pdgnode.containsKey(u)) { return this.m_unit2pdgnode.get(u); } else { return null; } }
@VisibleForTesting static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) { LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap(); // Search parent first, since it's the order ClassLoader#loadClass() uses. ClassLoader parent = classloader.getParent(); if (parent != null) { entries.putAll(getClassPathEntries(parent)); } for (URL url : getClassLoaderUrls(classloader)) { if (url.getProtocol().equals("file")) { File file = toFile(url); if (!entries.containsKey(file)) { entries.put(file, classloader); } } } return ImmutableMap.copyOf(entries); }
private static void addToHistory(LinkedHashMap<String, Properties> propHistory, Map<String, Object> flatMap) { String id = String.valueOf(flatMap.get("pipelineid")); String key = (String) flatMap.get("key"); String value = (String) flatMap.get("value"); if (!propHistory.containsKey(id)) { propHistory.put(id, new Properties()); } propHistory.get(id).add(new Property(key, value)); }
private void putIfMissing(LinkedHashMap<String, String> map, String key, String value) { if (map.containsKey(key) == false) map.put(key, value); }
if (!targetPathToAliases.containsKey(pathToAdd)) { targetPathToAliases.put(pathToAdd, new ArrayList<String>()); targetPathToAliases.get(pathToAdd).add(sourceAlias);
@Override public Object optionValue(String name) { Option opt = new Option(name, null); if (declaredOptions.containsKey(opt)) { return declaredOptions.get(opt); } if (undeclaredOptions.containsKey(name)) { return undeclaredOptions.get(name); } return null; }
@VisibleForTesting static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) { LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap(); // Search parent first, since it's the order ClassLoader#loadClass() uses. ClassLoader parent = classloader.getParent(); if (parent != null) { entries.putAll(getClassPathEntries(parent)); } for (URL url : getClassLoaderUrls(classloader)) { if (url.getProtocol().equals("file")) { File file = toFile(url); if (!entries.containsKey(file)) { entries.put(file, classloader); } } } return ImmutableMap.copyOf(entries); }
public Collection<String> getUsedConversionClasses(Schema schema) { LinkedHashMap<String, Conversion<?>> classnameToConversion = new LinkedHashMap<>(); for (Conversion<?> conversion : specificData.getConversions()) { classnameToConversion.put(conversion.getConvertedType().getCanonicalName(), conversion); } Collection<String> result = new HashSet<>(); for (String className : getClassNamesOfPrimitiveFields(schema)) { if (classnameToConversion.containsKey(className)) { result.add(classnameToConversion.get(className).getClass().getCanonicalName()); } } return result; }
private void setType(final String type) { this.type = type; if (!TYPES.containsKey(type)) { TYPES.put(type, this); } }
if (!targetPathToAliases.containsKey(pathToAdd)) { targetPathToAliases.put(pathToAdd, new ArrayList<String>()); targetPathToAliases.get(pathToAdd).add(sourceAlias);
public String buildPartitionKey(List<String> partitionColumns) { StringBuilder partitionKey= new StringBuilder(); for (String pc : partitionColumns) { Object pcValue = null; if (data.containsKey(pc)) pcValue = data.get(pc); if (pcValue != null) partitionKey.append(pcValue.toString()); } return partitionKey.toString(); }
@VisibleForTesting static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) { LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap(); // Search parent first, since it's the order ClassLoader#loadClass() uses. ClassLoader parent = classloader.getParent(); if (parent != null) { entries.putAll(getClassPathEntries(parent)); } for (URL url : getClassLoaderUrls(classloader)) { if (url.getProtocol().equals("file")) { File file = toFile(url); if (!entries.containsKey(file)) { entries.put(file, classloader); } } } return ImmutableMap.copyOf(entries); }