當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeMultimap.create方法代碼示例

本文整理匯總了Java中com.google.common.collect.TreeMultimap.create方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeMultimap.create方法的具體用法?Java TreeMultimap.create怎麽用?Java TreeMultimap.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.TreeMultimap的用法示例。


在下文中一共展示了TreeMultimap.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
public ColumnFilter build()
{
    boolean isFetchAll = metadata != null;

    PartitionColumns queried = queriedBuilder == null ? null : queriedBuilder.build();
    // It's only ok to have queried == null in ColumnFilter if isFetchAll. So deal with the case of a selectionBuilder
    // with nothing selected (we can at least happen on some backward compatible queries - CASSANDRA-10471).
    if (!isFetchAll && queried == null)
        queried = PartitionColumns.NONE;

    SortedSetMultimap<ColumnIdentifier, ColumnSubselection> s = null;
    if (subSelections != null)
    {
        s = TreeMultimap.create(Comparator.<ColumnIdentifier>naturalOrder(), Comparator.<ColumnSubselection>naturalOrder());
        for (ColumnSubselection subSelection : subSelections)
            s.put(subSelection.column().name, subSelection);
    }

    return new ColumnFilter(isFetchAll, metadata, queried, s);
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:21,代碼來源:ColumnFilter.java

示例2: testSelfDataOrdered

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
/**
 * 測試 TreeMultimap,自定義數據結構的排序
 */
@Test
public void testSelfDataOrdered() {
    // 創建TreeMultimap,使用Ordering.natural()指定自然排序,Ordering.from指定排序規則
    // Order4TreeMultimap::compareTo 是lambda的簡寫形式
    TreeMultimap<String, Order4TreeMultimap> treeMultimap = TreeMultimap
            .create(Ordering.natural(),
                    Ordering.from(Order4TreeMultimap::compareTo));

    // 列表2
    treeMultimap.put("order_list1", new Order4TreeMultimap(1, "haha1"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(5, "haha2"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(9, "haha3"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(10, "haha3"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(22, "haha4"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(444, "haha5"));

    // 列表2
    treeMultimap.put("order_list2", new Order4TreeMultimap(1, "haha3"));
    treeMultimap.put("order_list2", new Order4TreeMultimap(3, "haha4"));
    treeMultimap.put("order_list3", new Order4TreeMultimap(2, "haha5"));

    // 輸出
    treeMultimap.forEach((key, order) -> System.out.println("key=" + key + ",order=" + order));
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:28,代碼來源:TreeMultimapDemo.java

示例3: identifyDuplicates

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc, mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:Loader.java

示例4: alternateNames

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private static TreeMultimap<Integer, AlternateName> alternateNames(String path) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    TreeMultimap<Integer, AlternateName> multimap = TreeMultimap.create();
    try (BufferedReader br = new BufferedReader(new FileReader(path))) {
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            List<String> list = Splitter.on('\t').splitToList(line);
            if ("fr".equals(list.get(2))) {
                AlternateName name = new AlternateName(list.get(3), "1".equals(list.get(4)), "1".equals(list.get(5)), "1".equals(list.get(6)), "1".equals(list.get(7)));
                multimap.put(parseInt(list.get(1)), name);
            }
        }
    }
    catch (IOException e) {
        throw propagate(e);
    }
    log.info("Alternate names loaded: {}s", stopwatch.elapsed(SECONDS));
    return multimap;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:19,代碼來源:Geonames.java

示例5: spFile

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private static Multimap<Long, SignPostPath> spFile(TomtomFolder folder) {
    File file = new File(folder.getFile("sp.dbf"));
    Multimap<Long, SignPostPath> result = TreeMultimap.create();
    if (!file.exists()) {
        return result;
    }
    log.info("Reading SP {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SignPostPath path = SignPostPath.fromRow(row);
            result.put(path.getId(), path);
        }
    }
    log.info("Loaded {} sign paths", result.size());
    return result;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:18,代碼來源:SignPosts.java

示例6: loadSpeedProfiles

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private static Map<Integer, PrecomputeSpeedProfile> loadSpeedProfiles(String filename) {
    File file = new File(filename);
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return newHashMap();
    }

    TreeMultimap<Integer, SpeedProfile> profilesMap = TreeMultimap.create();
    log.info("Reading HSPR {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SpeedProfile profile = new SpeedProfile(row.getInt("PROFILE_ID"), row.getInt("TIME_SLOT"), row.getDouble("REL_SP"));
            profilesMap.put(profile.getId(), profile);
        }
    }
    log.info("Loaded {} hspr", profilesMap.size());

    return profilesMap.asMap().entrySet().stream().collect(toMap(Entry::getKey, e -> precomputeProfile(e.getValue())));
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:21,代碼來源:HsprDbf.java

示例7: calcCoverage

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
/**
 * Generates a coverage multimap from split key to Regions that start with the
 * split key.
 * 
 * @return coverage multimap
 */
public Multimap<byte[], R> calcCoverage() {
  // This needs to be sorted to force the use of the comparator on the values,
  // otherwise byte array comparison isn't used
  Multimap<byte[], R> regions = TreeMultimap.create(BYTES_COMPARATOR,
      rangeCmp);

  // march through all splits from the start points
  for (Entry<byte[], Collection<R>> start : starts.asMap().entrySet()) {
    byte[] key = start.getKey();
    for (R r : start.getValue()) {
      regions.put(key, r);

      for (byte[] coveredSplit : splits.subSet(r.getStartKey(),
          specialEndKey(r))) {
        regions.put(coveredSplit, r);
      }
    }
  }
  return regions;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:27,代碼來源:RegionSplitCalculator.java

示例8: testCreate

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
/**
 * 基本數據類型的排序
 */
@Test
public void testCreate() {
    TreeMultimap<String, Integer> treeMultimap = TreeMultimap.create();
    treeMultimap.put("list_1", 1);
    treeMultimap.put("list_1", 1);
    treeMultimap.put("list_1", 2);
    treeMultimap.put("list_1", 9);
    treeMultimap.put("list_1", 7);
    treeMultimap.put("list_1", 3);

    treeMultimap.put("list_2", 9);
    treeMultimap.put("list_2", 7);

    // {list_1=[1, 2, 3, 7, 9], list_2=[7, 9]}
    System.out.println(treeMultimap);
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:20,代碼來源:TreeMultimapDemo.java

示例9: indexSolutionGeneratorsOld

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
/**
     * Repartition subsequent partitions while the predicate is true
     *
     * This unifies three common use cases:
     * - k = 0   : Do not repartition at all
     * - k = 1   : Repartition the next largest equivalence class
     * - k = null: Repartition all equivalence classes
     *
     */
//    public static <N, M> Entry<? extends Collection<M>, ? extends Collection<M>>
//        nextEquivClassRepartitionK(TreeMultimap<K, V> equivClasses, BiPredicate<Integer, Entry<? extends Collection<M>, ? extends Collection<M>>>) {
//        return null;
//    }
//


    public static <S> TreeMultimap<Long, Problem<S>> indexSolutionGeneratorsOld(Collection<Problem<S>> solGens) {
        TreeMultimap<Long, Problem<S>> result = TreeMultimap.create();

        for(Problem<S> solutionGenerator : solGens) {
            long size = solutionGenerator.getEstimatedCost();
            result.put(size, solutionGenerator);
        }

        return result;
    }
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:27,代碼來源:IsoUtils.java

示例10: decodeRecords

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
/**
 * Decodes a list of MX records into a tree map, ranking them automatically.
 *
 * @param records The list of MX records.
 * @return The tree map containing ranked MX records.
 */
private TreeMultimap<Integer, String> decodeRecords(List<Record> records) {
    TreeMultimap<Integer, String> recordMap = TreeMultimap.create(Ordering.natural(), Ordering.natural());

    records.forEach(record -> {
        String[] split = record.rdataToString().split(" ");

        if (split.length >= 2) {

            try {
                int rank = Integer.parseInt(split[0]);
                String domain = split[1];

                recordMap.put(rank, domain);

            } catch (NumberFormatException ex) {
                ex.printStackTrace();
            }

        }
    });

    return recordMap;
}
 
開發者ID:stevesoltys,項目名稱:carrier,代碼行數:30,代碼來源:MailResolverService.java

示例11: getDomainApplicationMap

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
/** Return a map of all fully-qualified domain names mapped to the applications for that name. */
private static Multimap<String, DomainApplication> getDomainApplicationMap(final String tld) {
  DateTime now = DateTime.now(UTC);
  Multimap<String, DomainApplication> domainApplicationMap =
      TreeMultimap.create(Ordering.natural(), comparing(DomainApplication::getForeignKey));
  Iterable<DomainApplication> domainApplications =
      ofy().load().type(DomainApplication.class).filter("tld", tld);
  for (DomainApplication domainApplication : domainApplications) {
    // Ignore deleted and rejected applications. They aren't under consideration.
    ApplicationStatus applicationStatus = domainApplication.getApplicationStatus();
    DateTime deletionTime = domainApplication.getDeletionTime();
    if (applicationStatus == REJECTED || isAtOrAfter(now, deletionTime)) {
      continue;
    }
    boolean result = domainApplicationMap.put(
        domainApplication.getFullyQualifiedDomainName(), domainApplication);
    checkState(result, "Domain application not added to map: %s", domainApplication);
  }
  return domainApplicationMap;
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:21,代碼來源:GenerateAuctionDataCommand.java

示例12: build

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private IndexToIndexMultiMap build() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < DOCS; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.BitSetIndexToIndexMultiMap(
                    elements.asMap().values(),
                    DOCS);

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    assertEquals(
            V1DatabaseFormat.MultiMapType.LONG_ARRAY_BIT_SET_BASED.getCode(),
            buf.getInt());

    final IndexToIndexMultiMap result =
            BitSetIndexToIndexMultiMap.from(buf);

    assertEquals(DOCS / 2, result.getKeysCount());

    return result;
}
 
開發者ID:yandex,項目名稱:yoctodb,代碼行數:27,代碼來源:BitSetIndexToIndexMultiMapTest.java

示例13: buildBitSet

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
@Test
public void buildBitSet() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < DOCS; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.BitSetIndexToIndexMultiMap(
                    elements.asMap().values(),
                    DOCS);

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    final IndexToIndexMultiMap result =
            IndexToIndexMultiMapReader.from(buf);

    assertTrue(result instanceof BitSetIndexToIndexMultiMap);
}
 
開發者ID:yandex,項目名稱:yoctodb,代碼行數:22,代碼來源:IndexToIndexMultiMapReaderTest.java

示例14: build

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private IndexToIndexMultiMap build() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < VALUES; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.IntIndexToIndexMultiMap(
                    elements.asMap().values());

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    assertEquals(
            V1DatabaseFormat.MultiMapType.LIST_BASED.getCode(),
            buf.getInt());

    final IndexToIndexMultiMap result =
            IntIndexToIndexMultiMap.from(buf);

    assertEquals(VALUES / 2, result.getKeysCount());

    return result;
}
 
開發者ID:yandex,項目名稱:yoctodb,代碼行數:26,代碼來源:IntIndexToIndexMultiMapTest.java

示例15: prepareData

import com.google.common.collect.TreeMultimap; //導入方法依賴的package包/類
private Buffer prepareData(
        final int keys,
        final int values) throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < keys; i++) {
        //same elements
        elements.put(i, (keys - i) % values);
        elements.put(i, (keys - i) % values);
        elements.put(i, (keys - i) % values);
        elements.put(i, (keys - i) % values);

        elements.put(i, (2 * keys - i) % values);
        elements.put(i, (3 * keys - i) % values);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap indexToIndexMultiMap =
            new com.yandex.yoctodb.util.mutable.impl.IntIndexToIndexMultiMap(
                    elements.asMap().values());

    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    indexToIndexMultiMap.writeTo(os);
    Assert.assertEquals(os.size(), indexToIndexMultiMap.getSizeInBytes());
    return Buffer.from(os.toByteArray());
}
 
開發者ID:yandex,項目名稱:yoctodb,代碼行數:24,代碼來源:IntIndexToIndexMultiMapTest.java


注:本文中的com.google.common.collect.TreeMultimap.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。