List of usage examples for java.lang String hashCode
public int hashCode()
From source file:com.alibaba.china.talos.service.impl.AuthDataItemTransportAO.java
/** * @param relatedBizId/* w w w .j av a2 s . c o m*/ * @return */ private String getAuthDataItemRelationTableName(String relatedBizId) { return "auth_data_item_relation_" + StringUtils.leftPad("" + (Math.abs(relatedBizId.hashCode()) % 64), 4, "0"); }
From source file:net.demilich.metastone.game.behaviour.decicionTreeBheavior.DecisionDataBase.java
public synchronized void addExample(GameContext context, String actionName, Player player, int label) { //we want to add an example to the knowledge that hash the same actionName int index = hashToIndex.get(actionName.hashCode()); if (index == -1) { System.err.println("could not find " + actionName); return;//from w w w . j a va 2 s .c o m } CardContextKnowledge knowledge = database[index]; //populate feature data reset(); this.furfillOrder(context, this.featureAndHash[0], null, player); //furfillAll(context,player); //add the example knowledge.addExample(this.featureData.clone(), label); }
From source file:com.github.stephanarts.cas.ticket.registry.provider.AddMethod.java
/** * Execute the JSONRPCFunction.//from www. j av a2s . c o m * * @param params JSONRPC Method Parameters. * * @return JSONRPC result object * * @throws JSONRPCException implementors can throw JSONRPCExceptions containing the error. */ public JSONObject execute(final JSONObject params) throws JSONRPCException { JSONObject result = new JSONObject(); String ticketId = null; String serializedTicket = null; Ticket ticket = null; logger.debug("Add Ticket"); if (params.length() != 2) { throw new JSONRPCException(-32602, "Invalid Params"); } if (!(params.has("ticket-id") && params.has("ticket"))) { throw new JSONRPCException(-32602, "Invalid Params"); } try { ticketId = params.getString("ticket-id"); serializedTicket = params.getString("ticket"); ByteArrayInputStream bi = new ByteArrayInputStream( DatatypeConverter.parseBase64Binary(serializedTicket)); ObjectInputStream si = new ObjectInputStream(bi); ticket = (Ticket) si.readObject(); } catch (final Exception e) { throw new JSONRPCException(-32501, "Could not decode Ticket"); } if (this.map.containsKey(ticketId.hashCode())) { logger.error("Duplicate Key {}", ticketId); throw new JSONRPCException(-32502, "Duplicate Ticket"); } else { this.map.put(ticketId.hashCode(), ticket); } logger.debug("Ticket-ID '{}'", ticketId); return result; }
From source file:au.edu.uws.eresearch.cr8it.TransformationHandler.java
private String getJsonMapping(String jsonString) throws IOException, ParseException { String template = readFile("./template.json"); JSONParser parser = new JSONParser(); JSONObject original = (JSONObject) parser.parse(template); JSONObject manifest = (JSONObject) parser.parse(jsonString); JSONObject dataObject = (JSONObject) original.get("data"); JSONArray dataArray = (JSONArray) dataObject.get("data"); JSONArray creators = (JSONArray) manifest.get("creators"); JSONArray activities = (JSONArray) manifest.get("activities"); JSONArray vfs = (JSONArray) manifest.get("vfs"); LocalDate today = new LocalDate(); int creatorIndex = 1; int grantIndex = 1; for (Object data : dataArray) { ((JSONObject) data).put("datasetId", jsonString.hashCode()); JSONObject tfpackage = (JSONObject) ((JSONObject) data).get("tfpackage"); tfpackage.put("dc:created", today.toString()); Object root = vfs.get(0); if (root != null) { String crateName = (String) ((JSONObject) root).get("name"); tfpackage.put("dc:title", crateName); tfpackage.put("title", crateName); }//from w ww.j av a 2 s.com for (Object creator : creators) { //TODO we might need to split the name into first and last name String name = (String) ((JSONObject) creator).get("name"); tfpackage.put("dc:creator.foaf:Person." + creatorIndex + ".foaf:name", name); String identifier = (String) ((JSONObject) creator).get("identifier"); tfpackage.put("dc:creator.foaf:Person." + creatorIndex + ".dc:identifier", identifier); creatorIndex++; } for (Object activity : activities) { String identifier = (String) ((JSONObject) activity).get("identifier"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".dc:identifier", identifier); String grantNumber = (String) ((JSONObject) activity).get("grant_number"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".redbox:grantNumber", grantNumber); String title = (String) ((JSONObject) activity).get("title"); String repositoryName = (String) ((JSONObject) activity).get("repository_name"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".skos:prefLabel", "(" + repositoryName + ") " + title); grantIndex++; } } String updatedJson = original.toJSONString(); return updatedJson; }
From source file:fuse.okuyamafs.OkuyamaFilesystem.java
public int flush(String path, Object fh) throws FuseException { synchronized (this.parallelDataAccessSync[((path.hashCode() << 1) >>> 1) % 100]) { log.info("flush " + path + " " + fh); List bufferedDataFhList = writeBufFpMap.removeGroupingData(path); if (bufferedDataFhList != null) { for (int idx = 0; idx < bufferedDataFhList.size(); idx++) { Object bFh = bufferedDataFhList.get(idx); this.fixNoCommitData(bFh); }//ww w . ja v a 2s.c o m } this.fixNoCommitData(fh); } return 0; }
From source file:com.opengamma.integration.timeseries.snapshot.CronTriggerComponentFactory.java
@Override protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -281470431: // classifier setClassifier((String) newValue); return;//from ww w . ja va2 s . c om case -1438096408: // jobName setJobName((String) newValue); return; case -1637271358: // jobGroup setJobGroup((String) newValue); return; case 3373707: // name setName((String) newValue); return; case -348729402: // cronExpression setCronExpression((String) newValue); return; case 836243736: // schemeBlackList setSchemeBlackList((String) newValue); return; case 1058119597: // dataFieldBlackList setDataFieldBlackList((String) newValue); return; case 1272470629: // dataSource setDataSource((String) newValue); return; case 650692196: // normalizationRuleSetId setNormalizationRuleSetId((String) newValue); return; case 951232793: // observationTime setObservationTime((String) newValue); return; case -747889643: // globalPrefix setGlobalPrefix((String) newValue); return; case -1707859415: // htsMaster setHtsMaster((HistoricalTimeSeriesMaster) newValue); return; case -745461486: // redisConnector setRedisConnector((RedisConnector) newValue); return; case -332642308: // baseDir setBaseDir((String) newValue); return; case -160710469: // scheduler setScheduler((Scheduler) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:net.schweerelos.parrot.ui.GraphViewComponent.java
private String getLayoutFilename() { String dataID = model.getDataIdentifier(); int lastSlashIndex = dataID.lastIndexOf(File.separatorChar); int lastDotIndex = dataID.lastIndexOf('.'); String filename;/*from ww w . java 2 s . co m*/ if (lastSlashIndex < lastDotIndex) { // this is what we prefer filename = dataID.substring(lastSlashIndex, lastDotIndex); } else { filename = new StringBuilder(dataID.hashCode()).toString(); } return System.getProperty("user.home") + File.separator + ".digital-parrot" + File.separator + filename + LAYOUT_SUFFIX; }
From source file:fuse.okuyamafs.OkuyamaFilesystem.java
public int fsync(String path, Object fh, boolean isDatasync) throws FuseException { synchronized (this.parallelDataAccessSync[((path.hashCode() << 1) >>> 1) % 100]) { log.info("fsync " + path + " " + fh + " " + isDatasync); List bufferedDataFhList = writeBufFpMap.removeGroupingData(path); if (bufferedDataFhList != null) { for (int idx = 0; idx < bufferedDataFhList.size(); idx++) { Object bFh = bufferedDataFhList.get(idx); this.fixNoCommitData(bFh); }/*from w w w. j a va 2 s . c o m*/ } this.fixNoCommitData(fh); } return 0; }
From source file:ch.epfl.data.squall.operators.ApproximateCountSketchOperator2.java
@Override public List<String> processOne(List<String> tuple, long lineageTimestamp) { // System.out.println("ZKM: processOne(" + tuple + ")"); _numTuplesProcessed++;/*from ww w .j a v a 2s . c o m*/ if (_numTuplesProcessed % 1000 == 0) { System.out.println("ZKM: processed: " + _numTuplesProcessed); } if (_distinct != null) { tuple = _distinct.processOne(tuple, lineageTimestamp); if (tuple == null) return null; } String tupleHash; if (_groupByType == GB_PROJECTION) tupleHash = MyUtilities.createHashString(tuple, _groupByColumns, _groupByProjection.getExpressions(), _map); else tupleHash = MyUtilities.createHashString(tuple, _groupByColumns, _map); // final Long value = _storage.update(tuple, tupleHash); // final String strValue = _wrapper.toString(value); final String strValue = "1"; // propagate further the affected tupleHash-tupleValue pair final List<String> affectedTuple = new ArrayList<String>(); affectedTuple.add(tupleHash); affectedTuple.add(strValue); // long k = (new Long(tupleHash)).longValue(); long k = tupleHash.hashCode(); long v = _scm.UpdateSketch(k, 1); // System.out.println("ZKM: " + k + " has count " + v + ", adding \"" + tupleHash + "\" to _unique_keys"); _unique_keys.add(tupleHash); // System.out.println("ZKM: affectedTuple == " + affectedTuple); return affectedTuple; }
From source file:com.chinamobile.bcbsp.graph.GraphDataForDisk.java
@Override public synchronized void addForAll(Vertex vertex) { this.sizeForAll++; String vertexID = String.valueOf(vertex.getVertexID()); int hashCode = vertexID.hashCode(); int hashIndex = hashCode % this.hashBucketNumber; // bucket index hashIndex = (hashIndex < 0 ? hashIndex + this.hashBucketNumber : hashIndex); /* Add the vertex to the right hash bucket. */ ArrayList<Vertex> hashBucket = this.hashBuckets.get(hashIndex); // When the hash bucket reference is null, create a bucket. if (hashBucket == null) { hashBucket = new ArrayList<Vertex>(); }/*from w ww . j a va 2 s . c o m*/ hashBucket.add(vertex); this.hashBuckets.set(hashIndex, hashBucket); // Evaluate the memory size of the new Vertex. int newVertexSize = this.sizeOfRef + this.sizer.sizeOf(vertex); this.totalSizeOfVertex += newVertexSize; this.totalCountOfVertex++; this.totalCountOfEdge += vertex.getEdgesNum(); /** Add the vertex's size to the length of the bucket's meta. */ BucketMeta meta = this.metaTable.get(hashIndex); meta.length = meta.length + newVertexSize; meta.lengthInMemory = meta.lengthInMemory + newVertexSize; meta.count = meta.count + 1; meta.activeCount = meta.activeCount + 1; this.metaTable.set(hashIndex, meta); /* Add the headnode's size to the graph data's size. */ this.sizeOfGraphDataInMem = this.sizeOfGraphDataInMem + newVertexSize; /* Set the bitmap's refered bit to 1 */ setBitmapTrue(hashIndex, meta.activeCount - 1, this.bitmaps); // Add a new Integer into the bitmaps every 8 nodes added. if (this.sizeForAll % 32 == 1) { this.sizeOfBitmapsInMem = this.sizeOfBitmapsInMem + this.sizeOfInteger + this.sizeOfRef; } onVertexAdded(); }