private void validateCompatibleWithTableSchemas ( String tableName , KeySchema keySchema , EntitySchema entitySchema ) { List < ManagedSchema > entitiesForTable = new ArrayList < ManagedSchema > ( ) ; for ( Entry < String , ManagedSchema > entry : getManagedSchemaMap ( ) . entrySet ( ) ) { if ( entry . getKey ( ) . startsWith ( tableName + ":" ) ) { entitiesForTable . add ( entry . getValue ( ) ) ; } } for ( ManagedSchema managedSchema : entitiesForTable ) { if ( ! managedSchema . getName ( ) . equals ( entitySchema . getName ( ) ) ) { KeyEntitySchemaParser < ? , ? > parser = getSchemaParser ( managedSchema . getSchemaType ( ) ) ; for ( String schema : managedSchema . getEntitySchemas ( ) . values ( ) ) { EntitySchema otherEntitySchema = parser . parseEntitySchema ( schema ) ; KeySchema otherKeySchema = parser . parseKeySchema ( schema ) ; if ( ! keySchema . compatible ( otherKeySchema ) ) { String msg = "StorageKey fields of schema not compatible with other schema for the table. " + "Table: " + tableName + ". Other schema: " + otherEntitySchema . getRawSchema ( ) + " New schema: " + entitySchema . getRawSchema ( ) ; throw new IncompatibleSchemaException ( msg ) ; } if ( ! validateCompatibleWithTableColumns ( entitySchema , otherEntitySchema ) ) { String msg = "Column mappings of schema not compatible with other schema for the table. " + "Table: " + tableName + ". Other schema: " + otherEntitySchema . getRawSchema ( ) + " New schema: " + entitySchema . getRawSchema ( ) ; throw new IncompatibleSchemaException ( msg ) ; } if ( ! validateCompatibleWithTableOccVersion ( entitySchema , otherEntitySchema ) ) { String msg = "OCCVersion mapping of schema not compatible with other schema for the table. " + "Only one schema in the table can have one." + "Table: " + tableName + ". Other schema: " + otherEntitySchema . getRawSchema ( ) + " New schema: " + entitySchema . getRawSchema ( ) ; throw new IncompatibleSchemaException ( msg ) ; } } } } }
Validate that a KeySchema and EntitySchema will be compatible with the other schemas registered with a table . This includes making sure that the schema doesn t overlap with columns other schemas for the table map to and validates that the key schemas are the same .