public GenericHollowMap(HollowDataAccess dataAccess, String type, int ordinal) { this((HollowMapTypeDataAccess)dataAccess.getTypeDataAccess(type, ordinal), ordinal); }
@Override public HollowObjectHashCodeFinder getHashCodeFinder() { return currentDataAccess.getHashCodeFinder(); }
@Override public MissingDataHandler getMissingDataHandler() { return currentDataAccess.getMissingDataHandler(); }
private Object[] getAllValues(int ordinal, String type, int fieldIndex) { Object[] values; HollowTypeDataAccess typeDataAccess = hollowDataAccess.getTypeDataAccess(type); SchemaType schemaType = hollowDataAccess.getSchema(type).getSchemaType(); HollowSchema schema = hollowDataAccess.getSchema(type);
public void setDataAccess(HollowDataAccess currentDataAccess) { this.currentDataAccess = currentDataAccess; for(String type : currentDataAccess.getAllTypes()) { HollowTypeDataAccess typeDataAccess = currentDataAccess.getTypeDataAccess(type); HollowTypeProxyDataAccess proxyDataAccess = typeDataAccessMap.get(type); if(proxyDataAccess == null) { if(typeDataAccess instanceof HollowObjectTypeDataAccess) { proxyDataAccess = new HollowObjectProxyDataAccess(this); } else if(typeDataAccess instanceof HollowListTypeDataAccess) { proxyDataAccess = new HollowListProxyDataAccess(this); } else if(typeDataAccess instanceof HollowSetTypeDataAccess) { proxyDataAccess = new HollowSetProxyDataAccess(this); } else if(typeDataAccess instanceof HollowMapTypeDataAccess) { proxyDataAccess = new HollowMapProxyDataAccess(this); } typeDataAccessMap.put(type, proxyDataAccess); } proxyDataAccess.setCurrentDataAccess(typeDataAccess); } }
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()); }
@Test public void testAddSnapshot_data() throws Exception { long latestVersion = 1L; TestHollowConsumer consumer = new TestHollowConsumer.Builder() .withAnnouncementWatcher(new TestAnnouncementWatcher().setLatestVersion(1L)) .withBlobRetriever(new TestBlobRetriever()) .build(); consumer.addSnapshot(latestVersion, new HollowWriteStateEngineBuilder().add("foo").add(2).build()); consumer.triggerRefresh(); HollowDataAccess data = consumer.getAPI().getDataAccess(); assertEquals("Should have string and int", new HashSet<>(Arrays.asList("String", "Integer")), data.getAllTypes()); assertEquals("foo", new GenericHollowObject(data, "String", 0).getString("value")); assertEquals(2, new GenericHollowObject(data, "Integer", 0).getInt("value")); }
@Override public boolean hasSampleResults() { return currentDataAccess.hasSampleResults(); }
@Override public void resetSampling() { currentDataAccess.resetSampling(); }
@Override public List<HollowSchema> getSchemas() { return currentDataAccess.getSchemas(); }
@Override public HollowSchema getSchema(String name) { return currentDataAccess.getSchema(name); }
@Override public HollowSchema getNonNullSchema(String name) { return currentDataAccess.getNonNullSchema(name); }
private Object getValue(int ordinal, String type, int fieldIndex) { Object value = null; HollowTypeDataAccess typeDataAccess = hollowDataAccess.getTypeDataAccess(type); SchemaType schemaType = hollowDataAccess.getSchema(type).getSchemaType(); HollowSchema schema = hollowDataAccess.getSchema(type);
private boolean hasBeenUsedSinceReset() { if(sibling == null) { HollowAPI myAPI = apiHandle.get(); if(myAPI != null) return myAPI.getDataAccess().hasSampleResults(); } return false; }
private void beginUsageDetectionPeriod() { sibling = null; HollowAPI hollowAPI = apiHandle.get(); if(hollowAPI != null) { hollowAPI.getDataAccess().resetSampling(); hollowAPI.setSamplingDirector(ENABLED_SAMPLING_DIRECTOR); } }
public GenericHollowList(HollowDataAccess dataAccess, String type, int ordinal) { this((HollowListTypeDataAccess)dataAccess.getTypeDataAccess(type, ordinal), ordinal); }
MissingDataHandler missingDataHandler() { return dataAccess.getMissingDataHandler(); }
@Override public boolean contains(HollowSet<T> set, int ordinal, Object o) { if(getSchema().getHashKey() != null) { for(int i=0;i<ordinals.length;i++) { if(ordinals[i] != -1 && set.equalsElement(ordinals[i], o)) return true; } } else { int hashCode = dataAccess.getDataAccess().getHashCodeFinder().hashCode(o); int bucket = HashCodes.hashInt(hashCode) & hashMask; while(ordinals[bucket] != -1) { if(set.equalsElement(ordinals[bucket], o)) return true; bucket ++; bucket &= hashMask; } } return false; }
private boolean shouldDetach() { if(!detached && System.currentTimeMillis() > (gracePeriodBeginTimestamp + config.gracePeriodMillis() + config.usageDetectionPeriodMillis())) { if(config.forceDropData()) { return true; } else if(config.dropDataAutomatically()) { if(usageDetected) return false; HollowAPI api = apiHandle.get(); if(api != null) { HollowDataAccess dataAccess = api.getDataAccess(); if(dataAccess.hasSampleResults()) { usageDetected = true; return false; } return true; } } } return false; }
public GenericHollowObject(HollowDataAccess dataAccess, String typeName, int ordinal) { this((HollowObjectTypeDataAccess)dataAccess.getTypeDataAccess(typeName, ordinal), ordinal); }