List of usage examples for com.google.common.collect Maps newTreeMap
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap()
From source file:io.druid.indexing.appenderator.ActionBasedUsedSegmentChecker.java
@Override public Set<DataSegment> findUsedSegments(Set<SegmentIdentifier> identifiers) throws IOException { // Group by dataSource final Map<String, Set<SegmentIdentifier>> identifiersByDataSource = Maps.newTreeMap(); for (SegmentIdentifier identifier : identifiers) { if (!identifiersByDataSource.containsKey(identifier.getDataSource())) { identifiersByDataSource.put(identifier.getDataSource(), Sets.<SegmentIdentifier>newHashSet()); }// w w w . j av a 2 s . co m identifiersByDataSource.get(identifier.getDataSource()).add(identifier); } final Set<DataSegment> retVal = Sets.newHashSet(); for (Map.Entry<String, Set<SegmentIdentifier>> entry : identifiersByDataSource.entrySet()) { final List<Interval> intervals = JodaUtils.condenseIntervals( Iterables.transform(entry.getValue(), new Function<SegmentIdentifier, Interval>() { @Override public Interval apply(SegmentIdentifier input) { return input.getInterval(); } })); final List<DataSegment> usedSegmentsForIntervals = taskActionClient .submit(new SegmentListUsedAction(entry.getKey(), null, intervals)); for (DataSegment segment : usedSegmentsForIntervals) { if (identifiers.contains(SegmentIdentifier.fromDataSegment(segment))) { retVal.add(segment); } } } return retVal; }
From source file:cuchaz.enigma.analysis.SourceIndex.java
public SourceIndex(String source, boolean ignoreBadTokens) { this.source = source; this.ignoreBadTokens = ignoreBadTokens; this.tokenToReference = Maps.newTreeMap(); this.referenceToTokens = HashMultimap.create(); this.declarationToToken = Maps.newHashMap(); this.lineOffsets = Lists.newArrayList(); // count the lines this.lineOffsets.add(0); for (int i = 0; i < source.length(); i++) { if (source.charAt(i) == '\n') { this.lineOffsets.add(i + 1); }// ww w . j a v a 2 s .c o m } }
From source file:org.apache.gobblin.util.request_allocation.SimpleHiveDatasetTieringPrioritizer.java
private static Comparator<Requestor<FileSet<CopyEntity>>> createRequestorComparator(Properties props) throws IOException { TreeMap<Integer, WhitelistBlacklist> tiers = Maps.newTreeMap(); Matcher matcher;// w w w.j a v a2 s . c om for (Map.Entry<Object, Object> entry : props.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String && (matcher = TIER_PATTERN.matcher((String) entry.getKey())).matches()) { int tier = Integer.parseInt(matcher.group(1)); WhitelistBlacklist whitelistBlacklist = new WhitelistBlacklist((String) entry.getValue(), ""); tiers.put(tier, whitelistBlacklist); } } return new TierComparator(tiers); }
From source file:controllers.api.ExtractorsApiController.java
@BodyParser.Of(BodyParser.Json.class) public Result order(String inputId) { final JsonNode json = request().body().asJson(); final SortedMap<Integer, String> positions = Maps.newTreeMap(); final Iterator<JsonNode> order = json.get("order").elements(); int i = 0;/*from ww w .j a v a 2s. com*/ while (order.hasNext()) { final String extractorId = order.next().asText(); positions.put(i, extractorId); i++; } try { extractorService.order(inputId, positions); } catch (IOException e) { Logger.error("Could not update extractor order.", e); return internalServerError(); } catch (APIException e) { Logger.error("Could not update extractor order.", e); return internalServerError(); } return ok(); }
From source file:io.atomix.core.tree.impl.DefaultDocumentTreeNode.java
public DefaultDocumentTreeNode(DocumentPath key, V value, long version, Ordering ordering, DocumentTreeNode<V> parent) { this.key = checkNotNull(key); this.value = new Versioned<>(value, version); this.ordering = ordering; this.parent = parent; switch (ordering) { case INSERTION: children = Maps.newLinkedHashMap(); break;/*from w w w. j av a2 s . c o m*/ case NATURAL: default: children = Maps.newTreeMap(); break; } }
From source file:com.yahoo.pulsar.common.policies.data.PersistentTopicStats.java
public PersistentTopicStats() { this.publishers = Lists.newArrayList(); this.subscriptions = Maps.newHashMap(); this.replication = Maps.newTreeMap(); }
From source file:org.apache.druid.indexing.appenderator.ActionBasedUsedSegmentChecker.java
@Override public Set<DataSegment> findUsedSegments(Set<SegmentIdentifier> identifiers) throws IOException { // Group by dataSource final Map<String, Set<SegmentIdentifier>> identifiersByDataSource = Maps.newTreeMap(); for (SegmentIdentifier identifier : identifiers) { if (!identifiersByDataSource.containsKey(identifier.getDataSource())) { identifiersByDataSource.put(identifier.getDataSource(), Sets.newHashSet()); }/* w ww .j ava 2 s. co m*/ identifiersByDataSource.get(identifier.getDataSource()).add(identifier); } final Set<DataSegment> retVal = Sets.newHashSet(); for (Map.Entry<String, Set<SegmentIdentifier>> entry : identifiersByDataSource.entrySet()) { final List<Interval> intervals = JodaUtils.condenseIntervals( Iterables.transform(entry.getValue(), new Function<SegmentIdentifier, Interval>() { @Override public Interval apply(SegmentIdentifier input) { return input.getInterval(); } })); final List<DataSegment> usedSegmentsForIntervals = taskActionClient .submit(new SegmentListUsedAction(entry.getKey(), null, intervals)); for (DataSegment segment : usedSegmentsForIntervals) { if (identifiers.contains(SegmentIdentifier.fromDataSegment(segment))) { retVal.add(segment); } } } return retVal; }
From source file:com.netflix.governator.configuration.ConfigurationDocumentation.java
public Map<String, Entry> getSortedEntries() { Map<String, Entry> sortedEntries = Maps.newTreeMap(); sortedEntries.putAll(entries); return sortedEntries; }
From source file:com.googlesource.gerrit.plugins.quota.ListQuotas.java
@Override public Map<String, QuotaInfo> apply(ConfigResource resource) throws AuthException, BadRequestException, ResourceConflictException, Exception { Map<String, QuotaInfo> result = Maps.newTreeMap(); ListProjects lister = listProjects.get(); lister.setMatchPrefix(matchPrefix);/*from ww w .jav a 2 s .co m*/ for (String projectName : lister.apply().keySet()) { Project.NameKey n = new Project.NameKey(projectName); result.put(projectName, getQuota.getInfo(n)); } return result; }
From source file:org.auraframework.impl.javascript.parser.handler.JavascriptControllerDefHandler.java
@Override protected JavascriptControllerDef createDefinition(Map<String, Object> map) { setDefBuilderFields(builder);/* w w w. j a v a2s . com*/ builder.actionDefs = Maps.newTreeMap(); for (Map.Entry<String, Object> e : map.entrySet()) { JsFunction f = (JsFunction) e.getValue(); String name = e.getKey(); JavascriptActionDef action = createActionDef(name, f); builder.actionDefs.put(name, action); } return builder.build(); }