@Test public void testSanity() { final String[] strings = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}; Indexed<String> indexed = GenericIndexed.fromArray(strings, GenericIndexed.STRING_STRATEGY); checkBasicAPIs(strings, indexed, true); Assert.assertEquals(-13, indexed.indexOf("q")); Assert.assertEquals(-9, indexed.indexOf("howdydo")); Assert.assertEquals(-1, indexed.indexOf("1111")); }
if (dimValues != null && !allNull(dimValues)) { dimHasValues = true; hasNull |= dimValues.indexOf(null) >= 0; dimValueLookups[i] = dimValueLookup = dimValues; numMergeIndex++;
private void checkBasicAPIs(String[] strings, Indexed<String> index, boolean allowReverseLookup) { Assert.assertEquals(strings.length, index.size()); for (int i = 0; i < strings.length; i++) { Assert.assertEquals(strings[i], index.get(i)); } if (allowReverseLookup) { HashMap<String, Integer> mixedUp = new HashMap<>(); for (int i = 0; i < strings.length; i++) { mixedUp.put(strings[i], i); } for (Map.Entry<String, Integer> entry : mixedUp.entrySet()) { Assert.assertEquals(entry.getValue().intValue(), index.indexOf(entry.getKey())); } } else { try { index.indexOf("xxx"); Assert.fail("should throw exception"); } catch (UnsupportedOperationException e) { // not supported } } }
if (dimValues != null && !allNull(dimValues)) { dimHasValues = true; hasNull |= dimValues.indexOf(null) >= 0; dimValueLookups[i] = dimValueLookup = dimValues; numMergeIndex++;