List of usage examples for java.lang String hashCode
public int hashCode()
From source file:net.myrrix.online.eval.AbstractEvaluator.java
private static DataFileContents readDataFile(File dataDir, double evaluationPercentage, RescorerProvider provider) throws IOException { // evaluationPercentage filters per user and item, not per datum, since time scales with users and // items. We select sqrt(evaluationPercentage) of users and items to overall select about evaluationPercentage // of all data. int perMillion = (int) (1000000 * FastMath.sqrt(evaluationPercentage)); Multimap<Long, RecommendedItem> data = ArrayListMultimap.create(); Multimap<String, RecommendedItem> itemTags = ArrayListMultimap.create(); Multimap<String, RecommendedItem> userTags = ArrayListMultimap.create(); for (File dataFile : dataDir.listFiles(new PatternFilenameFilter(".+\\.csv(\\.(zip|gz))?"))) { log.info("Reading {}", dataFile); int count = 0; for (CharSequence line : new FileLineIterable(dataFile)) { Iterator<String> parts = COMMA_TAB_SPLIT.split(line).iterator(); String userIDString = parts.next(); if (userIDString.hashCode() % 1000000 <= perMillion) { String itemIDString = parts.next(); if (itemIDString.hashCode() % 1000000 <= perMillion) { Long userID = null; boolean userIsTag = userIDString.startsWith("\""); if (!userIsTag) { userID = Long.valueOf(userIDString); }//from w ww .jav a 2s. c o m boolean itemIsTag = itemIDString.startsWith("\""); Long itemID = null; if (!itemIsTag) { itemID = Long.valueOf(itemIDString); } Preconditions.checkArgument(!(userIsTag && itemIsTag), "Can't have a user tag and item tag in one line"); if (parts.hasNext()) { String token = parts.next().trim(); if (!token.isEmpty()) { float value = LangUtils.parseFloat(token); if (userIsTag) { itemTags.put(userIDString, new GenericRecommendedItem(itemID, value)); } else if (itemIsTag) { userTags.put(itemIDString, new GenericRecommendedItem(userID, value)); } else { if (provider != null) { IDRescorer rescorer = provider.getRecommendRescorer(new long[] { userID }, null); if (rescorer != null) { value = (float) rescorer.rescore(itemID, value); } } data.put(userID, new GenericRecommendedItem(itemID, value)); } } // Ignore remove lines } else { if (userIsTag) { itemTags.put(userIDString, new GenericRecommendedItem(itemID, 1.0f)); } else if (itemIsTag) { userTags.put(itemIDString, new GenericRecommendedItem(userID, 1.0f)); } else { float value = 1.0f; if (provider != null) { IDRescorer rescorer = provider.getRecommendRescorer(new long[] { userID }, null); if (rescorer != null) { value = (float) rescorer.rescore(itemID, value); } } data.put(userID, new GenericRecommendedItem(itemID, value)); } } } } if (++count % 1000000 == 0) { log.info("Finished {} lines", count); } } } return new DataFileContents(data, itemTags, userTags); }
From source file:com.mawujun.util.AnnotationUtils.java
/** * Helper method for generating a hash code for a member of an annotation. * * @param name the name of the member//from www.j a v a 2 s .c o m * @param value the value of the member * @return a hash code for this member */ private static int hashMember(String name, Object value) { int part1 = name.hashCode() * 127; if (value.getClass().isArray()) { return part1 ^ arrayMemberHash(value.getClass().getComponentType(), value); } if (value instanceof Annotation) { return part1 ^ hashCode((Annotation) value); } return part1 ^ value.hashCode(); }
From source file:Main.java
public static String getDeviceUUID(Context context) { @SuppressWarnings("static-access") final TelephonyManager tm = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, tmPhone, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); String uniqueId = deviceUuid.toString(); Log.d("debug", "uuid=" + uniqueId); return uniqueId; }
From source file:main.java.utils.Utility.java
public static long javaHash(String key) { return key.hashCode(); }
From source file:Main.java
/** * this generate the device Id/* w ww. j av a 2s. c o m*/ * * @param baseContext * @param contentResolver * @return */ //http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id public static String generateDeviceId(Context baseContext, ContentResolver contentResolver) { final TelephonyManager tm = (TelephonyManager) baseContext.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, androidId; tmDevice = String.valueOf(tm.getDeviceId()); tmSerial = String.valueOf(tm.getSimSerialNumber()); androidId = String.valueOf(android.provider.Settings.Secure.getString(contentResolver, android.provider.Settings.Secure.ANDROID_ID)); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); return deviceUuid.toString(); }
From source file:Main.java
public static String getDeviceId(Context context) { if (deviceId == null) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice, tmSerial, tmPhone, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); deviceId = deviceUuid.toString(); System.err.println(deviceId); }/* w ww . j av a 2 s . co m*/ return deviceId; }
From source file:com.njlabs.amrita.aid.util.Identifier.java
@SuppressLint("HardwareIds") public static String identify(Context context) { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); final String tmDevice, tmSerial, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); return deviceUuid.toString(); }
From source file:com.ge.predix.acs.policy.evaluation.cache.AbstractPolicyEvaluationCache.java
static String subjectKey(final String zoneId, final String subjectId) { return zoneId + ":sub-id:" + Integer.toHexString(subjectId.hashCode()); }
From source file:com.ge.predix.acs.policy.evaluation.cache.AbstractPolicyEvaluationCache.java
static String resourceKey(final String zoneId, final String resourceId) { return zoneId + ":res-id:" + Integer.toHexString(resourceId.hashCode()); }
From source file:com.ge.predix.acs.policy.evaluation.cache.AbstractPolicyEvaluationCache.java
static String resourceTranslationKey(final String zoneId, final String resourceId) { return zoneId + ":rtr-id:" + Integer.toHexString(resourceId.hashCode()); }