this.typeCompositeIndexMap.put(type.getStorageId(), compositeIndexMap); for (SchemaCompositeIndex compositeIndex : type.getSchemaCompositeIndexes().values()) { if (compositeIndexMap.put(compositeIndex.getName(), compositeIndex) != null) throw new IllegalArgumentException("schema model is invalid");
private CompositeIndex addCompositeIndex(Schema schema, SchemaCompositeIndex schemaIndex) { // Get fields corresponding to specified storage IDs final int[] storageIds = Ints.toArray(schemaIndex.getIndexedFields()); if (storageIds.length < 2 || storageIds.length > Database.MAX_INDEXED_FIELDS) throw new IllegalArgumentException("invalid " + schemaIndex + ": can't index " + storageIds.length + " fields"); final ArrayList<SimpleField<?>> list = new ArrayList<>(storageIds.length); int count = 0; for (int storageId : storageIds) { final Field<?> field = this.fields.get(storageId); if (!(field instanceof SimpleField)) { throw new IllegalArgumentException("invalid " + schemaIndex + ": no simple field with storage ID " + storageId + " found"); } final SimpleField<?> simpleField = (SimpleField<?>)field; if (simpleField.parent != null) { throw new IllegalArgumentException("invalid " + schemaIndex + ": simple field with storage ID " + storageId + " is a sub-field of a complex field"); } list.add(simpleField); } // Create and add index final CompositeIndex index = new CompositeIndex(schemaIndex.getName(), schemaIndex.getStorageId(), schema, this, list); this.addSchemaItem(this.compositeIndexes, this.compositeIndexesByName, index); return index; } }
for (SchemaCompositeIndex index : this.schemaCompositeIndexes.values()) { index.validate(); final String indexName = index.getName(); if (compositeIndexesByName.put(indexName, index) != null) throw new InvalidSchemaException("duplicate composite index name `" + indexName + "'");