private boolean rowIsExactMatch(HollowDiffViewRow row) { EffigyFieldPair fieldPair = row.getFieldPair(); if(fieldPair.getFrom() == null || fieldPair.getTo() == null || fieldPair.isLeafNode()) return false; HollowEffigy fromEffigy = (HollowEffigy)fieldPair.getFrom().getValue(); HollowEffigy toEffigy = (HollowEffigy)fieldPair.getTo().getValue(); if(fromEffigy == null || toEffigy == null) return false; return exactRecordMatcher.isExactMatch(fromEffigy.getDataAccess(), fromEffigy.getOrdinal(), toEffigy.getDataAccess(), toEffigy.getOrdinal()); }
public static List<EffigyFieldPair> pair(HollowEffigy from, HollowEffigy to, Map<String, PrimaryKey> matchHints) { if(from == null || to == null) return new HollowEffigyNullPartnerPairer(from, to).pair(); if(from.getDataAccess() == null) return new HollowEffigyObjectPairer(from, to).pair(); HollowSchema schema = from.getDataAccess().getSchema(); switch(schema.getSchemaType()) { case OBJECT: return new HollowEffigyObjectPairer(from, to).pair(); case MAP: String keyType = ((HollowMapSchema)schema).getKeyType(); return new HollowEffigyMapPairer(from, to, matchHints.get(keyType)).pair(); case LIST: case SET: String elementType = ((HollowCollectionSchema)schema).getElementType(); return new HollowEffigyCollectionPairer(from, to, matchHints.get(elementType)).pair(); } throw new IllegalArgumentException("I don't know how to pair fields for type " + schema.getName() + "(" + schema.getSchemaType() + ")"); } }
toFieldPathIndexes[i] = matchHint.getFieldPathIndex(to.getDataAccess().getDataAccess(), i); fromFieldPathIndexes[i] = matchHint.getFieldPathIndex(from.getDataAccess().getDataAccess(), i);
private int fieldHashCode(HollowEffigy element, int[] fieldPath) { HollowObjectTypeDataAccess dataAccess = (HollowObjectTypeDataAccess) element.getDataAccess(); HollowObjectSchema schema = dataAccess.getSchema(); int ordinal = element.getOrdinal(); for (int i = 0; i < fieldPath.length - 1; i++) { int fieldPosition = fieldPath[i]; ordinal = dataAccess.readOrdinal(ordinal, fieldPosition); dataAccess = (HollowObjectTypeDataAccess) dataAccess.getDataAccess().getTypeDataAccess(schema.getReferencedType(fieldPosition)); schema = dataAccess.getSchema(); } int fieldHash = HollowReadFieldUtils.fieldHashCode(dataAccess, ordinal, fieldPath[fieldPath.length-1]); return HashCodes.hashInt(fieldHash); }
private boolean fieldsAreEqual(HollowEffigy fromElement, HollowEffigy toElement, int[] fromFieldPath, int[] toFieldPath) { HollowObjectTypeDataAccess fromDataAccess = (HollowObjectTypeDataAccess) fromElement.getDataAccess(); int fromOrdinal = fromElement.getOrdinal(); HollowObjectTypeDataAccess toDataAccess = (HollowObjectTypeDataAccess) toElement.getDataAccess(); int toOrdinal = toElement.getOrdinal(); HollowObjectSchema fromSchema = fromDataAccess.getSchema(); HollowObjectSchema toSchema = toDataAccess.getSchema(); for (int i = 0; i < fromFieldPath.length - 1; i++) { int fromFieldPosition = fromFieldPath[i]; int toFieldPosition = toFieldPath[i]; fromOrdinal = fromDataAccess.readOrdinal(fromOrdinal, fromFieldPosition); toOrdinal = toDataAccess.readOrdinal(toOrdinal, toFieldPosition); fromDataAccess = (HollowObjectTypeDataAccess) fromDataAccess.getDataAccess().getTypeDataAccess(fromSchema.getReferencedType(fromFieldPosition)); toDataAccess = (HollowObjectTypeDataAccess) toDataAccess.getDataAccess().getTypeDataAccess(toSchema.getReferencedType(toFieldPosition)); fromSchema = fromDataAccess.getSchema(); toSchema = toDataAccess.getSchema(); } return HollowReadFieldUtils.fieldsAreEqual(fromDataAccess, fromOrdinal, fromFieldPath[fromFieldPath.length-1], toDataAccess, toOrdinal, toFieldPath[toFieldPath.length-1]); }