List of usage examples for java.util Arrays hashCode
public static int hashCode(Object a[])
From source file:com.jivesoftware.os.amza.service.storage.WALStorage.java
private void mergeStripedKeyHighwaters(byte[] prefix, byte[] key, long valueTimestamp, long[] keyHighwaterTimestamps) throws Exception { int highwaterTimestampIndex = Math .abs((Arrays.hashCode(prefix) ^ Arrays.hashCode(key)) % keyHighwaterTimestamps.length); keyHighwaterTimestamps[highwaterTimestampIndex] = Math.max(keyHighwaterTimestamps[highwaterTimestampIndex], valueTimestamp);// www . j av a 2 s . c o m }
From source file:com.jivesoftware.os.amza.service.storage.WALStorage.java
private long getLargestTimestampForKeyStripe(byte[] prefix, byte[] key, long[] keyHighwaterTimestamps) { int highwaterTimestampIndex = Math .abs((Arrays.hashCode(prefix) ^ Arrays.hashCode(key)) % keyHighwaterTimestamps.length); return keyHighwaterTimestamps[highwaterTimestampIndex]; }
From source file:io.gatling.jsonbenchmark.serialization.model.StringPerformance.java
@Override public int hashCode() { return str != null ? Arrays.hashCode(str) : 0; }
From source file:org.opendaylight.controller.cluster.raft.behaviors.LeaderTest.java
@Test public void testHandleSnapshotSendsPreviousChunksHashCodeWhenSendingNextChunk() throws Exception { logStart("testHandleSnapshotSendsPreviousChunksHashCodeWhenSendingNextChunk"); MockRaftActorContext actorContext = createActorContextWithFollower(); final int commitIndex = 3; final int snapshotIndex = 2; final int snapshotTerm = 1; final int currentTerm = 2; actorContext.setConfigParams(new DefaultConfigParamsImpl() { @Override/*ww w . j a va 2 s .c o m*/ public int getSnapshotChunkSize() { return 50; } }); actorContext.setCommitIndex(commitIndex); leader = new Leader(actorContext); leader.getFollower(FOLLOWER_ID).setMatchIndex(-1); leader.getFollower(FOLLOWER_ID).setNextIndex(0); Map<String, String> leadersSnapshot = new HashMap<>(); leadersSnapshot.put("1", "A"); leadersSnapshot.put("2", "B"); leadersSnapshot.put("3", "C"); // set the snapshot variables in replicatedlog actorContext.getReplicatedLog().setSnapshotIndex(snapshotIndex); actorContext.getReplicatedLog().setSnapshotTerm(snapshotTerm); actorContext.getTermInformation().update(currentTerm, leaderActor.path().toString()); ByteString bs = toByteString(leadersSnapshot); Snapshot snapshot = Snapshot.create(ByteState.of(bs.toByteArray()), Collections.<ReplicatedLogEntry>emptyList(), commitIndex, snapshotTerm, commitIndex, snapshotTerm, -1, null, null); leader.handleMessage(leaderActor, new SendInstallSnapshot(snapshot, ByteSource.wrap(bs.toByteArray()))); InstallSnapshot installSnapshot = MessageCollectorActor.expectFirstMatching(followerActor, InstallSnapshot.class); assertEquals(1, installSnapshot.getChunkIndex()); assertEquals(3, installSnapshot.getTotalChunks()); assertEquals(LeaderInstallSnapshotState.INITIAL_LAST_CHUNK_HASH_CODE, installSnapshot.getLastChunkHashCode().get().intValue()); final int hashCode = Arrays.hashCode(installSnapshot.getData()); followerActor.underlyingActor().clear(); leader.handleMessage(followerActor, new InstallSnapshotReply(installSnapshot.getTerm(), FOLLOWER_ID, 1, true)); installSnapshot = MessageCollectorActor.expectFirstMatching(followerActor, InstallSnapshot.class); assertEquals(2, installSnapshot.getChunkIndex()); assertEquals(3, installSnapshot.getTotalChunks()); assertEquals(hashCode, installSnapshot.getLastChunkHashCode().get().intValue()); }
From source file:org.kuali.kra.proposaldevelopment.hierarchy.service.impl.ProposalHierarchyServiceImpl.java
protected void aggregateHierarchy(DevelopmentProposal hierarchy) throws ProposalHierarchyException { LOG.info(String.format("***Aggregating Proposal Hierarchy #%s", hierarchy.getProposalNumber())); List<ProposalPersonBiography> biosToRemove = new ArrayList<ProposalPersonBiography>(); for (ProposalPersonBiography bio : hierarchy.getPropPersonBios()) { loadBioContent(bio);/*from www . j a v a 2 s .c om*/ String bioPersonId = bio.getPersonId(); Integer bioRolodexId = bio.getRolodexId(); boolean keep = false; for (ProposalPerson person : hierarchy.getProposalPersons()) { if ((bioPersonId != null && bioPersonId.equals(person.getPersonId())) || (bioRolodexId != null && bioRolodexId.equals(person.getRolodexId()))) { bio.setProposalPersonNumber(person.getProposalPersonNumber()); for (ProposalPersonBiographyAttachment attachment : bio.getPersonnelAttachmentList()) { attachment.setProposalPersonNumber(person.getProposalPersonNumber()); } keep = true; break; } } if (!keep) { biosToRemove.add(bio); } } if (!biosToRemove.isEmpty()) { hierarchy.getPropPersonBios().removeAll(biosToRemove); } BudgetDocument<DevelopmentProposal> hierarchyBudgetDocument = getHierarchyBudget(hierarchy); Budget hierarchyBudget = hierarchyBudgetDocument.getBudget(); hierarchyBudget.getBudgetCostShares().clear(); hierarchyBudget.getBudgetUnrecoveredFandAs().clear(); Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("hiddenInHierarchy", true); fieldValues.put("budgetId", hierarchyBudget.getBudgetId()); Collection<BudgetCostShare> hiddenCostShares = businessObjectService.findMatching(BudgetCostShare.class, fieldValues); Collection<BudgetUnrecoveredFandA> hiddenUnrecoveredFandAs = businessObjectService .findMatching(BudgetUnrecoveredFandA.class, fieldValues); Map<Integer, BudgetCostShare> newCostShares = new HashMap<Integer, BudgetCostShare>(); Map<Integer, BudgetUnrecoveredFandA> newUnrecoveredFandAs = new HashMap<Integer, BudgetUnrecoveredFandA>(); BudgetCostShare newCostShare; BudgetUnrecoveredFandA newUnrecoveredFandA; Integer keyHash; for (BudgetCostShare costShare : hiddenCostShares) { keyHash = Arrays.hashCode(new Object[] { costShare.getProjectPeriod(), costShare.getSourceAccount() }); newCostShare = newCostShares.get(keyHash); if (newCostShare == null) { newCostShare = (BudgetCostShare) ObjectUtils.deepCopy(costShare); //newCostShare.setBudgetId(hierarchyBudget.getBudgetId()); newCostShare.setDocumentComponentId(null); newCostShare.setObjectId(null); newCostShare.setVersionNumber(null); newCostShares.put(keyHash, newCostShare); } else { newCostShare .setSharePercentage(newCostShare.getSharePercentage().add(costShare.getSharePercentage())); if (newCostShare.getSharePercentage().isGreaterThan(new BudgetDecimal(100.0))) { newCostShare.setSharePercentage(new BudgetDecimal(100.0)); } newCostShare.setShareAmount(newCostShare.getShareAmount().add(costShare.getShareAmount())); } } for (BudgetUnrecoveredFandA unrecoveredFandA : hiddenUnrecoveredFandAs) { keyHash = Arrays .hashCode(new Object[] { unrecoveredFandA.getFiscalYear(), unrecoveredFandA.getSourceAccount(), unrecoveredFandA.getApplicableRate(), unrecoveredFandA.getOnCampusFlag() }); newUnrecoveredFandA = newUnrecoveredFandAs.get(keyHash); if (newUnrecoveredFandA == null) { newUnrecoveredFandA = (BudgetUnrecoveredFandA) ObjectUtils.deepCopy(unrecoveredFandA); newUnrecoveredFandA.setBudgetId(hierarchyBudget.getBudgetId()); newUnrecoveredFandA.setDocumentComponentId(null); newUnrecoveredFandA.setObjectId(null); newUnrecoveredFandA.setVersionNumber(null); newUnrecoveredFandAs.put(keyHash, newUnrecoveredFandA); } else { newUnrecoveredFandA.setAmount(newUnrecoveredFandA.getAmount().add(unrecoveredFandA.getAmount())); } } for (BudgetCostShare costShare : newCostShares.values()) { costShare.setHiddenInHierarchy(false); costShare.setHierarchyProposalNumber(null); hierarchyBudget.add(costShare); } for (BudgetUnrecoveredFandA unrecoveredFandA : newUnrecoveredFandAs.values()) { unrecoveredFandA.setHiddenInHierarchy(false); unrecoveredFandA.setHierarchyProposalNumber(null); hierarchyBudget.add(unrecoveredFandA); } KualiForm oldForm = GlobalVariables.getKualiForm(); GlobalVariables.setKualiForm(null); KraServiceLocator.getService(BudgetCalculationService.class).calculateBudget(hierarchyBudget); KraServiceLocator.getService(BudgetCalculationService.class).calculateBudgetSummaryTotals(hierarchyBudget); GlobalVariables.setKualiForm(oldForm); try { documentService.saveDocument(hierarchyBudgetDocument); } catch (WorkflowException e) { throw new ProposalHierarchyException(e); } }
From source file:eu.europa.ec.markt.tlmanager.core.validation.Validation.java
/** * 5.5.3 Service digital identity/*from w w w. java2s . co m*/ * <p/> * The same public key (and hence the same certificate representing this public key) shall not appear * more than once in the trusted list for the same type of service. The same public key may appear * more than once in the TL only when associated to trust services having different 'Service type * identifier' ('Sti') values (e.g. public key used for verifying signatures on different types of Trust * Services Tokens) for which different supervision/ accreditation systems apply. */ private void checkRuleUniqueSDIperService() { if (services != null) { Set<String> keySet = new HashSet<String>(); for (TSPServiceType service : services) { // both values are mandatory and are supposed to be present at this point String sti = service.getServiceInformation().getServiceTypeIdentifier(); DigitalIdentityListType sdi = service.getServiceInformation().getServiceDigitalIdentity(); byte[] publicKey = null; for (DigitalIdentityType id : sdi.getDigitalId()) { // 1-2 entries if (publicKey == null) { try { byte[] x509Certificate = id.getX509Certificate(); final X509Certificate x509 = DSSUtils.loadCertificate(x509Certificate); publicKey = x509.getPublicKey().getEncoded(); continue; } catch (DSSException e) { LOG.log(Level.SEVERE, e.getMessage(), e); } } else { break; } } String couple = sti + Arrays.hashCode(publicKey); if (keySet.contains(couple)) { logger.error(uiKeys.getString("Validation.rule.uniqueSDIperService"), service); } else { keySet.add(couple); } } } }
From source file:bammerbom.ultimatecore.bukkit.resources.utils.JsonRepresentedObject.java
/** * Gets the hash code represented by this objects value. * * @return This object's hash code.//from www . j a va 2s .com * @see Arrays#hashCode(Object[]) */ @Override public int hashCode() { return Arrays.hashCode(_array); }
From source file:org.bimserver.geometry.StreamingGeometryGenerator.java
int hash(VirtualObject geometryData) { int hashCode = 0; if (geometryData.has("indices")) { hashCode += Arrays.hashCode(extractBufferData(geometryData.get("indices"))); }/*from w ww .jav a 2s . c o m*/ if (geometryData.has("vertices")) { hashCode += Arrays.hashCode(extractBufferData(geometryData.get("vertices"))); } if (geometryData.has("normals")) { hashCode += Arrays.hashCode(extractBufferData(geometryData.get("normals"))); } if (geometryData.has("colorsQuantized")) { hashCode += Arrays.hashCode(extractBufferData(geometryData.get("colorsQuantized"))); } if (geometryData.has("color")) { hashCode += ((HashMapWrappedVirtualObject) geometryData.get("color")).hashCode(); } return hashCode; }
From source file:de.vanita5.twittnuker.util.Utils.java
public static int getAccountNotificationId(final int notificationType, final long accountId) { return Arrays.hashCode(new long[] { notificationType, accountId }); }