private void updateCacheInvalidationEntries(SchemaVersionInfo schemaVersionInfo) { // need to support this as SchemaIdVersion supports multiple ways to construct for backward compatible APIs // this would have been simple without that. SchemaVersionKey schemaVersionKey = new SchemaVersionKey(schemaVersionInfo.getName(), schemaVersionInfo.getVersion()); SchemaIdVersion key1 = new SchemaIdVersion(schemaVersionInfo.getId()); idWithNameVersion.putIfAbsent(key1, schemaVersionKey); Long schemaMetadataId = schemaVersionInfo.getSchemaMetadataId(); // schemaMetadataId can be null from earlier registry instances. if (schemaMetadataId != null) { SchemaIdVersion key2 = new SchemaIdVersion(schemaMetadataId, schemaVersionInfo.getVersion()); nameVersionWithIds.putIfAbsent(schemaVersionKey, Lists.newArrayList(key1, key2)); idWithNameVersion.putIfAbsent(key2, schemaVersionKey); } else { nameVersionWithIds.putIfAbsent(schemaVersionKey, Collections.singletonList(key1)); } }
private void updateCacheInvalidationEntries(SchemaVersionInfo schemaVersionInfo) { // need to support this as SchemaIdVersion supports multiple ways to construct for backward compatible APIs // this would have been simple without that. SchemaVersionKey schemaVersionKey = new SchemaVersionKey(schemaVersionInfo.getName(), schemaVersionInfo.getVersion()); SchemaIdVersion key1 = new SchemaIdVersion(schemaVersionInfo.getId()); idWithNameVersion.putIfAbsent(key1, schemaVersionKey); Long schemaMetadataId = schemaVersionInfo.getSchemaMetadataId(); // schemaMetadataId can be null from earlier registry instances. if (schemaMetadataId != null) { SchemaIdVersion key2 = new SchemaIdVersion(schemaMetadataId, schemaVersionInfo.getVersion()); nameVersionWithIds.putIfAbsent(schemaVersionKey, Lists.newArrayList(key1, key2)); idWithNameVersion.putIfAbsent(key2, schemaVersionKey); } else { nameVersionWithIds.putIfAbsent(schemaVersionKey, Collections.singletonList(key1)); } }
private Set<SchemaIdVersion> transformToSchemaIdVersions(Collection<SchemaVersionInfo> versionInfos) { return versionInfos.stream().map(versionInfo -> new SchemaIdVersion(versionInfo.getSchemaMetadataId(), versionInfo.getVersion(), versionInfo.getId())) .collect(Collectors.toSet()); }