@Override public boolean equals(Object obj) { if(obj instanceof HollowObject) { HollowObject hollowObj = (HollowObject)obj; if(ordinal == hollowObj.getOrdinal()) { String otherType = hollowObj.getSchema().getName(); String myType = getSchema().getName(); return myType.equals(otherType); } } return false; }
@Test public void test() { HashIndex<T, Q> hi = HashIndex .from(consumer, selectType) .usingPath(path, type); List<T> r = hi .findMatches(value) .collect(toList()); Assert.assertEquals(1, r.size()); Assert.assertTrue(selectType.isInstance(r.get(0))); Assert.assertEquals(0, r.get(0).getOrdinal()); } }
@Override public String toString() { return "Hollow Object: " + getSchema().getName() + " (" + ordinal + ")"; }
private boolean setOrderingExists(HollowSetTypeReadState bTypeState, String... orderedCValues) { for(int i=0;i<=bTypeState.maxOrdinal();i++) { GenericHollowSet set = new GenericHollowSet(bTypeState, i); Iterator<HollowRecord> iter = set.iterator(); for(int j=0;j<orderedCValues.length;j++) { if(!iter.hasNext()) break; HollowObject obj = (HollowObject)iter.next(); String cValue = obj.getString("c1"); if(!cValue.equals(orderedCValues[j])) break; if(j == (orderedCValues.length - 1)) return true; } } return false; }
@Test public void test() { UniqueKeyIndex<T, Q> pki = UniqueKeyIndex .from(consumer, uniqueType) .usingPath(path, type); T r = pki.findMatch(value); Assert.assertNotNull(r); Assert.assertEquals(0, r.getOrdinal()); } }
private void assertRecord(HollowObject obj, String fnPrefix, int... vals) { for (int i = 0; i < vals.length; i++) { String fn = fnPrefix + (i + 1); Assert.assertEquals(vals[i], obj.getInt(fn)); } }