private PrimaryKey getPrimaryKey(HollowSchema schema) { if(schema.getSchemaType() == SchemaType.OBJECT) return ((HollowObjectSchema)schema).getPrimaryKey(); return null; }
@Override protected String getClassName(HollowObjectSchema schema) { return schema.getName() + "PrimaryKeyIndex"; } }
public HollowPrimaryKeyIndexGenerator(HollowDataset dataset, String packageName, String apiClassname, HollowObjectSchema schema, CodeGeneratorConfig config) { super(packageName, apiClassname, schema, dataset, config); this.pk = schema.getPrimaryKey(); isGenSimpleConstructor = true; isParameterizedConstructorPublic = false; isAutoListenToDataRefresh = false; isImplementsUniqueKeyIndex = false; }
public static HollowSchema withoutKeys(HollowSchema schema) { switch(schema.getSchemaType()) { case SET: HollowSetSchema setSchema = (HollowSetSchema)schema; if(setSchema.getHashKey() != null) setSchema = new HollowSetSchema(setSchema.getName(), setSchema.getElementType()); return setSchema; case MAP: HollowMapSchema mapSchema = (HollowMapSchema)schema; if(mapSchema.getHashKey() != null) mapSchema = new HollowMapSchema(mapSchema.getName(), mapSchema.getKeyType(), mapSchema.getValueType()); return mapSchema; default: return schema; } }
private int[] createFieldMapping(HollowObjectSchema unionSchema, HollowObjectSchema individualSchema) { int mapping[] = new int[unionSchema.numFields()]; for(int i=0;i<unionSchema.numFields();i++) { String fieldName = unionSchema.getFieldName(i); mapping[i] = individualSchema.getPosition(fieldName); } return mapping; }
private static HollowObjectSchema getStringSchema(String schemaName) { HollowObjectSchema schema = new HollowObjectSchema(schemaName, 1); schema.addField("value", FieldType.STRING); return schema; }
private boolean shouldPreserveHashPositions(HollowSchema schema) { switch(schema.getSchemaType()) { case MAP: return from.getTypesWithDefinedHashCodes().contains(((HollowMapSchema)schema).getKeyType()); case SET: return from.getTypesWithDefinedHashCodes().contains(((HollowSetSchema)schema).getElementType()); default: return false; } }
@Override public HollowSchema handleSchema(String type) { if("MissingMap".equals(type)) return new HollowMapSchema("MissingMap", "MissingObject", "MissingObject"); if("MissingObject".equals(type)) return new HollowObjectSchema("MissingObject", 0); return null; }
@Override public HollowSchema handleSchema(String type) { if("MissingList".equals(type)) return new HollowListSchema("MissingList", "MissingObject"); if("MissingObject".equals(type)) return new HollowObjectSchema("MissingObject", 0); return null; }
public FieldType getFieldType(String fieldName) { int fieldPosition = getPosition(fieldName); if(fieldPosition == -1) return null; return getFieldType(fieldPosition); }
@Override public HollowSchema handleSchema(String type) { if("MissingSet".equals(type)) return new HollowSetSchema("MissingSet", "MissingObject"); if("MissingObject".equals(type)) return new HollowObjectSchema("MissingObject", 0); return null; }
public String getReferencedType(String fieldName) { int fieldPosition = getPosition(fieldName); if(fieldPosition == -1) return null; return getReferencedType(fieldPosition); }
private boolean isDefinedHashCode(HollowSchema schema) { if(schema instanceof HollowSetSchema) return typeNamesWithDefinedHashCodes.contains(((HollowSetSchema)schema).getElementType()); if(schema instanceof HollowMapSchema) return typeNamesWithDefinedHashCodes.contains(((HollowMapSchema)schema).getKeyType()); return false; }
@Override public void writeTo(OutputStream os) throws IOException { DataOutputStream dos = new DataOutputStream(os); dos.write(SchemaType.LIST.getTypeId()); dos.writeUTF(getName()); dos.writeUTF(getElementType()); }
public HollowObjectTypeDataElements(HollowObjectSchema schema, ArraySegmentRecycler memoryRecycler) { varLengthData = new SegmentedByteArray[schema.numFields()]; bitsPerField = new int[schema.numFields()]; bitOffsetPerField = new int[schema.numFields()]; nullValueForField = new long[schema.numFields()]; this.schema = schema; this.memoryRecycler = memoryRecycler; }
ObjectFieldSegment( HollowObjectSchema enclosingSchema, String name, String typeName, int index) { super(enclosingSchema, name, typeName); this.index = index; this.type = enclosingSchema.getFieldType(index); }
/** * Warning: Not thread-safe. Should only be called within the update thread. */ public int bitsRequiredForField(String fieldName) { int fieldIndex = schema.getPosition(fieldName); return fieldIndex == -1 ? 0 : currentDataVolatile.bitsPerField[fieldIndex]; }
private boolean candidateIsDependentOnAnyTargetedType(String type, Set<String> targetedTypes) { for(String targetedType : targetedTypes) { if(HollowSchemaSorter.typeIsTransitivelyDependent(readEngine, type, targetedType)) return true; } return false; }
@Override protected String getClassName(HollowObjectSchema schema) { return schema.getName() + "PrimaryKeyIndex"; }