Java Code Examples for com.google.common.collect.TreeMultimap#create()

The following examples show how to use com.google.common.collect.TreeMultimap#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Intersection.java    From datawave with Apache License 2.0 6 votes vote down vote up
static TreeMultimap<String,IndexStream> nextAll(String key, Collection<IndexStream> streams) {
    TreeMultimap<String,IndexStream> newChildren = TreeMultimap.create(Ordering.natural(), Ordering.arbitrary());
    for (IndexStream itr : streams) {
        if (!isDay(key) && isDay(key(itr.peek()))) {
            newChildren.put(itr.peek().first(), itr);
        } else {
            itr.next();
            if (itr.hasNext()) {
                newChildren.put(itr.peek().first(), itr);
            } else {
                return TreeMultimap.create(Ordering.natural(), Ordering.arbitrary());
            }
        }
    }
    return newChildren;
}
 
Example 2
Source File: AggregateMultiProjectTaskReportModel.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void build() {
    groups = TreeMultimap.create(new Comparator<String>() {
        public int compare(String string1, String string2) {
            return string1.compareToIgnoreCase(string2);
        }
    }, new Comparator<TaskDetails>() {
        public int compare(TaskDetails task1, TaskDetails task2) {
            return task1.getPath().compareTo(task2.getPath());
        }
    });
    for (TaskReportModel project : projects) {
        for (String group : project.getGroups()) {
            for (final TaskDetails task : project.getTasksForGroup(group)) {
                groups.put(group, mergeTasksWithSameName ? new MergedTaskDetails(task) : task);
            }
        }
    }
}
 
Example 3
Source File: FileParseStatusAnswerer.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public TableAnswerElement answer(NetworkSnapshot snapshot) {
  ParseVendorConfigurationAnswerElement pvcae =
      _batfish.loadParseVendorConfigurationAnswerElement(snapshot);
  ConvertConfigurationAnswerElement ccae =
      _batfish.loadConvertConfigurationAnswerElementOrReparse(snapshot);

  Map<String, ParseStatus> statusMap = pvcae.getParseStatus();
  Rows rows = new Rows();
  Multimap<String, String> fileToConvertedHosts = ccae.getFileMap();
  Multimap<String, String> fileToHost = TreeMultimap.create();
  pvcae
      .getFileMap()
      .forEach(
          (hostname, filename) -> {
            fileToHost.put(filename, hostname);
            fileToHost.putAll(filename, fileToConvertedHosts.get(filename));
          });

  statusMap.forEach(
      (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename))));

  TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA);
  answerElement.postProcessAnswer(_question, rows.getData());
  return answerElement;
}
 
Example 4
Source File: MethodScopeExtractor.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Multimap<Scope, String> getScopeSnippets(final ASTNode node,
		final boolean methodAsRoots) {
	final ScopeFinder scopeFinder = new ScopeFinder(methodAsRoots);
	node.accept(scopeFinder);

	final Multimap<Scope, String> scopes = TreeMultimap.create();
	for (final Entry<ASTNode, Method> method : scopeFinder.methods
			.entries()) {
		scopes.put(new Scope(method.getKey().toString(),
				method.getValue().type, METHOD_CALL, 0, 0), method
				.getValue().name);
	}

	return scopes;

}
 
Example 5
Source File: TypenameScopeExtractor.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
private Multimap<Scope, String> getClassnames(final ASTNode node) {
	final ClassnameFinder cf = new ClassnameFinder(methodsAsRoots);
	node.accept(cf);

	final Multimap<Scope, String> classnames = TreeMultimap.create();

	for (final Entry<ASTNode, String> classname : cf.types.entries()) {
		final ASTNode parentNode = classname.getKey();
		final Scope sc = new Scope(
				classname.getKey().toString(),
				parentNode.getNodeType() == ASTNode.METHOD_DECLARATION ? ScopeType.SCOPE_METHOD
						: ScopeType.SCOPE_CLASS, TYPENAME,
				parentNode.getNodeType(), -1);
		classnames.put(sc, classname.getValue());
	}
	return classnames;
}
 
Example 6
Source File: FuzzyFieldProcessor.java    From datacollector with Apache License 2.0 6 votes vote down vote up
private TreeMultimap<String, MatchCandidate> findCandidatesFor(Map<String, Field> fields) throws StageException {
  TreeMultimap<String, MatchCandidate> candidates = TreeMultimap.create();

  for (String outputField : outputFieldNames) {
    for (Map.Entry<String, Field> entry : fields.entrySet()) {
      String fieldPath = entry.getKey();
      Field field = entry.getValue();
      int score = FuzzyMatch.getRatio(outputField, fieldPath, true);
      if (score >= matchThreshold) {
        if (greaterScore(candidates.get(outputField), score) || allCandidates) {
          if (!allCandidates) {
            // If not storing all candidates we must clear any existing candidates for this key
            // since a Multimap won't replace multiple values for a key.
            candidates.get(outputField).clear();
          }
          candidates.put(outputField, new MatchCandidate(outputField, score, fieldPath, field));
        }
      }
    }
  }

  return candidates;
}
 
Example 7
Source File: BEDFileLoader.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
public static SortedSetMultimap<String, GenomeRegion> fromBedFile(@NotNull String bedFile) throws IOException {
    final SortedSetMultimap<String, GenomeRegion> regionMap = TreeMultimap.create();

    String prevChromosome = null;
    GenomeRegion prevRegion = null;
    try (final AbstractFeatureReader<BEDFeature, LineIterator> reader = getFeatureReader(bedFile, new BEDCodec(), false)) {
        for (final BEDFeature bedFeature : reader.iterator()) {
            final String chromosome = bedFeature.getContig();
            final long start = bedFeature.getStart();
            final long end = bedFeature.getEnd();

            if (end < start) {
                LOGGER.warn("Invalid genome region found in chromosome {}: start={}, end={}", chromosome, start, end);
            } else {
                final GenomeRegion region = GenomeRegions.create(chromosome, start, end);
                if (prevRegion != null && chromosome.equals(prevChromosome) && prevRegion.end() >= start) {
                    LOGGER.warn("BED file is not sorted, please fix! Current={}, Previous={}", region, prevRegion);
                } else {
                    regionMap.put(chromosome, region);
                    prevChromosome = chromosome;
                    prevRegion = region;
                }
            }
        }
    }

    return regionMap;
}
 
Example 8
Source File: AbstractPlayerGamesTest.java    From codenjoy with GNU General Public License v3.0 5 votes vote down vote up
public Map<Integer, Collection<String>> getRooms() {
    Multimap<Integer, String> result = TreeMultimap.create();

    for (PlayerGame playerGame : playerGames) {
        int index = fields.indexOf(playerGame.getField());
        String name = playerGame.getPlayer().getId();

        result.get(index).add(name);
    }
    return result.asMap();
}
 
Example 9
Source File: HmfGenePanelSupplier.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
private static SortedSetMultimap<String, HmfTranscriptRegion> toSortedMap(@NotNull List<HmfTranscriptRegion> regions) {
    SortedSetMultimap<String, HmfTranscriptRegion> regionMap = TreeMultimap.create();
    for (HmfTranscriptRegion region : regions) {
        regionMap.put(region.chromosome(), region);
    }

    return regionMap;
}
 
Example 10
Source File: AllScopeExtractor.java    From api-mining with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<Scope, String> getFromFile(final File file)
		throws IOException {
	final Multimap<Scope, String> scopes = TreeMultimap.create();
	for (final IScopeExtractor extractor : allExtractors) {
		scopes.putAll(extractor.getFromFile(file));
	}
	return scopes;
}
 
Example 11
Source File: NegationFilterTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmpty() throws Throwable {
    List<String> filterSet1 = Lists.newArrayList("a", "b");
    Itr<String> f1 = new Itr<>(filterSet1);
    List<String> filterSet2 = Lists.newArrayList("a", "b", "c", "d", "e", "f");
    Itr<String> f2 = new Itr<>(filterSet2);
    TreeMultimap<String,NestedIterator<String>> mmap = TreeMultimap.create(Util.keyComparator(), Util.hashComparator());
    mmap.put(f1.next(), f1);
    mmap.put(f2.next(), f2);
    
    assertTrue(NegationFilter.isFiltered("c", mmap, Util.keyTransformer()));
    assertEquals(1, mmap.keySet().size());
    assertEquals("c", mmap.keySet().iterator().next());
    assertEquals(1, mmap.values().size());
}
 
Example 12
Source File: Transaction.java    From glowroot with Apache License 2.0 5 votes vote down vote up
public SetMultimap<String, String> getAttributes() {
    synchronized (attributesLock) {
        if (attributes == null) {
            return ImmutableSetMultimap.of();
        }
        SetMultimap<String, String> orderedAttributes = TreeMultimap.create();
        orderedAttributes.putAll(attributes);
        return orderedAttributes;
    }
}
 
Example 13
Source File: GuavaTreeMultimapTest.java    From java_in_examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    String INPUT_TEXT = "Hello World! Hello All! Hi World!";
    // Разберем текст на слова и индексы
    List<String> words = Arrays.asList(INPUT_TEXT.split(" "));
    // Создаем Multimap
    Multimap<String, Integer> multiMap = TreeMultimap.create();

    // Заполним Multimap
    int i = 0;
    for(String word: words) {
        multiMap.put(word, i);
        i++;
    }

    // Выводим все вхождения слов в текст
    System.out.println(multiMap); // напечатает {Hello=[0, 2], World!=[1, 5], All!=[3], Hi=[4]}-в натуральном порядке
    // Выводим все уникальные слова
    System.out.println(multiMap.keySet());    // напечатает [Hello, World!, All!, Hi]- в натуральном порядке

    // Выводим все индексы вхождения слова в текст
    System.out.println("Hello = " + multiMap.get("Hello"));    // напечатает [0, 2]
    System.out.println("World = " + multiMap.get("World!"));    // напечатает [1, 5]
    System.out.println("All = " + multiMap.get("All!"));    // напечатает [3]
    System.out.println("Hi = " + multiMap.get("Hi"));    // напечатает [4]
    System.out.println("Empty = " + multiMap.get("Empty"));    // напечатает []

    // Выводим общее количества всех слов в тексте
    System.out.println(multiMap.size());    //напечатает 6

    // Выводим общее количество всех уникальных слов
    System.out.println(multiMap.keySet().size());    //напечатает 4
}
 
Example 14
Source File: SortUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static <T extends Comparable, E extends Comparable> Iterator<T> extractAndSort(Iterator<T> input, Function<T, E> extractor) {
    TreeMultimap<E, T> reorgnized = TreeMultimap.create();
    while (input.hasNext()) {
        T t = input.next();
        E e = extractor.apply(t);
        reorgnized.put(e, t);
    }
    return reorgnized.values().iterator();
}
 
Example 15
Source File: MemPool.java    From snowblossom with Apache License 2.0 4 votes vote down vote up
public synchronized List<Transaction> getTransactionsForBlock(ChainHash last_utxo, int max_size)
{
  List<Transaction> block_list = new ArrayList<Transaction>();
  Set<ChainHash> included_txs = new HashSet<>();


  if (!last_utxo.equals(utxo_for_pri_map))
  {
    rebuildPriorityMap(last_utxo);
  }

  int size = 0;
  int low_fee_size = 0;


  TreeMultimap<Double, TXCluster> priority_map_copy = TreeMultimap.<Double, TXCluster>create();
  priority_map_copy.putAll(priority_map);

  while (priority_map_copy.size() > 0)
  {
    Map.Entry<Double, Collection<TXCluster> > last_entry = priority_map_copy.asMap().pollLastEntry();

    double ratio = last_entry.getKey();
    boolean low_fee = false;
    if (ratio < Globals.LOW_FEE) low_fee=true;

    Collection<TXCluster> list = last_entry.getValue();
    for (TXCluster cluster : list)
    {
      if (size + cluster.total_size <= max_size)
      {
        if ((!low_fee) || (low_fee_size < low_fee_max))
        {

          for (Transaction tx : cluster.tx_list)
          {
            ChainHash tx_hash = new ChainHash(tx.getTxHash());
            if (!included_txs.contains(tx_hash))
            {
              block_list.add(tx);
              included_txs.add(tx_hash);
              int sz = tx.toByteString().size();
              size += sz;
              if (low_fee)
              {
                low_fee_size += sz;
              }
            }
          }
        }

      }
    }
  }
  return block_list;

}
 
Example 16
Source File: FragmentOptionManager.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Convert this OptionList to a Map from name to OptionValue
 */
private static TreeMultimap<String, OptionValue> getMapFromOptionList(final OptionList list) {
  final TreeMultimap<String, OptionValue> optionMap = TreeMultimap.create();
  list.forEach(value -> optionMap.put(value.getName(), value));
  return optionMap;
}
 
Example 17
Source File: SearchList.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 4 votes vote down vote up
public SearchList() {
    this.reports = TreeMultimap.create();
    totalReportCount = Optional.absent();
}
 
Example 18
Source File: PDataTypeTest.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Test
public void testCoercibleGoldfile() {
    TreeMultimap<String, String> coercibleToMap = TreeMultimap.create();
    PDataType[] orderedTypes = PDataTypeFactory.getInstance().getOrderedTypes();
    for (PDataType fromType : orderedTypes) {
        for (PDataType targetType : orderedTypes) {
            if (fromType.isCoercibleTo(targetType)) {
                coercibleToMap.put(fromType.toString(), targetType.toString());
            }
        }
    }
    assertEquals(
          "{BIGINT=[BIGINT, BINARY, DECIMAL, DOUBLE, VARBINARY], "
         + "BIGINT ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, VARBINARY ARRAY], "
         + "BINARY=[BINARY, VARBINARY], "
         + "BINARY ARRAY=[BINARY ARRAY, VARBINARY ARRAY], "
         + "BOOLEAN=[BINARY, BOOLEAN, VARBINARY], "
         + "BOOLEAN ARRAY=[BINARY ARRAY, BOOLEAN ARRAY, VARBINARY ARRAY], "
         + "CHAR=[BINARY, CHAR, VARBINARY, VARCHAR], "
         + "CHAR ARRAY=[BINARY ARRAY, CHAR ARRAY, VARBINARY ARRAY, VARCHAR ARRAY], "
         + "DATE=[BINARY, DATE, TIME, TIMESTAMP, VARBINARY], "
         + "DATE ARRAY=[BINARY ARRAY, DATE ARRAY, TIME ARRAY, TIMESTAMP ARRAY, VARBINARY ARRAY], "
         + "DECIMAL=[DECIMAL, VARBINARY], "
         + "DECIMAL ARRAY=[DECIMAL ARRAY, VARBINARY ARRAY], "
         + "DOUBLE=[BINARY, DECIMAL, DOUBLE, VARBINARY], "
         + "DOUBLE ARRAY=[BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, VARBINARY ARRAY], "
         + "FLOAT=[BINARY, DECIMAL, DOUBLE, FLOAT, VARBINARY], "
         + "FLOAT ARRAY=[BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, VARBINARY ARRAY], "
         + "INTEGER=[BIGINT, BINARY, DECIMAL, DOUBLE, FLOAT, INTEGER, VARBINARY], "
         + "INTEGER ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, INTEGER ARRAY, VARBINARY ARRAY], "
         + "SMALLINT=[BIGINT, BINARY, DECIMAL, DOUBLE, FLOAT, INTEGER, SMALLINT, VARBINARY], "
         + "SMALLINT ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, INTEGER ARRAY, SMALLINT ARRAY, VARBINARY ARRAY], "
         + "TIME=[BINARY, DATE, TIME, TIMESTAMP, VARBINARY], "
         + "TIME ARRAY=[BINARY ARRAY, DATE ARRAY, TIME ARRAY, TIMESTAMP ARRAY, VARBINARY ARRAY], "
         + "TIMESTAMP=[BINARY, TIMESTAMP, VARBINARY], "
         + "TIMESTAMP ARRAY=[BINARY ARRAY, TIMESTAMP ARRAY, VARBINARY ARRAY], "
         + "TINYINT=[BIGINT, BINARY, DECIMAL, DOUBLE, FLOAT, INTEGER, SMALLINT, TINYINT, VARBINARY], "
         + "TINYINT ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, INTEGER ARRAY, SMALLINT ARRAY, TINYINT ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_DATE=[BINARY, DATE, TIME, TIMESTAMP, UNSIGNED_DATE, UNSIGNED_TIME, UNSIGNED_TIMESTAMP, VARBINARY], "
         + "UNSIGNED_DATE ARRAY=[BINARY ARRAY, DATE ARRAY, TIME ARRAY, TIMESTAMP ARRAY, UNSIGNED_DATE ARRAY, UNSIGNED_TIME ARRAY, UNSIGNED_TIMESTAMP ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_DOUBLE=[BINARY, DECIMAL, DOUBLE, UNSIGNED_DOUBLE, VARBINARY], "
         + "UNSIGNED_DOUBLE ARRAY=[BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, UNSIGNED_DOUBLE ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_FLOAT=[BINARY, DECIMAL, DOUBLE, FLOAT, UNSIGNED_DOUBLE, UNSIGNED_FLOAT, VARBINARY], "
         + "UNSIGNED_FLOAT ARRAY=[BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, UNSIGNED_DOUBLE ARRAY, UNSIGNED_FLOAT ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_INT=[BIGINT, BINARY, DECIMAL, DOUBLE, FLOAT, INTEGER, UNSIGNED_DOUBLE, UNSIGNED_FLOAT, UNSIGNED_INT, UNSIGNED_LONG, VARBINARY], "
         + "UNSIGNED_INT ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, INTEGER ARRAY, UNSIGNED_DOUBLE ARRAY, UNSIGNED_FLOAT ARRAY, UNSIGNED_INT ARRAY, UNSIGNED_LONG ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_LONG=[BIGINT, BINARY, DECIMAL, DOUBLE, UNSIGNED_DOUBLE, UNSIGNED_LONG, VARBINARY], "
         + "UNSIGNED_LONG ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, UNSIGNED_DOUBLE ARRAY, UNSIGNED_LONG ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_SMALLINT=[BIGINT, BINARY, DECIMAL, DOUBLE, FLOAT, INTEGER, SMALLINT, UNSIGNED_DOUBLE, UNSIGNED_FLOAT, UNSIGNED_INT, UNSIGNED_LONG, UNSIGNED_SMALLINT, VARBINARY], "
         + "UNSIGNED_SMALLINT ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, INTEGER ARRAY, SMALLINT ARRAY, UNSIGNED_DOUBLE ARRAY, UNSIGNED_FLOAT ARRAY, UNSIGNED_INT ARRAY, UNSIGNED_LONG ARRAY, UNSIGNED_SMALLINT ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_TIME=[BINARY, DATE, TIME, TIMESTAMP, UNSIGNED_DATE, UNSIGNED_TIME, UNSIGNED_TIMESTAMP, VARBINARY], "
         + "UNSIGNED_TIME ARRAY=[BINARY ARRAY, DATE ARRAY, TIME ARRAY, TIMESTAMP ARRAY, UNSIGNED_DATE ARRAY, UNSIGNED_TIME ARRAY, UNSIGNED_TIMESTAMP ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_TIMESTAMP=[BINARY, DATE, TIME, TIMESTAMP, UNSIGNED_DATE, UNSIGNED_TIME, UNSIGNED_TIMESTAMP, VARBINARY], "
         + "UNSIGNED_TIMESTAMP ARRAY=[BINARY ARRAY, DATE ARRAY, TIME ARRAY, TIMESTAMP ARRAY, UNSIGNED_DATE ARRAY, UNSIGNED_TIME ARRAY, UNSIGNED_TIMESTAMP ARRAY, VARBINARY ARRAY], "
         + "UNSIGNED_TINYINT=[BIGINT, BINARY, DECIMAL, DOUBLE, FLOAT, INTEGER, SMALLINT, TINYINT, UNSIGNED_DOUBLE, UNSIGNED_FLOAT, UNSIGNED_INT, UNSIGNED_LONG, UNSIGNED_SMALLINT, UNSIGNED_TINYINT, VARBINARY], "
         + "UNSIGNED_TINYINT ARRAY=[BIGINT ARRAY, BINARY ARRAY, DECIMAL ARRAY, DOUBLE ARRAY, FLOAT ARRAY, INTEGER ARRAY, SMALLINT ARRAY, TINYINT ARRAY, UNSIGNED_DOUBLE ARRAY, UNSIGNED_FLOAT ARRAY, UNSIGNED_INT ARRAY, UNSIGNED_LONG ARRAY, UNSIGNED_SMALLINT ARRAY, UNSIGNED_TINYINT ARRAY, VARBINARY ARRAY], "
         + "VARBINARY=[BINARY, VARBINARY], "
         + "VARBINARY ARRAY=[BINARY ARRAY, VARBINARY ARRAY], "
         + "VARCHAR=[BINARY, CHAR, VARBINARY, VARCHAR], "
         + "VARCHAR ARRAY=[BINARY ARRAY, CHAR ARRAY, VARBINARY ARRAY, VARCHAR ARRAY]}", 
         coercibleToMap.toString());
}
 
Example 19
Source File: PropogatingIteratorTest.java    From datawave with Apache License 2.0 3 votes vote down vote up
@Test
public void testAggregateFour() throws IOException {
    TreeMultimap<Key,Value> map = TreeMultimap.create();
    
    map.put(newKey(SHARD, FIELD_TO_AGGREGATE, "abc"), new Value(createValueWithUid("abc.1").build().toByteArray()));
    map.put(newKey(SHARD, FIELD_TO_AGGREGATE, "abc"), new Value(createValueWithUid("abc.2").build().toByteArray()));
    map.put(newKey(SHARD, FIELD_TO_AGGREGATE, "abc"), new Value(createValueWithUid("abc.3").build().toByteArray()));
    map.put(newKey(SHARD, FIELD_TO_AGGREGATE, "abc"), new Value(createValueWithUid("abc.4").build().toByteArray()));
    
    map.put(newKey(SHARD, FIELD_TO_AGGREGATE, "abd"), new Value(createValueWithUid("abc.3").build().toByteArray()));
    
    SortedMultiMapIterator data = new SortedMultiMapIterator(map);
    
    PropogatingIterator iter = new PropogatingIterator();
    Map<String,String> options = Maps.newHashMap();
    
    options.put(PropogatingIterator.AGGREGATOR_DEFAULT, GlobalIndexUidAggregator.class.getCanonicalName());
    
    IteratorEnvironment env = new MockIteratorEnvironment(false);
    
    iter.init(data, options, env);
    
    iter.seek(new Range(), Collections.emptyList(), false);
    
    Assert.assertTrue(iter.hasTop());
    
    Key topKey = iter.getTopKey();
    
    Assert.assertEquals(newKey(SHARD, FIELD_TO_AGGREGATE, "abc"), topKey);
    validateUids(iter.getTopValue(), "abc.1", "abc.2", "abc.3", "abc.4");
    iter.next();
    topKey = iter.getTopKey();
    Assert.assertEquals(newKey(SHARD, FIELD_TO_AGGREGATE, "abd"), topKey);
    validateUids(iter.getTopValue(), "abc.3");
    
}
 
Example 20
Source File: TermFrequencyList.java    From datawave with Apache License 2.0 3 votes vote down vote up
public TermFrequencyList(Iterable<Entry<Zone,Iterable<TermWeightPosition>>> offsetsPerField) {
    checkNotNull(offsetsPerField);
    
    this.offsetsPerField = TreeMultimap.create();
    
    addOffsets(offsetsPerField);
}