com.google.common.collect.ImmutableSortedMultiset Java Examples
The following examples show how to use
com.google.common.collect.ImmutableSortedMultiset.
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: Word2VecTrainer.java From Word2VecJava with MIT License | 6 votes |
/** @return Tokens with their count, sorted by frequency decreasing, then lexicographically ascending */ private ImmutableMultiset<String> filterAndSort(final Multiset<String> counts) { // This isn't terribly efficient, but it is deterministic // Unfortunately, Guava's multiset doesn't give us a clean way to order both by count and element return Multisets.copyHighestCountFirst( ImmutableSortedMultiset.copyOf( Multisets.filter( counts, new Predicate<String>() { @Override public boolean apply(String s) { return counts.count(s) >= minFrequency; } } ) ) ); }
Example #2
Source File: Validator.java From presto with Apache License 2.0 | 5 votes |
private static boolean resultsMatch(QueryResult controlResult, QueryResult testResult, int precision) { SortedMultiset<List<Object>> control = ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResult.getResults()); SortedMultiset<List<Object>> test = ImmutableSortedMultiset.copyOf(rowComparator(precision), testResult.getResults()); try { return control.equals(test); } catch (TypesDoNotMatchException e) { return false; } }
Example #3
Source File: Validator.java From presto with Apache License 2.0 | 5 votes |
public String getResultsComparison(int precision) { List<List<Object>> controlResults = controlResult.getResults(); List<List<Object>> testResults = testResult.getResults(); if (valid() || (controlResults == null) || (testResults == null)) { return ""; } Multiset<List<Object>> control = ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResults); Multiset<List<Object>> test = ImmutableSortedMultiset.copyOf(rowComparator(precision), testResults); try { Iterable<ChangedRow> diff = ImmutableSortedMultiset.<ChangedRow>naturalOrder() .addAll(Iterables.transform(Multisets.difference(control, test), row -> new ChangedRow(Changed.REMOVED, row, precision))) .addAll(Iterables.transform(Multisets.difference(test, control), row -> new ChangedRow(Changed.ADDED, row, precision))) .build(); diff = Iterables.limit(diff, 100); StringBuilder sb = new StringBuilder(); sb.append(format("Control %s rows, Test %s rows%n", control.size(), test.size())); if (verboseResultsComparison) { Joiner.on("\n").appendTo(sb, diff); } else { sb.append("RESULTS DO NOT MATCH\n"); } return sb.toString(); } catch (TypesDoNotMatchException e) { return e.getMessage(); } }
Example #4
Source File: ImmutableSortedMultisetDeserializer.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override protected Builder<Object> createBuilder() { /* This is suboptimal. See the considerations in ImmutableSortedSetDeserializer. */ @SuppressWarnings({ "rawtypes", "unchecked" }) Builder<Object> builder = (Builder) ImmutableSortedMultiset.naturalOrder(); return builder; }
Example #5
Source File: ImmutableSortedMultisetDeserializer.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override protected ImmutableSortedMultiset<Object> _createWithSingleElement(DeserializationContext ctxt, Object value) throws IOException { return (ImmutableSortedMultiset<Object>) createBuilder() .add(value) .build(); }
Example #6
Source File: ImmutableSortedMultisetDeserializer.java From jackson-datatypes-collections with Apache License 2.0 | 4 votes |
@Override public GuavaCollectionDeserializer<ImmutableSortedMultiset<Object>> withResolved(JsonDeserializer<?> valueDeser, TypeDeserializer typeDeser, NullValueProvider nuller, Boolean unwrapSingle) { return new ImmutableSortedMultisetDeserializer(_containerType, valueDeser, typeDeser, nuller, unwrapSingle); }
Example #7
Source File: ImmutableSortedMultisetDeserializer.java From jackson-datatypes-collections with Apache License 2.0 | 4 votes |
@Override protected ImmutableSortedMultiset<Object> _createEmpty(DeserializationContext ctxt) throws IOException { return ImmutableSortedMultiset.of(); }
Example #8
Source File: SortedCollectionWrapper.java From immutables with Apache License 2.0 | 4 votes |
@Value.ReverseOrder ImmutableSortedMultiset<Elem> getElemMultiset();
Example #9
Source File: SortedCollectionWrapper.java From immutables with Apache License 2.0 | 4 votes |
@Value.ReverseOrder ImmutableSortedMultiset<ImmutableElem> getImmutableElemMultiset();