public GenericHollowObject(HollowDataAccess dataAccess, String typeName, int ordinal) { this((HollowObjectTypeDataAccess)dataAccess.getTypeDataAccess(typeName, ordinal), ordinal); }
public GenericHollowMap(HollowDataAccess dataAccess, String type, int ordinal) { this((HollowMapTypeDataAccess)dataAccess.getTypeDataAccess(type, ordinal), ordinal); }
public GenericHollowList(HollowDataAccess dataAccess, String type, int ordinal) { this((HollowListTypeDataAccess)dataAccess.getTypeDataAccess(type, ordinal), ordinal); }
public GenericHollowSet(HollowDataAccess dataAccess, String type, int ordinal) { this((HollowSetTypeDataAccess)dataAccess.getTypeDataAccess(type, ordinal), ordinal); }
@Override public HollowTypeDataAccess getTypeDataAccess(String typeName, int ordinal) { HollowDataAccess state = this; while(state instanceof HollowHistoricalStateDataAccess) { HollowHistoricalStateDataAccess historicalState = (HollowHistoricalStateDataAccess)state; if(historicalState.getOrdinalMapping().ordinalIsMapped(typeName, ordinal)) return state.getTypeDataAccess(typeName); state = historicalState.getNextState(); } return state.getTypeDataAccess(typeName); }
public HollowEffigy effigy(HollowDataAccess dataAccess, String typeName, int ordinal) { if(ordinal == -1) return null; HollowTypeDataAccess typeState = dataAccess.getTypeDataAccess(typeName, ordinal); if(typeState == null) return null; if(typeState instanceof HollowObjectTypeDataAccess) { return new HollowEffigy(this, (HollowObjectTypeDataAccess) typeState, ordinal); } else if(typeState instanceof HollowCollectionTypeDataAccess) { return new HollowEffigy(this, (HollowCollectionTypeDataAccess) typeState, ordinal); } else if(typeState instanceof HollowMapTypeDataAccess){ return new HollowEffigy(this, (HollowMapTypeDataAccess) typeState, ordinal); } throw new IllegalArgumentException("I don't know how to effigize a " + typeState.getClass()); }
public Api( HollowDataAccess dataAccess, Set<String> cachedTypes, Map<String, HollowFactory<?>> factoryOverrides, Api previousCycleAPI) { super(dataAccess); this.stringTypeDataAccess = (HollowObjectTypeDataAccess) dataAccess.getTypeDataAccess("String"); this.stringDelegate = new HollowObjectGenericDelegate(stringTypeDataAccess); this.fieldOfStringRenamedTypeDataAccess = (HollowObjectTypeDataAccess) dataAccess.getTypeDataAccess( "FieldOfStringRenamed"); this.fieldOfStringRenamedDelegate = new HollowObjectGenericDelegate(fieldOfStringRenamedTypeDataAccess); }
public List<Object> extractValues(HollowDataAccess dataAccess, HollowDiffNodeIdentifier fieldIdentifier, int ordinal) { IntList ordinalList = new IntList(1); ordinalList.add(ordinal); return traverse(dataAccess.getTypeDataAccess(getType(fieldIdentifier)), ordinalList, fieldIdentifier, 0); }
@Override public Collection<HBoolean> getAllHBoolean() { return new AllHollowRecordCollection<HBoolean>(getDataAccess().getTypeDataAccess("Boolean").getTypeState()) { @Override protected HBoolean getForOrdinal(int ordinal) { return getHBoolean(ordinal); } }; } @Override
@Override public Collection<HDouble> getAllHDouble() { return new AllHollowRecordCollection<HDouble>(getDataAccess().getTypeDataAccess("Double").getTypeState()) { @Override protected HDouble getForOrdinal(int ordinal) { return getHDouble(ordinal); } }; } @Override
@Override public Collection<HInteger> getAllHInteger() { return new AllHollowRecordCollection<HInteger>(getDataAccess().getTypeDataAccess("Integer").getTypeState()) { @Override protected HInteger getForOrdinal(int ordinal) { return getHInteger(ordinal); } }; } @Override
private void assertRecord(HollowDataAccess dataAccess, int ordinal, int... expectedElements) { HollowListTypeDataAccess typeDataAccess = (HollowListTypeDataAccess)dataAccess.getTypeDataAccess("TestList"); for(int i=0;i<expectedElements.length;i++) { Assert.assertEquals(expectedElements[i], typeDataAccess.getElementOrdinal(ordinal, i)); } }
@Override public Collection<HFloat> getAllHFloat() { return new AllHollowRecordCollection<HFloat>(getDataAccess().getTypeDataAccess("Float").getTypeState()) { @Override protected HFloat getForOrdinal(int ordinal) { return getHFloat(ordinal); } }; } @Override
@Override public Collection<HLong> getAllHLong() { return new AllHollowRecordCollection<HLong>(getDataAccess().getTypeDataAccess("Long").getTypeState()) { @Override protected HLong getForOrdinal(int ordinal) { return getHLong(ordinal); } }; } @Override
@Override public Collection<HString> getAllHString() { return new AllHollowRecordCollection<HString>(getDataAccess().getTypeDataAccess("String").getTypeState()) { @Override protected HString getForOrdinal(int ordinal) { return getHString(ordinal); } }; } @Override
public HistoricalPrimaryKeyMatcher(HollowDataAccess dataAccess, PrimaryKey primaryKey) { this.fieldPathIndexes = new int[primaryKey.numFields()][]; this.fieldTypes = new FieldType[primaryKey.numFields()]; for(int i=0;i<primaryKey.numFields();i++) { fieldPathIndexes[i] = primaryKey.getFieldPathIndex(dataAccess, i); fieldTypes[i] = primaryKey.getFieldType(dataAccess, i); } this.keyTypeAccess = (HollowObjectTypeDataAccess) dataAccess.getTypeDataAccess(primaryKey.getType()); }
private int fieldHashCode(HollowEffigy element, int[] fieldPath) { HollowObjectTypeDataAccess dataAccess = (HollowObjectTypeDataAccess) element.getDataAccess(); HollowObjectSchema schema = dataAccess.getSchema(); int ordinal = element.getOrdinal(); for (int i = 0; i < fieldPath.length - 1; i++) { int fieldPosition = fieldPath[i]; ordinal = dataAccess.readOrdinal(ordinal, fieldPosition); dataAccess = (HollowObjectTypeDataAccess) dataAccess.getDataAccess().getTypeDataAccess(schema.getReferencedType(fieldPosition)); schema = dataAccess.getSchema(); } int fieldHash = HollowReadFieldUtils.fieldHashCode(dataAccess, ordinal, fieldPath[fieldPath.length-1]); return HashCodes.hashInt(fieldHash); }
private void assertRecord(HollowDataAccess dataAccess, int ordinal, int... expectedElements) { HollowSetTypeDataAccess typeDataAccess = (HollowSetTypeDataAccess)dataAccess.getTypeDataAccess("TestSet"); test: for(int expected : expectedElements) { HollowOrdinalIterator iter = typeDataAccess.potentialMatchOrdinalIterator(ordinal, expected); int actual = iter.next(); while(actual != HollowOrdinalIterator.NO_MORE_ORDINALS) { if(actual == expected) continue test; actual = iter.next(); } Assert.fail("Did not find expected element " + expected + " for ordinal " + ordinal); } }
private void assertRecord(HollowDataAccess dataAccess, int ordinal, int... expectedEntries) { HollowMapTypeDataAccess typeDataAccess = (HollowMapTypeDataAccess)dataAccess.getTypeDataAccess("TestMap"); test: for(int i=0;i<expectedEntries.length;i+=2) { HollowMapEntryOrdinalIterator iter = typeDataAccess.potentialMatchOrdinalIterator(ordinal, expectedEntries[i]); while(iter.next()) { if(iter.getKey() == expectedEntries[i] && iter.getValue() == expectedEntries[i+1]) continue test; } Assert.fail("Did not find expected entry (" + expectedEntries[i] + "," + expectedEntries[i+1] + ") for ordinal " + ordinal); } }
@Test public void testClientAPIHoldsLongLivedReferences() throws IOException { client.triggerRefreshTo(1); HollowAPI api = client.getAPI(); HollowObjectTypeDataAccess dataAccess = (HollowObjectTypeDataAccess) api.getDataAccess().getTypeDataAccess("TestObject"); client.triggerRefreshTo(2); client.triggerRefreshTo(3); client.triggerRefreshTo(4); Assert.assertEquals(1, dataAccess.readInt(1, 0)); Assert.assertEquals("one", dataAccess.readString(1, 1)); Assert.assertEquals(3, dataAccess.readInt(3, 0)); Assert.assertEquals("three", dataAccess.readString(3, 1)); }