Example usage for java.util Map values

List of usage examples for java.util Map values

Introduction

In this page you can find the example usage for java.util Map values.

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:com.baidu.rigel.biplatform.tesseract.qsservice.query.QueryRequestBuilder.java

/**
 * @param questionModel//w ww  .  jav  a 2s. c om
 * @param dsInfo
 * @param cube
 * @param queryContext
 * @return
 */
public static QueryRequest buildQueryRequest(DataSourceInfo dsInfo, Cube cube, QueryContext queryContext,
        boolean useIndex, PageInfo pageInfo) {
    MiniCube miniCube = (MiniCube) cube;
    QueryRequest request = new QueryRequest();
    request.setCubeId(cube.getId());
    request.setDataSourceInfo(dsInfo);
    // ?cubeName?
    request.setCubeName(cube.getName());
    request.setFrom(new From(miniCube.getSource()));
    request.setUseIndex(useIndex);

    // 
    request.setSelect(buildSelectMeasure(queryContext.getQueryMeasures()));
    // ??selectgroup by
    Map<String, Expression> expressions = new HashMap<String, Expression>();
    buildSelectAndGroupBy(queryContext.getColumnMemberTrees(), request, expressions);
    buildSelectAndGroupBy(queryContext.getRowMemberTrees(), request, expressions);

    // filter?
    if (MapUtils.isNotEmpty(queryContext.getFilterMemberValues())) {
        queryContext.getFilterMemberValues().forEach((properties, values) -> {
            Expression expression = new Expression(properties);
            expression.getQueryValues().add(new QueryObject(null, values));
            request.getWhere().getAndList().add(expression);
        });
    }

    request.getWhere().getAndList().addAll(expressions.values());
    int start = 0;
    int size = -1;
    if (pageInfo != null) {
        start = pageInfo.getPageNo() * pageInfo.getPageSize();
        size = pageInfo.getPageSize();
    }
    request.setLimit(new Limit(start, size));
    return request;
}

From source file:org.zkoss.spring.security.SecurityUtil.java

private static void initializeIfRequired() {
    if (_applicationContext != null) {
        return;/*from  w ww  .  j a va 2  s  .com*/
    }

    _applicationContext = SpringUtil.getApplicationContext();

    Map map = new HashMap();
    ApplicationContext context = _applicationContext;

    while (context != null) {
        map.putAll(context.getBeansOfType(AclService.class));
        context = context.getParent();
    }

    if (map.size() != 1) {
        throw new UiException(
                "Found incorrect number of AclService instances in application context - you must have only have one!");
    }

    _aclService = (AclService) map.values().iterator().next();

    map = _applicationContext.getBeansOfType(SidRetrievalStrategy.class);

    if (map.size() == 0) {
        _sidRetrievalStrategy = new SidRetrievalStrategyImpl();
    } else if (map.size() == 1) {
        _sidRetrievalStrategy = (SidRetrievalStrategy) map.values().iterator().next();
    } else {
        throw new UiException("Found incorrect number of SidRetrievalStrategy instances in application "
                + "context - you must have only have one!");
    }

    map = _applicationContext.getBeansOfType(ObjectIdentityRetrievalStrategy.class);

    if (map.size() == 0) {
        _objectIdentityRetrievalStrategy = new ObjectIdentityRetrievalStrategyImpl();
    } else if (map.size() == 1) {
        _objectIdentityRetrievalStrategy = (ObjectIdentityRetrievalStrategy) map.values().iterator().next();
    } else {
        throw new UiException("Found incorrect number of ObjectIdentityRetrievalStrategy instances in "
                + "application context - you must have only have one!");
    }

    map = _applicationContext.getBeansOfType(PermissionFactory.class);

    if (map.size() == 0) {
        permissionFactory = new DefaultPermissionFactory();
    } else if (map.size() == 1) {
        permissionFactory = (PermissionFactory) map.values().iterator().next();
    } else {
        throw new UiException("Found incorrect number of PermissionFactory instances in "
                + "application context - you must have only have one!");
    }
}

From source file:gov.gtas.svc.util.TargetingResultCaseMgmtUtils.java

/**
 *
 * @param ctx//from  w ww . ja  va 2 s  . c  o m
 * @param res
 */
public static void updateRuleExecutionContext(RuleExecutionContext ctx, RuleServiceResult res) {
    logger.info("Entering updateRuleExecutionContext().");
    ctx.setRuleExecutionStatistics(res.getExecutionStatistics());
    final Map<String, TargetSummaryVo> hitSummaryMap = new HashMap<>();
    for (RuleHitDetail rhd : res.getResultList()) {
        String key = rhd.getFlightId() + "/" + rhd.getPassengerId();
        TargetSummaryVo hitSummmary = hitSummaryMap.get(key);
        if (hitSummmary == null) {
            hitSummmary = new TargetSummaryVo(rhd.getHitType(), rhd.getFlightId(), rhd.getPassengerType(),
                    rhd.getPassengerId(), rhd.getPassengerName());
            hitSummaryMap.put(key, hitSummmary);
        }
        hitSummmary.addHitDetail(new TargetDetailVo(rhd.getUdrRuleId(), rhd.getRuleId(), rhd.getHitType(),
                rhd.getTitle(), rhd.getHitReasons()));
    }
    ctx.setTargetingResult(hitSummaryMap.values());
    logger.info("Exiting updateRuleExecutionContext().");
}

From source file:cascading.flow.hadoop.util.HadoopUtil.java

public static void addComparators(Configuration conf, String property, Map<String, Fields> map,
        BaseFlowStep flowStep, Group group) {
    Iterator<Fields> fieldsIterator = map.values().iterator();

    if (!fieldsIterator.hasNext())
        return;/*from   w  ww .j  a  v  a2 s . c om*/

    Fields fields = fieldsIterator.next();

    if (fields.hasComparators()) {
        conf.set(property, pack(fields, conf));
        return;
    }

    // use resolved fields if there are no comparators.
    Set<Scope> previousScopes = flowStep.getPreviousScopes(group);

    fields = previousScopes.iterator().next().getOutValuesFields();

    if (fields.size() != 0) // allows fields.UNKNOWN to be used
        conf.setInt(property + ".size", fields.size());
}

From source file:com.microsoft.tfs.core.clients.favorites.IdentityFavoritesStore.java

/**
 * Updates/Adds supplied favorite Items/*from  w  w  w .  j  a va 2  s  .  co m*/
 */
private static void updateFavorites(final TeamFoundationIdentity identity, final String effectiveNamespace,
        final FavoriteItem[] items) {
    final Map<GUID, FavoriteItem> favorites = new HashMap<GUID, FavoriteItem>();
    for (final FavoriteItem item : getFavorites(identity)) {
        favorites.put(item.getID(), item);
    }

    for (final FavoriteItem favItem : items) {
        if (!GUID.EMPTY.equals(favItem.getParentID())) {
            if (!favorites.containsKey(favItem.getParentID())) {
                throw new FavoritesException(
                        Messages.getString("IdentityFavoritesStore.ParentFavoriteNotFound")); //$NON-NLS-1$
            }
        }

        for (final FavoriteItem f : favorites.values()) {
            if (f.getParentID().equals(favItem.getParentID())) {
                if (!f.getID().equals(favItem.getID())
                        && String.CASE_INSENSITIVE_ORDER.compare(f.getType() + "", favItem.getType() + "") == 0 //$NON-NLS-1$ //$NON-NLS-2$
                        && String.CASE_INSENSITIVE_ORDER.compare(f.getName() + "", favItem.getName() + "") == 0 //$NON-NLS-1$ //$NON-NLS-2$
                        && String.CASE_INSENSITIVE_ORDER.compare(f.getData() + "", favItem.getData() + "") == 0) //$NON-NLS-1$ //$NON-NLS-2$
                {
                    throw new DuplicateFavoritesException(
                            Messages.getString("IdentityFavoritesStore.FavoriteWithSameNameTypeDataExists"), //$NON-NLS-1$
                            favItem);
                }
            }
        }

        setViewProperty(identity, IdentityPropertyScope.LOCAL, effectiveNamespace,
                favItem.getID().getGUIDString(), favItem.serialize());
    }
}

From source file:io.hops.experiments.results.compiler.InterleavedBMResultsAggregator.java

public static void combineResults(Map<String, Map<Integer, InterleavedAggregate>> hdfsAllWorkLoads,
        Map<String, Map<Integer, InterleavedAggregate>> hopsfsAllWorkloas, String outpuFolder)
        throws IOException {

    String plot = "set terminal postscript eps enhanced color font \"Helvetica,18\"  #monochrome\n";
    plot += "set output '| ps2pdf - interleaved.pdf'\n";
    plot += "#set size 1,0.75 \n ";
    plot += "set ylabel \"ops/sec\" \n";
    plot += "set xlabel \"Number of Namenodes\" \n";
    plot += "set format y \"%.0s%c\"\n";
    plot += "plot ";

    for (String workload : hopsfsAllWorkloas.keySet()) {
        Map<Integer, InterleavedAggregate> hopsWorkloadResult = hopsfsAllWorkloas.get(workload);
        Map<Integer, InterleavedAggregate> hdfsWorkloadResult = hdfsAllWorkLoads.get(workload);

        if (hopsWorkloadResult == null) {
            System.out.println("No data for hopsfs for workload " + workload);
            return;
        }/*w  w w .  j  av a  2s. com*/

        double hdfsVal = 0;
        if (hdfsWorkloadResult != null) {
            if (hdfsWorkloadResult.keySet().size() > 1) {
                System.out.println("NN count for HDFS cannot be greater than 1");
                return;
            }

            if (hdfsWorkloadResult.keySet().size() == 1) {
                hdfsVal = ((InterleavedAggregate) hdfsWorkloadResult.values().toArray()[0]).getSpeed();
            }
        }

        if (hopsWorkloadResult.keySet().size() <= 0) {
            return;
        }

        plot += " '" + workload
                + "-interleaved.dat' using 2:xticlabels(1) not with lines, '' using 0:2:3:4:xticlabels(1) title \"HopsFS-"
                + workload + "\" with errorbars, " + hdfsVal + " title \"HDFS-" + workload + "\" \n";
        String data = "";
        SortedSet<Integer> sorted = new TreeSet<Integer>(); // Sort my number of NN
        sorted.addAll(hopsWorkloadResult.keySet());
        for (Integer nn : sorted) {
            InterleavedAggregate agg = hopsWorkloadResult.get(nn);
            data += CompileResults.format(nn + "") + CompileResults.format(agg.getSpeed() + "")
                    + CompileResults.format(agg.getMinSpeed() + "")
                    + CompileResults.format(agg.getMaxSpeed() + "") + "\n";
        }
        System.out.println(data);
        CompileResults.writeToFile(outpuFolder + "/" + workload + "-interleaved.dat", data, false);
    }

    System.out.println(plot);
    CompileResults.writeToFile(outpuFolder + "/interleaved.gnuplot", plot, false);
}

From source file:edu.common.dynamicextensions.xmi.XMIUtilities.java

/**
 * This method returns the UmlAttributes for the given Umlclass from XMI.
 * boolean includeInherited - Specifies whether inherited attributes should be included or not.
 * @param klass/*from   ww w .j  a v  a 2s  .c o m*/
 * @param includeInherited
 * @return
 */
public static Collection getAttributes(UmlClass klass, boolean includeInherited) {
    Collection atts = new ArrayList();
    if (includeInherited) {
        Map attsMap = new HashMap();
        UmlClass superClass = klass;
        do {
            for (Iterator i = superClass.getFeature().iterator(); i.hasNext();) {
                Object o = i.next();
                if (o instanceof Attribute) {
                    Attribute att = (Attribute) o;
                    if (attsMap.get(att.getName()) == null) {
                        attsMap.put(att.getName(), att);
                    }
                }
            }
            superClass = getSuperClass(superClass);
        } while (superClass != null);

        atts = attsMap.values();
    } else {
        for (Iterator i = klass.getFeature().iterator(); i.hasNext();) {
            Object o = i.next();
            if (o instanceof Attribute) {
                atts.add(o);
            }
        }
    }
    return atts;
}

From source file:com.pureinfo.srm.reports.table.MyTabeleDataHelper.java

/**
 * @param _sValuesCol//from  ww  w. jav a 2  s  .  c o  m
 * @param _sRow
 */
public static void calculateAndSetMapRow(Map _row, String[] _sValuesCol) {
    if (_row == null)
        return;
    int total = 0, cared = 0;
    for (int i = 0; i < _sValuesCol.length; i++) {
        Number num = (Number) _row.get(_sValuesCol[i]);
        if (num != null) {
            cared += num.intValue();
        }
    }
    for (Iterator iter = _row.values().iterator(); iter.hasNext();) {
        Number num = (Number) iter.next();
        if (num != null) {
            total += num.intValue();
        }
    }
    _row.put(OTHER, new Integer(total - cared));
    _row.put(TOTAL, new Integer(total));
}

From source file:org.kiji.rest.util.RowResourceUtil.java

/**
 * Returns a list of fully qualified KijiColumnNames to return to the client.
 *
 * @param tableLayout is the layout of the table from which the row is being fetched.
 *
 * @param columnsDef is the columns definition object being modified to be passed down to the
 *        KijiTableReader.// ww  w . j a va2 s  .c o  m
 * @param requestedColumns the list of user requested columns to display.
 * @return the list of KijiColumns that will ultimately be displayed. Since this method validates
 *         the list of incoming columns, it's not necessarily the case that what was specified in
 *         the requestedColumns string correspond exactly to the list of outgoing columns. In some
 *         cases it could be less (in case of an invalid column/qualifier) or more in case of
 *         specifying only the family but no qualifiers.
 */
public static List<KijiColumnName> addColumnDefs(KijiTableLayout tableLayout, ColumnsDef columnsDef,
        String requestedColumns) {

    List<KijiColumnName> returnCols = Lists.newArrayList();
    Collection<KijiColumnName> requestedColumnList = null;
    // Check for whether or not *all* columns were requested
    if (requestedColumns == null || requestedColumns.trim().equals("*")) {
        requestedColumnList = tableLayout.getColumnNames();
    } else {
        requestedColumnList = Lists.newArrayList();
        String[] requestedColumnArray = requestedColumns.split(",");
        for (String s : requestedColumnArray) {
            requestedColumnList.add(new KijiColumnName(s));
        }
    }

    Map<String, FamilyLayout> colMap = tableLayout.getFamilyMap();
    // Loop over the columns requested and validate that they exist and/or
    // expand qualifiers
    // in case only family names were specified (in the case of group type
    // families).
    for (KijiColumnName kijiColumn : requestedColumnList) {
        FamilyLayout layout = colMap.get(kijiColumn.getFamily());
        if (null != layout) {
            if (layout.isMapType()) {
                columnsDef.add(kijiColumn);
                returnCols.add(kijiColumn);
            } else {
                Map<String, ColumnLayout> groupColMap = layout.getColumnMap();
                if (kijiColumn.isFullyQualified()) {
                    ColumnLayout groupColLayout = groupColMap.get(kijiColumn.getQualifier());
                    if (null != groupColLayout) {
                        columnsDef.add(kijiColumn);
                        returnCols.add(kijiColumn);
                    }
                } else {
                    for (ColumnLayout c : groupColMap.values()) {
                        KijiColumnName fullyQualifiedGroupCol = new KijiColumnName(kijiColumn.getFamily(),
                                c.getName());
                        columnsDef.add(fullyQualifiedGroupCol);
                        returnCols.add(fullyQualifiedGroupCol);
                    }
                }
            }
        }
    }

    if (returnCols.isEmpty()) {
        throw new WebApplicationException(new IllegalArgumentException("No columns selected!"),
                Status.BAD_REQUEST);
    }

    return returnCols;
}

From source file:com.linkedin.pinot.core.query.aggregation.groupby.AggregationGroupByOperatorService.java

/**
 * Given a map from group by keys to results for multiple aggregation functions, trim the results to desired size and
 * put them into a list of group by results.
 *
 * @param aggrFuncList List of aggregation functions.
 * @param aggrGroupByResults Map from group by keys to result arrays.
 * @param trimmedGroupByResultList List of maps containing group by results returned.
 * @param numAggrFunctions Number of aggregation functions.
 * @param trimSize Desired trim size.//from   w w w. j av  a 2 s.c om
 */
@SuppressWarnings("unchecked")
private static void trimToSize(List<AggregationFunction> aggrFuncList,
        Map<String, Serializable[]> aggrGroupByResults,
        List<Map<String, Serializable>> trimmedGroupByResultList, int numAggrFunctions, int trimSize) {
    MinMaxPriorityQueue<ImmutablePair<Serializable, String>>[] heaps = new MinMaxPriorityQueue[numAggrFunctions];
    for (int i = 0; i < numAggrFunctions; i++) {
        boolean reverseOrder = aggrFuncList.get(i).getFunctionName().startsWith(MIN_PREFIX);
        heaps[i] = getMinMaxPriorityQueue(aggrGroupByResults.values().iterator().next()[i], trimSize,
                reverseOrder);
    }

    for (String key : aggrGroupByResults.keySet()) {
        Serializable[] results = aggrGroupByResults.get(key);
        for (int i = 0; i < numAggrFunctions; i++) {
            Serializable result = results[i];
            MinMaxPriorityQueue<ImmutablePair<Serializable, String>> heap = heaps[i];
            if (heap == null) {
                trimmedGroupByResultList.get(i).put(key, result);
            } else {
                heap.add(new ImmutablePair(result, key));
            }
        }
    }

    for (int i = 0; i < numAggrFunctions; i++) {
        MinMaxPriorityQueue<ImmutablePair<Serializable, String>> heap = heaps[i];
        ImmutablePair<Serializable, String> pair;
        if (heap != null) {
            while ((pair = heap.pollFirst()) != null) {
                trimmedGroupByResultList.get(i).put(pair.getRight(), pair.getLeft());
            }
        }
    }
}