IndexRecord extends BrowsableRecord<Text, Value, PrimaryKey> { public Map<PrimaryKey, Set<Value>> explore(long timestamp, Operator operator, Value... values) { return explore(true, timestamp, operator, values); } @DoNotInvoke @PackagePrivate  IndexRecord(Text locator, @Nullable Value key); static IndexRecord create(Text locator); static IndexRecord createPartial(Text locator, Value key); Map<PrimaryKey, Set<Value>> explore(long timestamp,
            Operator operator, Value... values); Map<PrimaryKey, Set<Value>> explore(Operator operator,
            Value... values); Set<PrimaryKey> find(long timestamp, Operator operator,
            Value... values); Set<PrimaryKey> find(Operator operator, Value... values); Set<Value> gather(PrimaryKey record); Set<Value> gather(PrimaryKey record, long timestamp);  }
@Test public void testFindBrowseOnlyReturnsRelevantData() { Text locator = TestData.getText(); record = getRecord(locator); for (int i = 0; i < 100; i++) { for (int j = 0; j <= i; j++) { record.append(getRevision(locator, Value.wrap(Convert.javaToThrift(j)), PrimaryKey.wrap(i))); } } Map<PrimaryKey, Set<Value>> data = ((IndexRecord) record).explore( Operator.GREATER_THAN, Value.wrap(Convert.javaToThrift(50))); for (int i = 0; i < 100; i++) { PrimaryKey pk = PrimaryKey.wrap(i); if(i > 50) { Assert.assertTrue(data.containsKey(pk)); Assert.assertEquals(i - 50, data.get(pk).size()); for (Value value : data.get(pk)) { Assert.assertTrue(value.compareTo( Value.wrap(Convert.javaToThrift(50))) > 0); } } else { Assert.assertFalse(data.containsKey(pk)); } } }
@Test public void testCaseInsensitiveValuesNotLost() { Text locator = Text.wrap("major"); record = getRecord(locator); record.append(getRevision(locator, Value.wrap(Convert.javaToThrift("Business Management")), PrimaryKey.wrap(1))); record.append(getRevision(locator, Value.wrap(Convert.javaToThrift("business management")), PrimaryKey.wrap(2))); IndexRecord index = (IndexRecord) record; Map<PrimaryKey, Set<Value>> data = index.explore(Operator.REGEX, Value.wrap(Convert.javaToThrift(".*business.*"))); Assert.assertFalse(data.isEmpty()); }