List of usage examples for java.util HashSet equals
boolean equals(Object o);
From source file:org.apache.nutch.crawl.CrawlDatum.java
private boolean metadataEquals(org.apache.hadoop.io.MapWritable otherMetaData) { if (metaData == null || metaData.size() == 0) { return otherMetaData == null || otherMetaData.size() == 0; }// w w w . j a va 2s.com if (otherMetaData == null) { // we already know that the current object is not null or empty return false; } HashSet<Entry<Writable, Writable>> set1 = new HashSet<>(metaData.entrySet()); HashSet<Entry<Writable, Writable>> set2 = new HashSet<>(otherMetaData.entrySet()); return set1.equals(set2); }
From source file:org.apache.nutch.crawl.MapWritable.java
public boolean equals(Object obj) { if (obj instanceof MapWritable) { MapWritable map = (MapWritable) obj; if (fSize != map.fSize) return false; HashSet<KeyValueEntry> set1 = new HashSet<KeyValueEntry>(); KeyValueEntry e1 = fFirst;//w w w. j a va 2 s . co m while (e1 != null) { set1.add(e1); e1 = e1.fNextEntry; } HashSet<KeyValueEntry> set2 = new HashSet<KeyValueEntry>(); KeyValueEntry e2 = map.fFirst; while (e2 != null) { set2.add(e2); e2 = e2.fNextEntry; } return set1.equals(set2); } return false; }
From source file:ru.otdelit.astrid.opencrx.sync.OpencrxSyncProvider.java
/** * Transmit tags/* w w w . j a va 2 s. c o m*/ * * @param local * @param remote * @param idTask * @param idDashboard * @throws ApiServiceException * @throws JSONException * @throws IOException */ private boolean transmitTags(OpencrxTaskContainer local, OpencrxTaskContainer remote) throws ApiServiceException, IOException { boolean transmitted = false; String activityId = local.pdvTask.getValue(OpencrxActivity.CRX_ID); if (TextUtils.isEmpty(activityId)) return false; HashMap<String, OpencrxResourceAssignment> assignments = new HashMap<String, OpencrxResourceAssignment>(); for (OpencrxResourceAssignment assignment : invoker.resourceAssignmentsShowForTask(activityId)) assignments.put(assignment.getResourceId(), assignment); HashSet<String> localTags = new HashSet<String>(); HashSet<String> remoteTags = new HashSet<String>(); for (Metadata item : local.metadata) if (OpencrxDataService.TAG_KEY.equals(item.getValue(Metadata.KEY))) localTags.add(item.getValue(OpencrxDataService.TAG)); if (remote != null && remote.metadata != null) for (Metadata item : remote.metadata) if (OpencrxDataService.TAG_KEY.equals(item.getValue(Metadata.KEY))) remoteTags.add(item.getValue(OpencrxDataService.TAG)); if (!localTags.equals(remoteTags)) { for (String label : localTags) { if (labelMap.containsKey(label) && !remoteTags.contains(label)) { String resourceId = labelMap.get(label); try { invoker.taskAssignResource(activityId, resourceId); } catch (ApiServiceException ex) { // Possible internal server error if resource is bad formed - ignore it } transmitted = true; } } for (String label : remoteTags) { if (labelMap.containsKey(label) && !localTags.contains(label)) { String resourceId = labelMap.get(label); OpencrxResourceAssignment assignment = assignments.get(resourceId); if (assignment == null || assignment.getAssignmentDate() == null) continue; Time assignTime = new Time(); assignTime.set(assignment.getAssignmentDate().getTime()); if (lastSync.after(assignTime)) { try { invoker.resourceAssignmentDelete(activityId, assignment.getAssignmentId()); } catch (IOException ex) { // Possible internal server error if we don't have rights to delete this - ignore it } } } } } return transmitted; }
From source file:org.apache.hadoop.hive.druid.io.DruidRecordWriter.java
private void pushSegments(List<SegmentIdentifier> segmentsToPush) { try {/*from w w w . j a v a 2 s .c o m*/ SegmentsAndMetadata segmentsAndMetadata = appenderator.push(segmentsToPush, committerSupplier.get()) .get(); final HashSet<String> pushedSegmentIdentifierHashSet = new HashSet<>(); for (DataSegment pushedSegment : segmentsAndMetadata.getSegments()) { pushedSegmentIdentifierHashSet .add(SegmentIdentifier.fromDataSegment(pushedSegment).getIdentifierAsString()); final Path segmentDescriptorOutputPath = DruidStorageHandlerUtils .makeSegmentDescriptorOutputPath(pushedSegment, segmentsDescriptorDir); DruidStorageHandlerUtils.writeSegmentDescriptor(fileSystem, pushedSegment, segmentDescriptorOutputPath); LOG.info(String.format("Pushed the segment [%s] and persisted the descriptor located at [%s]", pushedSegment, segmentDescriptorOutputPath)); } final HashSet<String> toPushSegmentsHashSet = new HashSet( FluentIterable.from(segmentsToPush).transform(new Function<SegmentIdentifier, String>() { @Nullable @Override public String apply(@Nullable SegmentIdentifier input) { return input.getIdentifierAsString(); } }).toList()); if (!pushedSegmentIdentifierHashSet.equals(toPushSegmentsHashSet)) { throw new IllegalStateException( String.format("was asked to publish [%s] but was able to publish only [%s]", Joiner.on(", ").join(toPushSegmentsHashSet), Joiner.on(", ").join(pushedSegmentIdentifierHashSet))); } for (SegmentIdentifier dataSegmentId : segmentsToPush) { LOG.info("Dropping segment {}", dataSegmentId.toString()); appenderator.drop(dataSegmentId).get(); } LOG.info(String.format("Published [%,d] segments.", segmentsToPush.size())); } catch (InterruptedException e) { LOG.error(String.format("got interrupted, failed to push [%,d] segments.", segmentsToPush.size()), e); Thread.currentThread().interrupt(); } catch (IOException | ExecutionException e) { LOG.error(String.format("Failed to push [%,d] segments.", segmentsToPush.size()), e); Throwables.propagate(e); } }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
public boolean valueDoesNotContainAll(List<CodeType> codeTypes, String... valuesToMatch) { HashSet<String> valuesFoundInListOfCodeTypes = new HashSet<>(); HashSet<String> valuesToBeFound = new HashSet<>(Arrays.asList(valuesToMatch)); if (valuesToMatch == null || valuesToMatch.length == 0 || CollectionUtils.isEmpty(codeTypes)) { return true; }/*from w w w. j a v a 2s.co m*/ for (CodeType codeType : codeTypes) { String value = codeType.getValue(); if (valuesToBeFound.contains(value)) { valuesFoundInListOfCodeTypes.add(value); } } return !valuesFoundInListOfCodeTypes.equals(valuesToBeFound); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
public boolean listIdDoesNotContainAll(List<CodeType> codeTypes, String... valuesToMatch) { HashSet<String> valuesFoundInListOfCodeTypes = new HashSet<>(); HashSet<String> valuesToBeFound = new HashSet<>(Arrays.asList(valuesToMatch)); if (valuesToMatch == null || valuesToMatch.length == 0 || CollectionUtils.isEmpty(codeTypes)) { return true; }/*from w w w . j av a 2s . co m*/ for (CodeType codeType : codeTypes) { if (codeType != null) { String listId = codeType.getListId(); if (valuesToBeFound.contains(listId)) { valuesFoundInListOfCodeTypes.add(listId); } } } return !valuesFoundInListOfCodeTypes.equals(valuesToBeFound); }
From source file:org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.java
private void waitForTokensToBeRenewed(MockRM rm2, HashSet<Token<RMDelegationTokenIdentifier>> tokenSet) throws Exception { // Max wait time to get the token renewal can be kept as 1sec (100 * 10ms) int waitCnt = 100; while (waitCnt-- > 0) { if (tokenSet.equals(rm2.getRMContext().getDelegationTokenRenewer().getDelegationTokens())) { // Stop waiting as tokens are populated to DelegationTokenRenewer. break; } else {//from ww w. j av a2 s . c o m Thread.sleep(10); } } }
From source file:edu.cmu.tetrad.sem.SemIm.java
public void setFunction(Node node, ConnectionFunction function) { List<Node> parents = semPm.getGraph().getParents(node); for (Iterator<Node> j = parents.iterator(); j.hasNext();) { Node _node = j.next();/*from w w w. ja v a 2s.c o m*/ if (_node.getNodeType() == NodeType.ERROR) { j.remove(); } } HashSet<Node> parentSet = new HashSet<Node>(parents); List<Node> inputList = Arrays.asList(function.getInputNodes()); HashSet<Node> inputSet = new HashSet<Node>(inputList); if (!parentSet.equals(inputSet)) { throw new IllegalArgumentException( "The given function for " + node + " may only use the parents of " + node + ": " + parents); } functions.put(node, function); }
From source file:edu.umass.cs.gnsclient.client.integrationtests.ServerIntegrationTestV2.java
public void test_224_GroupAndACLTestRemoveGuidCheck(GuidEntry samEntry, GuidEntry mygroupEntry) { HashSet<String> expected = new HashSet<String>(Arrays.asList(samEntry.getGuid())); HashSet<String> actual = null; int count = 50; // try 10 times or so do {/*from ww w. j av a 2 s.c o m*/ try { if (count != 50) { Thread.sleep(100); } actual = JSONUtils.JSONArrayToHashSet(client.groupGetMembers(mygroupEntry.getGuid(), mygroupEntry)); } catch (ClientException | IOException | JSONException | InterruptedException e) { } } while (count-- > 0 && (actual == null || !actual.equals(expected))); if (count < 49) { System.out.println("Waited " + (49 - count) + " times"); } Assert.assertEquals(expected, actual); }