public void setNumShards(int numShards) { if(this.numShards == -1) { this.numShards = numShards; } else if(this.numShards != numShards) { throw new IllegalStateException("The number of shards for type " + schema.getName() + " is already fixed to " + this.numShards + ". Cannot reset to " + numShards + "."); } }
private boolean schemaExists(String schemaName, Collection<HollowSchema> allSchemas) { for(HollowSchema schema : allSchemas) { if(schema.getName().equals(schemaName)) return true; } return false; }
public static String delegateLookupClassname(HollowSchema schema) { if(schema instanceof HollowObjectSchema) return delegateLookupImplName(schema.getName()); if(schema instanceof HollowListSchema) return HollowListLookupDelegate.class.getSimpleName(); if(schema instanceof HollowSetSchema) return HollowSetLookupDelegate.class.getSimpleName(); if(schema instanceof HollowMapSchema) return HollowMapLookupDelegate.class.getSimpleName(); throw new UnsupportedOperationException("What kind of schema is a " + schema.getClass().getSimpleName() + "?"); }
public HollowFactoryJavaGenerator(String packageName, HollowSchema schema, HollowDataset dataset, CodeGeneratorConfig config) { super(packageName, SUB_PACKAGE_NAME, dataset, config); this.objectClassName = hollowImplClassname(schema.getName()); this.className = hollowFactoryClassname(schema.getName()); this.schema = schema; }
public static String delegateInterfaceName(HollowSchema schema) { if(schema instanceof HollowObjectSchema) return delegateInterfaceName(schema.getName()); if(schema instanceof HollowListSchema) return HollowListDelegate.class.getSimpleName(); if(schema instanceof HollowSetSchema) return HollowSetDelegate.class.getSimpleName(); if(schema instanceof HollowMapSchema) return HollowMapDelegate.class.getSimpleName(); throw new UnsupportedOperationException("What kind of schema is a " + schema.getClass().getSimpleName() + "?"); }
public static String delegateCachedClassname(HollowSchema schema) { if(schema instanceof HollowObjectSchema) return delegateCachedImplName(schema.getName()); if(schema instanceof HollowListSchema) return HollowListCachedDelegate.class.getSimpleName(); if(schema instanceof HollowSetSchema) return HollowSetCachedDelegate.class.getSimpleName(); if(schema instanceof HollowMapSchema) return HollowMapCachedDelegate.class.getSimpleName(); throw new UnsupportedOperationException("What kind of schema is a " + schema.getClass().getSimpleName() + "?"); }
@Override public boolean shouldCopy(HollowTypeReadState typeState, int ordinal) { BitSet typeIncludedOrdinals = includedOrdinals.get(typeState.getSchema().getName()); if(typeIncludedOrdinals == null) return false; return typeIncludedOrdinals.get(ordinal); }
public HollowCollectionsGenerator(String packageName, String apiClassname, HollowSchema schema, HollowDataset dataset, CodeGeneratorConfig config) { super(packageName, SUB_PACKAGE_NAME, dataset, config); this.apiClassname = apiClassname; this.className = hollowImplClassname(schema.getName()); } }
@Override public boolean shouldCopy(HollowTypeReadState typeState, int ordinal) { BitSet typeExcludedOrdinals = excludedOrdinals.get(typeState.getSchema().getName()); if(typeExcludedOrdinals == null) return true; return !typeExcludedOrdinals.get(ordinal); }
public HollowTypeAPIGenerator(String stateEngineClassname, String packageName, HollowSchema schema, HollowDataset dataset, CodeGeneratorConfig config) { super(packageName, SUB_PACKAGE_NAME, dataset, config); this.apiClassname = stateEngineClassname; this.className = typeAPIClassname(schema.getName()); } }
private Map<String, BitSet> discoverChangedOrdinalsBetweenStates() { SimultaneousExecutor executor = new SimultaneousExecutor(); Map<String, BitSet> excludeOrdinalsFromCopy = new HashMap<String, BitSet>(); for(HollowSchema schema : schemas) { BitSet recordsToExclude = findOrdinalsPopulatedWithDifferentRecords(schema.getName(), executor); excludeOrdinalsFromCopy.put(schema.getName(), recordsToExclude); } TransitiveSetTraverser.addReferencingOutsideClosure(from, excludeOrdinalsFromCopy); return excludeOrdinalsFromCopy; }
@Override public int getShard(HollowTypeReadState topLevelType, int ordinal) { HollowPrimaryKeyValueDeriver deriver = primaryKeyDeriverByType.get(topLevelType.getSchema().getName()); if(deriver == null) return -1; Object[] key = deriver.getRecordKey(ordinal); return hashKey(topLevelType.getSchema().getName(), key) % numShards; }
private Map<String, int[]> initializeTypeMappings(HollowReadStateEngine inputStateEngine) { Map<String, int[]> typeMappings = new HashMap<String, int[]>(); for(HollowTypeReadState typeState : inputStateEngine.getTypeStates()) { int mapping[] = new int[typeState.maxOrdinal() + 1]; Arrays.fill(mapping, -1); typeMappings.put(typeState.getSchema().getName(), mapping); } return typeMappings; } }
protected void addTypeState(HollowTypeReadState typeState) { typeStates.put(typeState.getSchema().getName(), typeState); if(listenToAllPopulatedOrdinals) { typeState.addListener(new PopulatedOrdinalListener()); } List<HollowTypeStateListener> list = listeners.get(typeState.getSchema().getName()); if(list != null) { for(HollowTypeStateListener listener : list) typeState.addListener(listener); } }
private DiffEqualOrdinalMap buildMap(HollowTypeReadState fromTypeState, HollowTypeReadState toTypeState) { String typeName = fromTypeState.getSchema().getName(); DiffEqualityTypeMapper mapper = getTypeMapper(fromTypeState, toTypeState); DiffEqualOrdinalMap equalOrdinalMap = mapper.mapEqualObjects(); if(mapper.requiresTraversalForMissingFields()) typesWhichRequireMissingFieldTraversal.add(fromTypeState.getSchema().getName()); equalOrdinalMap.buildToOrdinalIdentityMapping(); map.put(typeName, equalOrdinalMap); return equalOrdinalMap; }
public void run() { HollowChecksum cksum = typeState.getChecksum(commonSchemasWith); typeChecksums.addElement(new TypeChecksum(typeState.getSchema().getName(), cksum)); } });
private void createHashOrderIndependentOrdinalMaps() { for(HollowSchema schema : output.getSchemas()) { if(isDefinedHashCode(schema)) { hashOrderIndependentOrdinalMaps.put(schema.getName(), new ByteArrayOrdinalMap()); } } }
private boolean fieldNeedsTypeNameAnnotation(int i) { if (schema.getFieldType(i) == FieldType.REFERENCE) { HollowSchema referencedSchema = dataset.getSchema(schema.getReferencedType(i)); return !referencedSchema.getName().equals(expectedCollectionClassName(referencedSchema)); } return false; }
private HollowSchema getFilteredSchema(HollowSchema schema, HollowFilterConfig filterConfig) { if(filterConfig.doesIncludeType(schema.getName())) { if(schema.getSchemaType() == SchemaType.OBJECT) return getFilteredObjectSchema((HollowObjectSchema) schema, filterConfig); return schema; } return null; }
@Override public void stringify(Writer writer, HollowRecord record) throws IOException { stringify(writer, record.getTypeDataAccess().getDataAccess(), record.getSchema().getName(), record.getOrdinal()); }