List of usage examples for java.util SortedSet contains
boolean contains(Object o);
From source file:org.jenkins.ci.plugins.PersistentBuildQueue.java
/** * Called at Jenkins start (and probably more times, hence the isLoaded * check) to load up the persisted build queue and * {@link AbstractProject#scheduleBuild(int, hudson.model.Cause)} for all * entries in the set.//w ww .j a v a 2 s. co m */ public static void load() { synchronized (LOCK) { if (!isLoaded) { final SortedSet<String> persistedBuildQueue = getPersistentBuildQueueEntries(); for (final Project project : Hudson.getInstance().getProjects()) { if (persistedBuildQueue.contains(project.getDisplayName())) { LOG.info("Re-scheduling persisted build queue project: " + project.getDisplayName()); project.scheduleBuild(0, new PersistentBuildQueueCause()); } } isLoaded = true; } } }
From source file:main.java.workload.Workload.java
public static Set<Integer> getTrDataSet(Database db, Cluster cluster, WorkloadBatch wb, Set<Integer> trTupleSet) { Set<Integer> trDataSet = new TreeSet<Integer>(); SortedSet<Integer> deletedTuples = new TreeSet<Integer>(); int s_id = 1; for (int tpl_id : trTupleSet) { if (!deletedTuples.contains(tpl_id)) { String[] parts = Cluster.breakDataIdWithoutReplicaId(tpl_id); int tpl_pk = Integer.parseInt(parts[0]); int tbl_id = Integer.parseInt(parts[1]); Tuple tpl = db.getTupleById(tbl_id, tpl_id); int _id = -1; if (tpl.getTuple_action().equals(WorkloadConstants.TPL_INSERT)) { tpl.setTuple_action(WorkloadConstants.TPL_INITIAL); // Insert into Cluster, already in the Database switch (Global.setup) { case "range": Server s = cluster.getServer(s_id); int p_id = cluster.getRangePartition(s, tbl_id); _id = cluster.insertData_RangePartitioning(tpl_id, s_id, p_id); ++s_id;/* w w w . ja v a2s .c o m*/ if (s_id > Global.servers) s_id = 1; break; case "consistenthash": _id = cluster.insertData_ConsistentHash(tpl_id); break; default: Global.LOGGER.error( "Wrong cluster setup method is specified !!! Choose either 'range' or 'consistenthash'"); break; } trDataSet.add(_id); } else if (tpl.getTuple_action().equals("delete")) { // Remove from Cluster switch (Global.setup) { case "range": cluster.deleteDataRangePartitioning(tpl_id); break; case "consistenthash": cluster.deleteDataConsistentHashing(tpl_id); break; default: Global.LOGGER.error( "Wrong cluster setup method is specified !!! Choose either 'range' or 'consistenthash'"); break; } // Remove from Database db.deleteTupleByPk(tbl_id, tpl_pk); _id = Cluster.getDataIdFromTupleId(tpl_id); // Remove from Workload Batch // Removing vertex in Workload Batch graph and hypergraph wb.deleteTrDataFromWorkload(_id); SimpleVertex v = wb.hgr.getVertex(_id); if (v != null) { wb.hgr.removeVertex(v); } deletedTuples.add(tpl_id); } else { _id = Cluster.getDataIdFromTupleId(tpl_id); trDataSet.add(_id); } } // end--if() } // Tuple return trDataSet; }
From source file:com.spotify.heroic.filter.impl.OrFilterImpl.java
private static Filter optimize(SortedSet<Filter> statements) { final SortedSet<Filter> result = new TreeSet<>(); root: for (final Filter f : statements) { if (f instanceof Filter.Not) { final Filter.Not not = (Filter.Not) f; if (statements.contains(not.first())) { return TrueFilterImpl.get(); }// w w w. j a va2s. c o m result.add(f); continue; } if (f instanceof Filter.StartsWith) { final Filter.StartsWith outer = (Filter.StartsWith) f; for (final Filter inner : statements) { if (inner.equals(outer)) { continue; } if (inner instanceof Filter.StartsWith) { final Filter.StartsWith starts = (Filter.StartsWith) inner; if (!outer.first().equals(starts.first())) { continue; } if (FilterComparatorUtils.prefixedWith(outer.second(), starts.second())) { continue root; } } } result.add(f); continue; } // all ok! result.add(f); } if (result.isEmpty()) { return TrueFilterImpl.get(); } if (result.size() == 1) { return result.iterator().next(); } return new OrFilterImpl(new ArrayList<>(result)); }
From source file:com.spotify.heroic.filter.OrFilter.java
static Filter optimize(final SortedSet<Filter> filters) { final SortedSet<Filter> result = new TreeSet<>(); for (final Filter f : filters) { if (f instanceof NotFilter) { // Optimize away expressions which are always true. // Example: foo = bar or !(foo = bar) if (filters.contains(((NotFilter) f).getFilter())) { return TrueFilter.get(); }//ww w.j ava 2 s . c o m } else if (f instanceof StartsWithFilter) { // Optimize away prefixes which encompass each other. // Example: foo ^ hello or foo ^ helloworld -> foo ^ hello if (FilterUtils.containsPrefixedWith(filters, (StartsWithFilter) f, (inner, outer) -> FilterUtils.prefixedWith(outer.getValue(), inner.getValue()))) { continue; } } result.add(f); } if (result.isEmpty()) { return TrueFilter.get(); } if (result.size() == 1) { return result.iterator().next(); } return new OrFilter(ImmutableList.copyOf(result)); }
From source file:com.spotify.heroic.filter.AndFilter.java
static Filter optimize(final SortedSet<Filter> filters) { final SortedSet<Filter> result = new TreeSet<>(); for (final Filter f : filters) { if (f instanceof NotFilter) { // Optimize away expressions which are always false. // Example: foo = bar and !(foo = bar) if (filters.contains(((NotFilter) f).getFilter())) { return FalseFilter.get(); }// www. j a v a2 s . c o m } else if (f instanceof StartsWithFilter) { // Optimize away prefixes which encompass each other. // Example: foo ^ hello and foo ^ helloworld -> foo ^ helloworld if (FilterUtils.containsPrefixedWith(filters, (StartsWithFilter) f, (inner, outer) -> FilterUtils.prefixedWith(inner.getValue(), outer.getValue()))) { continue; } } else if (f instanceof MatchTagFilter) { // Optimize matchTag expressions which are always false. // Example: foo = bar and foo = baz if (FilterUtils.containsConflictingMatchTag(filters, (MatchTagFilter) f)) { return FalseFilter.get(); } } else if (f instanceof MatchKeyFilter) { // Optimize matchTag expressions which are always false. // Example: $key = bar and $key = baz if (FilterUtils.containsConflictingMatchKey(filters, (MatchKeyFilter) f)) { return FalseFilter.get(); } } result.add(f); } if (result.isEmpty()) { return FalseFilter.get(); } if (result.size() == 1) { return result.iterator().next(); } return new AndFilter(ImmutableList.copyOf(result)); }
From source file:com.spotify.heroic.filter.impl.AndFilterImpl.java
private static Filter optimize(SortedSet<Filter> statements) { final SortedSet<Filter> result = new TreeSet<>(); root: for (final Filter f : statements) { if (f instanceof Filter.Not) { final Filter.Not not = (Filter.Not) f; if (statements.contains(not.first())) { return FalseFilterImpl.get(); }//from w w w .ja v a 2 s .co m result.add(f); continue; } /** * If there exists two MatchTag statements, but they check for different values. */ if (f instanceof Filter.MatchTag) { final Filter.MatchTag outer = (Filter.MatchTag) f; for (final Filter inner : statements) { if (inner.equals(outer)) { continue; } if (inner instanceof Filter.MatchTag) { final Filter.MatchTag matchTag = (Filter.MatchTag) inner; if (!outer.first().equals(matchTag.first())) { continue; } if (!FilterComparatorUtils.isEqual(outer.second(), matchTag.second())) { return FalseFilterImpl.get(); } } } result.add(f); continue; } if (f instanceof Filter.MatchTag) { final Filter.MatchTag outer = (Filter.MatchTag) f; for (final Filter inner : statements) { if (inner.equals(outer)) { continue; } if (inner instanceof Filter.MatchTag) { final Filter.MatchTag tag = (Filter.MatchTag) inner; if (!outer.first().equals(tag.first())) { continue; } if (!FilterComparatorUtils.isEqual(outer.second(), tag.second())) { return FalseFilterImpl.get(); } } } result.add(f); continue; } // optimize away prefixes which encompass eachother. // Example: foo ^ hello and foo ^ helloworld -> foo ^ helloworld if (f instanceof Filter.StartsWith) { final Filter.StartsWith outer = (Filter.StartsWith) f; for (final Filter inner : statements) { if (inner.equals(outer)) { continue; } if (inner instanceof Filter.StartsWith) { final Filter.StartsWith starts = (Filter.StartsWith) inner; if (!outer.first().equals(starts.first())) { continue; } if (FilterComparatorUtils.prefixedWith(starts.second(), outer.second())) { continue root; } } } result.add(f); continue; } // all ok! result.add(f); } if (result.isEmpty()) { return FalseFilterImpl.get(); } if (result.size() == 1) { return result.iterator().next(); } return new AndFilterImpl(new ArrayList<>(result)); }
From source file:com.espertech.esper.schedule.ScheduleComputeHelper.java
private static int nextValue(SortedSet<Integer> valueSet, int startValue) { if (valueSet == null) { return startValue; }//from w w w . j av a 2 s. c o m if (valueSet.contains(startValue)) { return startValue; } SortedSet<Integer> tailSet = valueSet.tailSet(startValue + 1); if (tailSet.isEmpty()) { return -1; } else { return tailSet.first(); } }
From source file:org.apache.geode.pdx.internal.PdxInstanceImpl.java
/** * Any fields that are in otherFields but not in myFields are added to myFields as defaults. When * adding fields they are inserted in the natural sort order. Note: myFields may be modified by * this call./*w ww. ja va 2s .com*/ */ private static void addDefaultFields(SortedSet<PdxField> myFields, SortedSet<PdxField> otherFields) { for (PdxField f : otherFields) { if (!myFields.contains(f)) { myFields.add(new DefaultPdxField(f)); } } }
From source file:spade.storage.CompressedTextFile.java
public static Pair<Pair<Integer, Integer>, String> commonNodes(SortedSet<Integer> reference, SortedSet<Integer> node) { int nodesInCommon = 0; int numberOfZero = 0; String bitlist = ""; for (Integer successor : reference) { if (node.contains(successor)) { nodesInCommon++;/* w ww .j a va 2s.com*/ bitlist = bitlist + "1"; } else { numberOfZero++; bitlist = bitlist + "0"; } } Pair<Integer, Integer> count = new Pair<Integer, Integer>(nodesInCommon, numberOfZero); return new Pair<Pair<Integer, Integer>, String>(count, bitlist); }
From source file:com.brotherpowers.cameraview.SizeMap.java
/** * Add a new {@link Size} to this collection. * * @param size The size to add./*from ww w. ja v a 2 s.c o m*/ * @return {@code true} if it is added, {@code false} if it already exists and is not added. */ public boolean add(Size size) { for (AspectRatio ratio : mRatios.keySet()) { if (ratio.matches(size)) { final SortedSet<Size> sizes = mRatios.get(ratio); if (sizes.contains(size)) { return false; } else { sizes.add(size); return true; } } } // None of the existing ratio matches the provided size; add a new key SortedSet<Size> sizes = new TreeSet<>(); sizes.add(size); mRatios.put(AspectRatio.of(size.getWidth(), size.getHeight()), sizes); return true; }