List of usage examples for java.util Map values
Collection<V> values();
From source file:org.psnively.scala.beans.ScalaBeanInfo.java
private static PropertyDescriptor[] initPropertyDescriptors(BeanInfo beanInfo) { Map<String, PropertyDescriptor> propertyDescriptors = new TreeMap<String, PropertyDescriptor>( new PropertyNameComparator()); for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { propertyDescriptors.put(pd.getName(), pd); }//from ww w.j a v a 2 s . com for (MethodDescriptor md : beanInfo.getMethodDescriptors()) { Method method = md.getMethod(); if (ReflectionUtils.isObjectMethod(method)) { continue; } if (isScalaSetter(method)) { addScalaSetter(propertyDescriptors, method); } else if (isScalaGetter(method)) { addScalaGetter(propertyDescriptors, method); } } return propertyDescriptors.values().toArray(new PropertyDescriptor[propertyDescriptors.size()]); }
From source file:com.espertech.esper.core.start.EPStatementStartMethodHelperSubselect.java
private static Pair<EventTableFactory, SubordTableLookupStrategyFactory> determineSubqueryIndexInternalFactory( ExprNode filterExpr, EventType viewableEventType, EventType[] outerEventTypes, StreamTypeService subselectTypeService, boolean fullTableScan, Set<String> optionalUniqueProps) throws ExprValidationException { // No filter expression means full table scan if ((filterExpr == null) || fullTableScan) { UnindexedEventTableFactory table = new UnindexedEventTableFactory(0); SubordFullTableScanLookupStrategyFactory strategy = new SubordFullTableScanLookupStrategyFactory(); return new Pair<EventTableFactory, SubordTableLookupStrategyFactory>(table, strategy); }//from w w w . j a v a 2 s. c o m // Build a list of streams and indexes SubordPropPlan joinPropDesc = QueryPlanIndexBuilder.getJoinProps(filterExpr, outerEventTypes.length, subselectTypeService.getEventTypes()); Map<String, SubordPropHashKey> hashKeys = joinPropDesc.getHashProps(); Map<String, SubordPropRangeKey> rangeKeys = joinPropDesc.getRangeProps(); List<SubordPropHashKey> hashKeyList = new ArrayList<SubordPropHashKey>(hashKeys.values()); List<SubordPropRangeKey> rangeKeyList = new ArrayList<SubordPropRangeKey>(rangeKeys.values()); boolean unique = false; // If this is a unique-view and there are unique criteria, use these if (optionalUniqueProps != null && !optionalUniqueProps.isEmpty()) { boolean found = true; for (String uniqueProp : optionalUniqueProps) { if (!hashKeys.containsKey(uniqueProp)) { found = false; break; } } if (found) { String[] hashKeysArray = hashKeys.keySet().toArray(new String[hashKeys.keySet().size()]); for (String hashKey : hashKeysArray) { if (!optionalUniqueProps.contains(hashKey)) { hashKeys.remove(hashKey); } } hashKeyList = new ArrayList<SubordPropHashKey>(hashKeys.values()); unique = true; rangeKeyList.clear(); rangeKeys.clear(); } } // build table (local table) EventTableFactory eventTable; CoercionDesc hashCoercionDesc; CoercionDesc rangeCoercionDesc; if (hashKeys.size() != 0 && rangeKeys.isEmpty()) { String indexedProps[] = hashKeys.keySet().toArray(new String[hashKeys.keySet().size()]); hashCoercionDesc = CoercionUtil.getCoercionTypesHash(viewableEventType, indexedProps, hashKeyList); rangeCoercionDesc = new CoercionDesc(false, null); if (hashKeys.size() == 1) { if (!hashCoercionDesc.isCoerce()) { eventTable = new PropertyIndexedEventTableSingleFactory(0, viewableEventType, indexedProps[0], unique, null); } else { eventTable = new PropertyIndexedEventTableSingleCoerceAddFactory(0, viewableEventType, indexedProps[0], hashCoercionDesc.getCoercionTypes()[0]); } } else { if (!hashCoercionDesc.isCoerce()) { eventTable = new PropertyIndexedEventTableFactory(0, viewableEventType, indexedProps, unique, null); } else { eventTable = new PropertyIndexedEventTableCoerceAddFactory(0, viewableEventType, indexedProps, hashCoercionDesc.getCoercionTypes()); } } } else if (hashKeys.isEmpty() && rangeKeys.isEmpty()) { eventTable = new UnindexedEventTableFactory(0); hashCoercionDesc = new CoercionDesc(false, null); rangeCoercionDesc = new CoercionDesc(false, null); } else if (hashKeys.isEmpty() && rangeKeys.size() == 1) { String indexedProp = rangeKeys.keySet().iterator().next(); CoercionDesc coercionRangeTypes = CoercionUtil.getCoercionTypesRange(viewableEventType, rangeKeys, outerEventTypes); if (!coercionRangeTypes.isCoerce()) { eventTable = new PropertySortedEventTableFactory(0, viewableEventType, indexedProp); } else { eventTable = new PropertySortedEventTableCoercedFactory(0, viewableEventType, indexedProp, coercionRangeTypes.getCoercionTypes()[0]); } hashCoercionDesc = new CoercionDesc(false, null); rangeCoercionDesc = coercionRangeTypes; } else { String[] indexedKeyProps = hashKeys.keySet().toArray(new String[hashKeys.keySet().size()]); Class[] coercionKeyTypes = SubordPropUtil.getCoercionTypes(hashKeys.values()); String[] indexedRangeProps = rangeKeys.keySet().toArray(new String[rangeKeys.keySet().size()]); CoercionDesc coercionRangeTypes = CoercionUtil.getCoercionTypesRange(viewableEventType, rangeKeys, outerEventTypes); eventTable = new PropertyCompositeEventTableFactory(0, viewableEventType, indexedKeyProps, coercionKeyTypes, indexedRangeProps, coercionRangeTypes.getCoercionTypes()); hashCoercionDesc = CoercionUtil.getCoercionTypesHash(viewableEventType, indexedKeyProps, hashKeyList); rangeCoercionDesc = coercionRangeTypes; } SubordTableLookupStrategyFactory subqTableLookupStrategyFactory = SubordinateTableLookupStrategyUtil .getLookupStrategy(outerEventTypes, hashKeyList, hashCoercionDesc, rangeKeyList, rangeCoercionDesc, false); return new Pair<EventTableFactory, SubordTableLookupStrategyFactory>(eventTable, subqTableLookupStrategyFactory); }
From source file:com.alibaba.jstorm.ui.UIUtils.java
public static List<TableData> getWorkerMetricsTable(Map<String, MetricInfo> metrics, Integer window, Map<String, String> paramMap) { List<TableData> ret = new ArrayList<TableData>(); TableData table = new TableData(); ret.add(table);// w w w . jav a 2 s . c o m List<String> headers = table.getHeaders(); List<Map<String, ColumnData>> lines = table.getLines(); table.setName("Worker " + UIDef.METRICS); List<String> keys = getSortedKeys(UIUtils.getKeys(metrics.values())); headers.add(UIDef.PORT); headers.add(MetricDef.NETTY); headers.addAll(keys); TreeMap<String, MetricInfo> tmpMap = new TreeMap<String, MetricInfo>(); tmpMap.putAll(metrics); Map<String, MetricInfo> showMap = new TreeMap<String, MetricInfo>(); long pos = JStormUtils.parseLong(paramMap.get(UIDef.POS), 0); long index = 0; for (Entry<String, MetricInfo> entry : tmpMap.entrySet()) { if (index < pos) { index++; } else if (pos <= index && index < pos + UIUtils.ONE_TABLE_PAGE_SIZE) { showMap.put(entry.getKey(), entry.getValue()); index++; } else { break; } } for (Entry<String, MetricInfo> entry : showMap.entrySet()) { Map<String, ColumnData> line = new HashMap<String, ColumnData>(); lines.add(line); String slot = entry.getKey(); MetricInfo metric = entry.getValue(); ColumnData slotColumn = new ColumnData(); slotColumn.addText(slot); line.put(UIDef.PORT, slotColumn); ColumnData nettyColumn = new ColumnData(); line.put(MetricDef.NETTY, nettyColumn); if (StringUtils.isBlank(paramMap.get(UIDef.TOPOLOGY))) { nettyColumn.addText(MetricDef.NETTY); } else { LinkData linkData = new LinkData(); nettyColumn.addLinkData(linkData); linkData.setUrl(UIDef.LINK_WINDOW_TABLE); linkData.setText(MetricDef.NETTY); linkData.addParam(UIDef.CLUSTER, paramMap.get(UIDef.CLUSTER)); linkData.addParam(UIDef.PAGE_TYPE, UIDef.PAGE_TYPE_NETTY); linkData.addParam(UIDef.TOPOLOGY, paramMap.get(UIDef.TOPOLOGY)); } for (String key : keys) { String value = UIUtils.getValue(metric, key, window); ColumnData valueColumn = new ColumnData(); valueColumn.addText(value); line.put(key, valueColumn); } } return ret; }
From source file:edu.umn.cs.spatialHadoop.core.SpatialSite.java
/** * Finds the partitioning info used in the given global index. If each cell * is represented as one partition, the MBRs of these partitions are returned. * If one cell is stored in multiple partitions (i.e., multiple files), * their MBRs are combined to produce one MBR for this cell. * @param gIndex/* w w w. jav a 2 s. c o m*/ * @return */ public static CellInfo[] cellsOf(GlobalIndex<Partition> gIndex) { // Find all partitions of the given file. If two partitions have the same // cell ID, it indicates that they are two blocks of the same cell. This // means they represent one partition and should be merged together. // They might have different MBRs as each block has its own MBR according // to the data stored in it. Map<Integer, CellInfo> cells = new HashMap<Integer, CellInfo>(); for (Partition p : gIndex) { CellInfo cell = cells.get(p.cellId); if (cell == null) { cells.put(p.cellId, cell = new CellInfo(p)); } else { cell.expand(p); } } return cells.values().toArray(new CellInfo[cells.size()]); }
From source file:com.streamsets.pipeline.lib.util.ProtobufTypeUtil.java
/** * Populates a map of protobuf extensions and map with the default values for * each message field from a map of file descriptors. * * @param fileDescriptorMap Map of file descriptors * @param typeToExtensionMap Map of extensions to populate * @param defaultValueMap Map of default values to populate *///from ww w . j a va 2s. c om public static void populateDefaultsAndExtensions(Map<String, Descriptors.FileDescriptor> fileDescriptorMap, Map<String, Set<Descriptors.FieldDescriptor>> typeToExtensionMap, Map<String, Object> defaultValueMap) { for (Descriptors.FileDescriptor f : fileDescriptorMap.values()) { // go over every file descriptor and look for extensions and default values of those extensions for (Descriptors.FieldDescriptor fieldDescriptor : f.getExtensions()) { String containingType = fieldDescriptor.getContainingType().getFullName(); Set<Descriptors.FieldDescriptor> fieldDescriptors = typeToExtensionMap.get(containingType); if (fieldDescriptors == null) { fieldDescriptors = new LinkedHashSet<>(); typeToExtensionMap.put(containingType, fieldDescriptors); } fieldDescriptors.add(fieldDescriptor); if (fieldDescriptor.hasDefaultValue()) { defaultValueMap.put(containingType + "." + fieldDescriptor.getName(), fieldDescriptor.getDefaultValue()); } } // go over messages within file descriptor and look for all fields and extensions and their defaults for (Descriptors.Descriptor d : f.getMessageTypes()) { addDefaultsAndExtensions(typeToExtensionMap, defaultValueMap, d); } } }
From source file:demo.RxJavaTransformer.java
private static List<EventDataCollection> reducebyCount(List<EventData> transformedData) { List<EventDataCollection> eventDataCollection = new ArrayList<EventDataCollection>(); Map<String, EventDataCollection> mapData = new HashMap<String, EventDataCollection>(); for (EventData event : transformedData) { String startEndId = event.getStartendId(); if (mapData.containsKey(startEndId)) { EventDataCollection edc = mapData.get(startEndId); edc.addEventData(event);/*from w w w . java 2 s .co m*/ } else { EventDataCollection edc = new EventDataCollection(startEndId); edc.addEventData(event); mapData.put(startEndId, edc); } } List<EventDataCollection> reducedEventDataCollection = new ArrayList<EventDataCollection>(mapData.values()); Collections.sort(reducedEventDataCollection); return reducedEventDataCollection; }
From source file:com.jim.im.utils.Assert.java
/** * Assert that an MAP has no null elements. Note: Does not complain if the MAP is empty! * <p/>//from w ww . ja va 2 s . c o m * * <pre class="code"> * Assert.noNullElements(MAP, "The MAP must have non-null * elements"); * </pre> * * @param map the MAP to check * @param message the exception message to use if the assertion fails * @throws IllegalStateException if the object array contains a <code>null</code> element */ public static void noNullElements(Map map, String message) { if (map == null) { return; } for (Object each : map.values()) { notNull(each, message); } }
From source file:org.wrml.runtime.format.application.vnd.wrml.design.schema.SchemaDesignFormatter.java
public static ObjectNode buildSchemaNode(final ObjectMapper objectMapper, final URI schemaUri, final SchemaLoader schemaLoader, final Set<URI> addedBaseSchemaUris) { final Prototype prototype = schemaLoader.getPrototype(schemaUri); if (prototype == null) { return null; }/*from w w w . j av a 2s . c om*/ final ObjectNode schemaNode = objectMapper.createObjectNode(); schemaNode.put(PropertyName.localName.name(), prototype.getUniqueName().getLocalName()); schemaNode.put(PropertyName.title.name(), prototype.getTitle()); schemaNode.put(PropertyName.uri.name(), schemaUri.toString()); schemaNode.put(PropertyName.version.name(), prototype.getVersion()); String titleSlotName = prototype.getTitleSlotName(); if (StringUtils.isNotBlank(titleSlotName)) { schemaNode.put(PropertyName.titleSlotName.name(), titleSlotName); } else { titleSlotName = getTitleSlotName(schemaUri, schemaLoader); if (StringUtils.isNotBlank(titleSlotName)) { schemaNode.put(PropertyName.titleSlotName.name(), titleSlotName); } } final Set<String> allSlotNames = prototype.getAllSlotNames(); if (allSlotNames != null && !allSlotNames.isEmpty()) { final ArrayNode propertyNamesNode = objectMapper.createArrayNode(); for (final String slotName : allSlotNames) { final ProtoSlot protoSlot = prototype.getProtoSlot(slotName); if (protoSlot instanceof LinkProtoSlot) { continue; } if (protoSlot.getDeclaringSchemaUri().equals(schemaUri)) { propertyNamesNode.add(slotName); } } if (propertyNamesNode.size() > 0) { schemaNode.put(PropertyName.propertyNames.name(), propertyNamesNode); } } final Set<String> keySlotNames = prototype.getDeclaredKeySlotNames(); if (keySlotNames != null && !keySlotNames.isEmpty()) { final ArrayNode keyPropertyNamesNode = objectMapper.createArrayNode(); for (final String keySlotName : keySlotNames) { keyPropertyNamesNode.add(keySlotName); } if (keyPropertyNamesNode.size() > 0) { schemaNode.put(PropertyName.keyPropertyNames.name(), keyPropertyNamesNode); } } final Set<String> allKeySlotNames = prototype.getAllKeySlotNames(); final ArrayNode allKeySlotNamesNode = objectMapper.createArrayNode(); schemaNode.put(PropertyName.allKeySlotNames.name(), allKeySlotNamesNode); for (final String keySlotName : allKeySlotNames) { allKeySlotNamesNode.add(keySlotName); } final Set<String> comparablePropertyNames = prototype.getComparableSlotNames(); if (comparablePropertyNames != null && !comparablePropertyNames.isEmpty()) { final ArrayNode comparablePropertyNamesNode = objectMapper.createArrayNode(); for (final String comparablePropertyName : comparablePropertyNames) { comparablePropertyNamesNode.add(comparablePropertyName); } if (comparablePropertyNamesNode.size() > 0) { schemaNode.put(PropertyName.comparablePropertyNames.name(), comparablePropertyNamesNode); } } final Map<URI, LinkProtoSlot> linkProtoSlots = prototype.getLinkProtoSlots(); if (linkProtoSlots != null && !linkProtoSlots.isEmpty()) { final ArrayNode linkNamesNode = objectMapper.createArrayNode(); for (final LinkProtoSlot linkProtoSlot : linkProtoSlots.values()) { if (linkProtoSlot.getDeclaringSchemaUri().equals(schemaUri)) { linkNamesNode.add(linkProtoSlot.getName()); } } if (linkNamesNode.size() > 0) { schemaNode.put(PropertyName.linkNames.name(), linkNamesNode); } } final Set<URI> declaredBaseSchemaUris = prototype.getDeclaredBaseSchemaUris(); if (declaredBaseSchemaUris != null && !declaredBaseSchemaUris.isEmpty() && addedBaseSchemaUris != null) { final ArrayNode baseSchemasNode = objectMapper.createArrayNode(); for (final URI baseSchemaUri : declaredBaseSchemaUris) { if (!addedBaseSchemaUris.contains(baseSchemaUri)) { final ObjectNode baseSchemaNode = buildSchemaNode(objectMapper, baseSchemaUri, schemaLoader, addedBaseSchemaUris); baseSchemasNode.add(baseSchemaNode); addedBaseSchemaUris.add(baseSchemaUri); } } if (baseSchemasNode.size() > 0) { schemaNode.put(PropertyName.baseSchemas.name(), baseSchemasNode); } } return schemaNode; }
From source file:com.amalto.core.metadata.ClassRepository.java
private static Method[] getMethods(Class clazz) { // TMDM-5851: Work around several issues in introspection (getDeclaredMethods() and getMethods() may return // inherited methods if returned type is a sub class of super class method). Map<String, Class<?>> superClassMethods = new HashMap<String, Class<?>>(); if (clazz.getSuperclass() != null) { for (Method method : clazz.getSuperclass().getMethods()) { superClassMethods.put(method.getName(), method.getReturnType()); }/*from ww w .j a v a2 s. c o m*/ } Map<String, Method> methods = new HashMap<String, Method>(); for (Method method : clazz.getDeclaredMethods()) { if (!(superClassMethods.containsKey(method.getName()) && superClassMethods.get(method.getName()).equals(method.getReturnType()))) { methods.put(method.getName(), method); } } Method[] allMethods = clazz.getMethods(); for (Method method : allMethods) { if (!methods.containsKey(method.getName())) { methods.put(method.getName(), method); } } Method[] classMethods = methods.values().toArray(new Method[methods.size()]); // TMDM-5483: getMethods() does not always return methods in same order: sort them to ensure fixed order. Arrays.sort(classMethods, new Comparator<Method>() { @Override public int compare(Method method1, Method method2) { return method1.getName().compareTo(method2.getName()); } }); return classMethods; }
From source file:com.microsoft.tfs.core.clients.framework.location.internal.LocationCacheManager.java
/** * Convert the specified ServiceDefinition HashMap to an array of * ServiceDefinitions.//from w ww. j a v a 2s . com * * @param servicesMap * The HashMap containing the ServiceDefions. * * @return An array containing each ServiceDefinition value from the map. */ private static ServiceDefinition[] serviceDefinitionMapToArray( final Map<String, Map<GUID, ServiceDefinition>> servicesMap) { final List<ServiceDefinition> list = new ArrayList<ServiceDefinition>(); for (final Map<GUID, ServiceDefinition> serviceDefinitionInstances : servicesMap.values()) { for (final ServiceDefinition serviceDefinition : serviceDefinitionInstances.values()) { list.add(serviceDefinition); } } return list.toArray(new ServiceDefinition[list.size()]); }