@Test public void indexOf() { HashFunction yearMonthFunction = new DateAppIdHashFunction(0); Assert.assertEquals(yearMonthFunction.indexOf("201909"), 201909); }
@Override public int indexOf(Object key) { String hashKey = String.valueOf(key); Matcher matcher = pattern.matcher(hashKey); if (matcher.matches()) { YearMonth yearMonth = YearMonth.parse(hashKey, yearMonthFormatter); return yearMonth.getYear() * 100 + yearMonth.getMonthValue(); } int appIdValue = partitions != 0 ? Math.abs(hashKey.hashCode()) % partitions : 0; return appIdValue; }
DateAppIdHashFunction implements HashFunction { @Override public int indexOf(Object key) { String hashKey = String.valueOf(key); Matcher matcher = pattern.matcher(hashKey); if (matcher.matches()) { YearMonth yearMonth = YearMonth.parse(hashKey, yearMonthFormatter); return yearMonth.getYear() * 100 + yearMonth.getMonthValue(); } int appIdValue = partitions != 0 ? Math.abs(hashKey.hashCode()) % partitions : 0; return appIdValue; } }
DateAppIdHashFunction implements HashFunction { @Override public int indexOf(Object key) { String hashKey = String.valueOf(key); Matcher matcher = pattern.matcher(hashKey); if (matcher.matches()) { YearMonth yearMonth = YearMonth.parse(hashKey, yearMonthFormatter); return yearMonth.getYear() * 100 + yearMonth.getMonthValue(); } int appIdValue = partitions != 0 ? Math.abs(hashKey.hashCode()) % partitions : 0; return appIdValue; } DateAppIdHashFunction();  DateAppIdHashFunction(int partitions); }
DateAppIdHashFunction implements HashFunction { @Override public int indexOf(Object key) { String hashKey = String.valueOf(key); Matcher matcher = pattern.matcher(hashKey); if (matcher.matches()) { YearMonth yearMonth = YearMonth.parse(hashKey, yearMonthFormatter); return yearMonth.getYear() * 100 + yearMonth.getMonthValue(); } int appIdValue = partitions != 0 ? Math.abs(hashKey.hashCode()) % partitions : 0; return appIdValue; } DateAppIdHashFunction();  DateAppIdHashFunction(int partitions); @Override int indexOf(Object key); @Override int indexOf(List<Object> keys); @Override HashType getType(); }
DateAppIdHashFunction implements HashFunction { @Override public int indexOf(Object key) { String hashKey = String.valueOf(key); Matcher matcher = pattern.matcher(hashKey); if (matcher.matches()) { YearMonth yearMonth = YearMonth.parse(hashKey, yearMonthFormatter); return yearMonth.getYear() * 100 + yearMonth.getMonthValue(); } int appIdValue = partitions != 0 ? Math.abs(hashKey.hashCode()) % partitions : 0; return appIdValue; } DateAppIdHashFunction();  DateAppIdHashFunction(int partitions); @Override int indexOf(Object key); @Override int indexOf(List<Object> keys); @Override HashType getType();  }