public String toString() { return Arrays.toString(path) + " (" + type.toString() + ")"; } }
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getName()); if (primaryKey != null) { builder.append(" @PrimaryKey("); if (primaryKey.numFields() > 0) { builder.append(primaryKey.getFieldPath(0)); for (int i = 1; i < primaryKey.numFields(); i++) { builder.append(", ").append(primaryKey.getFieldPath(i)); } } builder.append(")"); } builder.append(" {\n"); for(int i=0;i<numFields();i++) { builder.append("\t"); if(getFieldType(i) == FieldType.REFERENCE) { builder.append(getReferencedType(i)); } else { builder.append(getFieldType(i).toString().toLowerCase()); } builder.append(" ").append(getFieldName(i)).append(";\n"); } builder.append("}"); return builder.toString(); }
public static String getJavaBoxedType(FieldType fieldType) { switch(fieldType) { case BOOLEAN: return "Boolean"; case BYTES: return "byte[]"; case DOUBLE: return "Double"; case FLOAT: return "Float"; case LONG: return "Long"; case INT: case REFERENCE: return "Integer"; case STRING: return "String"; } throw new IllegalArgumentException("Java boxed type is not known for FieldType." + fieldType.toString()); }
for(int i=0;i<schema.numFields();i++) { String fieldName = schema.getFieldName(i); String fieldType = schema.getFieldType(i) == FieldType.REFERENCE ? schema.getReferencedType(i) : schema.getFieldType(i).toString(); Object fieldValue = null;
public HollowDiffObjectCountingNode(HollowDiff diff, HollowTypeDiff topLevelTypeDiff, HollowDiffNodeIdentifier nodeId, HollowObjectTypeReadState fromState, HollowObjectTypeReadState toState) { super(diff, topLevelTypeDiff, nodeId); this.fromState = fromState; this.toState = toState; this.fromSchema = fromState == null ? emptySchema(toState.getSchema()) : fromState.getSchema(); this.toSchema = toState == null ? emptySchema(fromState.getSchema()) : toState.getSchema(); if(!fromSchema.getName().equals(toSchema.getName())) throw new IllegalArgumentException("Cannot diff between two schemas with different names: from '" + fromSchema.getName() + "' to '" + toSchema.getName() + "'"); this.unionSchema = fromSchema.findUnionSchema(toSchema); this.fieldNodes = new HollowDiffCountingNode[unionSchema.numFields()]; this.fromFieldMapping = createFieldMapping(unionSchema, fromSchema); this.toFieldMapping = createFieldMapping(unionSchema, toSchema); this.fieldRequiresMissingFieldTraversal = new boolean[unionSchema.numFields()]; this.fieldEqualOrdinalFilters = new DiffEqualOrdinalFilter[unionSchema.numFields()]; for(int i=0;i<unionSchema.numFields();i++) { int fromFieldIndex = fromSchema.getPosition(unionSchema.getFieldName(i)); int toFieldIndex = toSchema.getPosition(unionSchema.getFieldName(i)); if(unionSchema.getFieldType(i) == FieldType.REFERENCE) { HollowTypeReadState refFromState = fromFieldIndex == -1 ? null : fromSchema.getReferencedTypeState(fromFieldIndex); HollowTypeReadState refToState = toFieldIndex == -1 ? null : toSchema.getReferencedTypeState(toFieldIndex); fieldNodes[i] = getHollowDiffCountingNode(refFromState, refToState, unionSchema.getFieldName(i)); fieldEqualOrdinalFilters[i] = new DiffEqualOrdinalFilter(equalityMapping.getEqualOrdinalMap(unionSchema.getReferencedType(i))); if(refFromState == null || refToState == null || equalityMapping.requiresMissingFieldTraversal(unionSchema.getReferencedType(i))) fieldRequiresMissingFieldTraversal[i] = true; } else { HollowDiffNodeIdentifier childNodeId = new HollowDiffNodeIdentifier(nodeId, unionSchema.getFieldName(i), unionSchema.getFieldType(i).toString()); fieldNodes[i] = new HollowDiffFieldCountingNode(diff, topLevelTypeDiff, childNodeId, fromState, toState, unionSchema, i); } } }
public HollowObjectSchema findCommonSchema(HollowObjectSchema otherSchema) { if(!getName().equals(otherSchema.getName())) { throw new IllegalArgumentException("Cannot find common schema of two schemas with different names!"); } int commonFields = 0; for (String fieldName : fieldNames) { if(otherSchema.getPosition(fieldName) != -1) { commonFields++; } } PrimaryKey primaryKey = isNullableObjectEquals(this.primaryKey, otherSchema.getPrimaryKey()) ? this.primaryKey : null; HollowObjectSchema commonSchema = new HollowObjectSchema(getName(), commonFields, primaryKey); for (int i = 0; i < fieldNames.length; i++) { int otherFieldIndex = otherSchema.getPosition(fieldNames[i]); if (otherFieldIndex != -1) { if (fieldTypes[i] != otherSchema.getFieldType(otherFieldIndex) || !referencedTypesEqual(referencedTypes[i], otherSchema.getReferencedType(otherFieldIndex))) { String fieldType = fieldTypes[i] == FieldType.REFERENCE ? referencedTypes[i] : fieldTypes[i].toString().toLowerCase(); String otherFieldType = otherSchema.getFieldType(otherFieldIndex) == FieldType.REFERENCE ? otherSchema.getReferencedType(otherFieldIndex) : otherSchema.getFieldType(otherFieldIndex).toString().toLowerCase(); throw new IncompatibleSchemaException(getName(), fieldNames[i], fieldType, otherFieldType); } commonSchema.addField(fieldNames[i], fieldTypes[i], referencedTypes[i]); } } return commonSchema; }
public static String getJavaScalarType(FieldType fieldType) { switch(fieldType) { case BOOLEAN: return "boolean"; case BYTES: return "byte[]"; case DOUBLE: return "double"; case FLOAT: return "float"; case LONG: return "long"; case INT: case REFERENCE: return "int"; case STRING: return "String"; } throw new IllegalArgumentException("Java scalar type is not known for FieldType." + fieldType.toString()); }