List of usage examples for com.google.common.collect ImmutableMap size
int size();
From source file:com.google.devtools.build.java.bazel.JavaBuilderConfigGenerator.java
public static void main(String[] args) { try {//from www . j av a2s . c o m InputStream stream = System.in; if (args.length > 0) { stream = new FileInputStream(args[0]); } ImmutableMap<String, JavaToolchainData> data = JavaToolchainDataParser.parse(stream); if (data.size() != 1) { die(data.isEmpty() ? "No java_toolchain found!" : "Multiple java_toolchain found!"); } JavaToolchainData first = data.values().asList().get(0); String optsString = Joiner.on("\", \"").join(first.getJavacOptions()); System.out.println("package com.google.devtools.build.java.bazel;"); System.out.println("public class JavaBuilderJavacOpts {"); System.out.println("public static final String[] DEFAULT_JAVACOPTS = {\"" + optsString + "\"};"); System.out.println("}"); } catch (IOException e) { die("Cannot load input file: " + e.getMessage()); } }
From source file:com.facebook.buck.cxx.toolchain.HeaderSymlinkTreeWithModuleMap.java
static Optional<String> getModuleName(ImmutableMap<Path, SourcePath> links) { if (links.size() > 0) { return Optional.of(links.keySet().iterator().next().getName(0).toString()); } else {/*from w w w . j a va2s.c o m*/ return Optional.empty(); } }
From source file:org.apache.hadoop.yarn.nodelabels.NodeLabelTestBase.java
public static void assertMapEquals(Map<NodeId, Set<String>> expected, ImmutableMap<NodeId, Set<String>> actual) { Assert.assertEquals(expected.size(), actual.size()); for (NodeId k : expected.keySet()) { Assert.assertTrue(actual.containsKey(k)); assertCollectionEquals(expected.get(k), actual.get(k)); }//from ww w .j av a 2 s.c o m }
From source file:org.apache.hadoop.yarn.nodelabels.NodeLabelTestBase.java
public static void assertLabelInfoMapEquals(Map<NodeId, Set<NodeLabel>> expected, ImmutableMap<NodeId, Set<NodeLabel>> actual) { Assert.assertEquals(expected.size(), actual.size()); for (NodeId k : expected.keySet()) { Assert.assertTrue(actual.containsKey(k)); assertNLCollectionEquals(expected.get(k), actual.get(k)); }//w w w . ja v a 2s. c om }
From source file:org.apache.hadoop.yarn.nodelabels.NodeLabelTestBase.java
public static void assertLabelsToNodesEquals(Map<String, Set<NodeId>> expected, ImmutableMap<String, Set<NodeId>> actual) { Assert.assertEquals(expected.size(), actual.size()); for (String k : expected.keySet()) { Assert.assertTrue(actual.containsKey(k)); Set<NodeId> expectedS1 = new HashSet<>(expected.get(k)); Set<NodeId> actualS2 = new HashSet<>(actual.get(k)); Assert.assertEquals(expectedS1, actualS2); Assert.assertTrue(expectedS1.containsAll(actualS2)); }//from w ww . ja v a 2 s . c o m }
From source file:org.apache.hadoop.yarn.nodelabels.NodeLabelTestBase.java
public static void assertLabelsInfoToNodesEquals(Map<NodeLabel, Set<NodeId>> expected, ImmutableMap<NodeLabel, Set<NodeId>> actual) { Assert.assertEquals(expected.size(), actual.size()); for (NodeLabel k : expected.keySet()) { Assert.assertTrue(actual.containsKey(k)); Set<NodeId> expectedS1 = new HashSet<>(expected.get(k)); Set<NodeId> actualS2 = new HashSet<>(actual.get(k)); Assert.assertEquals(expectedS1, actualS2); Assert.assertTrue(expectedS1.containsAll(actualS2)); }/*from w ww. j av a 2 s. c o m*/ }
From source file:com.spectralogic.ds3autogen.test.helpers.RemoveDollarSignConverterHelper.java
/** * Checks if a Type Map generated by the createPopulatedMap function has * successfully changed all type names by removing the '$' symbol *//*from w w w.j a va 2 s .com*/ public static void checkAutoPopulatedMap(final ImmutableMap<String, Ds3Type> map) { assertThat(map.size(), is(2)); assertTrue(map.containsKey("com.test.package.Ds3Type_v1")); assertTrue(map.containsKey("com.test.package.Ds3Type_v2")); checkAutoPopulatedType(map.get("com.test.package.Ds3Type_v1"), "_v1"); checkAutoPopulatedType(map.get("com.test.package.Ds3Type_v2"), "_v2"); }
From source file:org.knime.ext.textprocessing.nodes.tokenization.TokenizerFactoryRegistry.java
/** * @return Returns m_tokenizerMap as a String array, so it can be used for the {@code ComboFieldEditor} in the * {@code TextprocessingPreferenceInitializer} class. * @since 3.3/*from ww w. ja v a 2 s .co m*/ */ public static String[][] getMapAsStringArray() { ImmutableMap<String, TokenizerFactory> map = getTokenizerFactoryMap(); String[][] array = new String[map.size()][2]; int counter = 0; for (ImmutableMap.Entry<String, TokenizerFactory> entry : map.entrySet()) { array[counter][0] = entry.getKey(); array[counter][1] = entry.getKey(); counter++; } return array; }
From source file:org.apache.hadoop.hive.ql.optimizer.calcite.translator.PlanModifierUtil.java
protected static void fixTopOBSchema(final RelNode rootRel, Pair<RelNode, RelNode> topSelparentPair, List<FieldSchema> resultSchema, boolean replaceProject) throws CalciteSemanticException { if (!(topSelparentPair.getKey() instanceof Sort) || !HiveCalciteUtil.orderRelNode(topSelparentPair.getKey())) { return;/*from www . j a v a 2 s . co m*/ } HiveSortLimit obRel = (HiveSortLimit) topSelparentPair.getKey(); Project obChild = (Project) topSelparentPair.getValue(); if (obChild.getRowType().getFieldCount() <= resultSchema.size()) { return; } RelDataType rt = obChild.getRowType(); @SuppressWarnings({ "unchecked", "rawtypes" }) Set<Integer> collationInputRefs = new HashSet(RelCollations.ordinals(obRel.getCollation())); ImmutableMap.Builder<Integer, RexNode> inputRefToCallMapBldr = ImmutableMap.builder(); for (int i = resultSchema.size(); i < rt.getFieldCount(); i++) { if (collationInputRefs.contains(i)) { RexNode obyExpr = obChild.getChildExps().get(i); if (obyExpr instanceof RexCall) { LOG.debug("Old RexCall : " + obyExpr); obyExpr = adjustOBSchema((RexCall) obyExpr, obChild, resultSchema); LOG.debug("New RexCall : " + obyExpr); } inputRefToCallMapBldr.put(i, obyExpr); } } ImmutableMap<Integer, RexNode> inputRefToCallMap = inputRefToCallMapBldr.build(); if ((obChild.getRowType().getFieldCount() - inputRefToCallMap.size()) != resultSchema.size()) { LOG.error(generateInvalidSchemaMessage(obChild, resultSchema, inputRefToCallMap.size())); throw new CalciteSemanticException("Result Schema didn't match Optimized Op Tree Schema"); } if (replaceProject) { // This removes order-by only expressions from the projections. HiveProject replacementProjectRel = HiveProject.create(obChild.getInput(), obChild.getChildExps().subList(0, resultSchema.size()), obChild.getRowType().getFieldNames().subList(0, resultSchema.size())); obRel.replaceInput(0, replacementProjectRel); } obRel.setInputRefToCallMap(inputRefToCallMap); }
From source file:ru.org.linux.spring.SearchController.java
private static Map<Integer, String> buildGroupFacet(Connection db, int sectionId, FacetField groupFacet) throws BadGroupException, SQLException { ImmutableMap.Builder<Integer, String> builder = ImmutableSortedMap.naturalOrder(); int totalCount = 0; for (FacetField.Count count : groupFacet.getValues()) { int groupId = Integer.parseInt(count.getName()); Group group = new Group(db, groupId); if (group.getSectionId() != sectionId) { continue; }/* w w w . ja va2 s .co m*/ String name = group.getTitle().toLowerCase(); builder.put(groupId, name + " (" + count.getCount() + ')'); totalCount += count.getCount(); } builder.put(0, "? (" + Integer.toString(totalCount) + ')'); ImmutableMap<Integer, String> r = builder.build(); if (r.size() <= 2) { return null; } else { return r; } }