public GenericHollowMap(HollowMapTypeDataAccess dataAccess, int ordinal) { this(new HollowMapLookupDelegate<HollowRecord, HollowRecord>(dataAccess), ordinal); }
@Override public boolean containsKey(HollowMap<K, V> map, int ordinal, Object key) { HollowMapEntryOrdinalIterator iter; if(getSchema().getHashKey() != null) { iter = dataAccess.ordinalIterator(ordinal); } else { int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(key); iter = dataAccess.potentialMatchOrdinalIterator(ordinal, hashCode); } while(iter.next()) { if(map.equalsKey(iter.getKey(), key)) return true; } return false; }
@Override public boolean containsValue(HollowMap<K, V> map, int ordinal, Object value) { HollowMapEntryOrdinalIterator iter = iterator(ordinal); while(iter.next()) { if(map.equalsValue(iter.getValue(), value)) return true; } return false; }
@Override public V get(HollowMap<K, V> map, int ordinal, Object key) { HollowMapEntryOrdinalIterator iter; if(getSchema().getHashKey() != null) { iter = dataAccess.ordinalIterator(ordinal); } else { int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(key); iter = dataAccess.potentialMatchOrdinalIterator(ordinal, hashCode); } while(iter.next()) { if(map.equalsKey(iter.getKey(), key)) return map.instantiateValue(iter.getValue()); } return null; }
public static HollowRecord instantiate(HollowDataAccess dataAccess, String typeName, int ordinal) { HollowTypeDataAccess typeState = dataAccess.getTypeDataAccess(typeName, ordinal); if(typeState != null) { if(typeState instanceof HollowObjectTypeDataAccess) return new GenericHollowObject(new HollowObjectGenericDelegate((HollowObjectTypeDataAccess)typeState), ordinal); if(typeState instanceof HollowListTypeDataAccess) return new GenericHollowList(new HollowListLookupDelegate<HollowRecord>((HollowListTypeDataAccess)typeState), ordinal); if(typeState instanceof HollowSetTypeDataAccess) return new GenericHollowSet(new HollowSetLookupDelegate<HollowRecord>((HollowSetTypeDataAccess)typeState), ordinal); if(typeState instanceof HollowMapTypeDataAccess) return new GenericHollowMap(new HollowMapLookupDelegate<HollowRecord, HollowRecord>((HollowMapTypeDataAccess)typeState), ordinal); } else { HollowSchema schema = dataAccess.getMissingDataHandler().handleSchema(typeName); if(schema instanceof HollowObjectSchema) return new GenericHollowObject(new HollowObjectGenericDelegate(new HollowObjectMissingDataAccess(dataAccess, typeName)), ordinal); if(schema instanceof HollowListSchema) return new GenericHollowList(new HollowListLookupDelegate<HollowRecord>(new HollowListMissingDataAccess(dataAccess, typeName)), ordinal); if(schema instanceof HollowSetSchema) return new GenericHollowSet(new HollowSetLookupDelegate<HollowRecord>(new HollowSetMissingDataAccess(dataAccess, typeName)), ordinal); if(schema instanceof HollowMapSchema) return new GenericHollowMap(new HollowMapLookupDelegate<HollowRecord, HollowRecord>(new HollowMapMissingDataAccess(dataAccess, typeName)), ordinal); } throw new UnsupportedOperationException("I don't know how to instantiate a generic object given a " + typeState.getClass().getSimpleName()); }