List of usage examples for com.google.common.collect Sets newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
From source file:org.apache.nutch.api.impl.db.DbIterator.java
DbIterator(Result<String, WebPage> res, Set<String> fields, String batchId) { this.result = res; if (batchId != null) { this.batchId = new Utf8(batchId); }/* w ww. j a va2 s . c o m*/ if (fields != null) { this.commonFields = Sets.newTreeSet(fields); } try { skipNonRelevant(); } catch (Exception e) { LOG.error("Cannot create db iterator!", e); } }
From source file:org.kuali.rice.xml.ingest.RiceConfigUtils.java
/** * Iterate over the list of key/value pairs from {@code properties} and invoke {@code config.putProperty(key,value)} *///from w w w. j ava 2 s . c om public static void putProperties(Config config, Properties properties) { SortedSet<String> keys = Sets.newTreeSet(properties.stringPropertyNames()); for (String key : keys) { config.putProperty(key, properties.getProperty(key)); } }
From source file:edu.harvard.med.screensaver.util.PowerSet.java
/** * Returns the power set of the specified set, ordering the power set elements * (themselves sets) by size, then minimum value. Each the power set elements * (sets) are also ordered by the natural ordering of their values. */// w w w .j ava 2 s .c om public static <T extends Comparable<T>> SortedSet<SortedSet<T>> orderedPowerset(Set<T> values) { SortedSet<SortedSet<T>> orderedPowerset = new TreeSet<SortedSet<T>>(new Comparator<SortedSet<T>>() { public int compare(SortedSet<T> s1, SortedSet<T> s2) { if (s1.size() < s2.size()) { return -1; } else if (s1.size() > s2.size()) { return 1; } else { Iterator<T> i1 = s1.iterator(); Iterator<T> i2 = s2.iterator(); int c = 0; while (i1.hasNext() && i2.hasNext() && c == 0) { c = i1.next().compareTo(i2.next()); } return c; } } }); Iterator<Set<T>> powerSetIterator = powerSetIterator(values); while (powerSetIterator.hasNext()) { TreeSet<T> orderedSetElement = Sets.newTreeSet(powerSetIterator.next()); orderedPowerset.add(orderedSetElement); if (log.isDebugEnabled()) { log.debug("added " + orderedSetElement); log.debug("powerset = " + orderedPowerset); } } return orderedPowerset; }
From source file:uk.ac.ebi.spot.rdf.model.Experiment.java
public Experiment(ExperimentType type, String accession, Date lastUpdate, String displayName, String description, boolean hasExtraInfoFile, Set<String> species, Map<String, String> speciesMapping, Set<String> pubMedIds, ExperimentDesign experimentDesign) { this.type = type; this.lastUpdate = lastUpdate; this.experimentDesign = experimentDesign; this.accession = accession; this.displayName = displayName; this.description = description; this.hasExtraInfoFile = hasExtraInfoFile; this.species = new TreeSet<String>(species); this.speciesMapping = speciesMapping; this.pubMedIds = Sets.newTreeSet(pubMedIds); }
From source file:org.apache.hadoop.hbase.rsgroup.RSGroupInfo.java
public RSGroupInfo(RSGroupInfo src) { name = src.getName(); servers = Sets.newHashSet(src.getServers()); tables = Sets.newTreeSet(src.getTables()); }
From source file:com.arpnetworking.clusteraggregator.models.ShardAllocation.java
private ShardAllocation(final Builder builder) { _host = builder._host;/*w ww . jav a 2s .co m*/ _shardRegion = builder._shardRegion; _currentShards = Sets.newTreeSet(new LexicalNumericComparator()); _currentShards.addAll(builder._currentShards); _incomingShards = Sets.newTreeSet(new LexicalNumericComparator()); _incomingShards.addAll(builder._incomingShards); _outgoingShards = Sets.newTreeSet(new LexicalNumericComparator()); _outgoingShards.addAll(builder._outgoingShards); }
From source file:com.metamx.druid.BaseStorageAdapter.java
@Override public Iterable<SearchHit> searchDimensions(final SearchQuery query, final Filter filter) { final List<String> dimensions = query.getDimensions(); final SearchQuerySpec searchQuerySpec = query.getQuery(); final TreeSet<SearchHit> retVal = Sets.newTreeSet(query.getSort().getComparator()); Iterable<String> dimsToSearch; if (dimensions == null || dimensions.isEmpty()) { dimsToSearch = getAvailableDimensions(); } else {//from w ww . j a v a 2 s . co m dimsToSearch = dimensions; } Offset filterOffset = (filter == null) ? null : getFilterOffset(filter); for (String dimension : dimsToSearch) { Iterable<String> dims = getDimValueLookup(dimension); if (dims != null) { for (String dimVal : dims) { dimVal = dimVal == null ? "" : dimVal; if (searchQuerySpec.accept(dimVal)) { if (filterOffset != null) { Offset lhs = new ConciseOffset(getInvertedIndex(dimension, dimVal)); Offset rhs = filterOffset.clone(); if (new IntersectingOffset(lhs, rhs).withinBounds()) { retVal.add(new SearchHit(dimension, dimVal)); } } else { retVal.add(new SearchHit(dimension, dimVal)); } } } } } return new FunctionalIterable<SearchHit>(retVal).limit(query.getLimit()); }
From source file:cloud.strategies.CompositeRemoteConnectionStrategy.java
private CompositeRemoteConnectionStrategy(Set<RemoteConnectionStrategy> strategySet) { if (strategySet.isEmpty()) { LOGGER.warn(String.format( "%s is initializing with an empty strategy set. This is likely to cause errors.", this)); }/*from w ww .jav a 2 s.c om*/ LOGGER.debug(String.format("%s is loading available strategy set. Contains %s strategies.", this, strategySet.size())); if (Logger.isTraceEnabled()) { strategySet.forEach(remoteConnectionStrategy -> Logger .trace(String.format("%s is loading strategy %s", this, remoteConnectionStrategy))); } // wrap in immutable sorted set to ensure comparability. this.strategySet = ImmutableSet.copyOf(Sets.newTreeSet(strategySet)); }
From source file:kr.co.vcnc.haeinsa.HaeinsaColumnTracker.java
/** * Constructor of HaeinsaColumnTracker./*from w w w. j a v a2s . com*/ * <p> * If this ColumnTracker track {@link HaeinsaScan}, minColumn, maxColumn * should be null and minColumnInclusive, maxColumnInclusive should be false. */ public HaeinsaColumnTracker(Map<byte[], NavigableSet<byte[]>> familyMap, byte[] minColumn, boolean minColumnInclusive, byte[] maxColumn, boolean maxColumnInclusive) { this.minColumn = minColumn; this.maxColumn = maxColumn; this.minColumnInclusive = minColumnInclusive; this.maxColumnInclusive = maxColumnInclusive; for (Entry<byte[], NavigableSet<byte[]>> entry : familyMap.entrySet()) { if (entry.getValue() != null) { NavigableSet<byte[]> qualifierSet = Sets.newTreeSet(Bytes.BYTES_COMPARATOR); qualifierSet.addAll(entry.getValue()); this.familyMap.put(entry.getKey(), qualifierSet); } else { this.familyMap.put(entry.getKey(), null); } } }
From source file:com.facebook.buck.model.InMemoryBuildFileTree.java
public InMemoryBuildFileTree(Collection<Path> basePaths) { TreeSet<Path> sortedBasePaths = Sets.newTreeSet(PATH_COMPARATOR); sortedBasePaths.addAll(basePaths);/*from w w w. ja v a 2s . c om*/ // Initialize basePathToNodeIndex with a Node that corresponds to the empty string. This ensures // that findParent() will always return a non-null Node because the empty string is a prefix of // all base paths. basePathToNodeIndex = Maps.newHashMap(); Node root = new Node(Paths.get("")); basePathToNodeIndex.put(Paths.get(""), root); // Build up basePathToNodeIndex in a breadth-first manner. for (Path basePath : sortedBasePaths) { if (basePath.equals(Paths.get(""))) { continue; } Node child = new Node(basePath); Node parent = findParent(child, basePathToNodeIndex); Preconditions.checkNotNull(parent).addChild(child); basePathToNodeIndex.put(basePath, child); } }