xunliu commented on code in PR #8297:
URL: https://github.com/apache/gravitino/pull/8297#discussion_r2313890037
##########
core/src/main/java/org/apache/gravitino/cache/CaffeineEntityCache.java:
##########
@@ -335,16 +355,125 @@ private <KEY, VALUE> Caffeine<KEY, VALUE>
newBaseBuilder(Config cacheConfig) {
*
* @param identifier The identifier of the entity to invalidate
*/
- private boolean invalidateEntities(NameIdentifier identifier) {
+ private boolean invalidateEntitiesOld(NameIdentifier identifier) {
List<EntityCacheKey> entityKeysToRemove =
Lists.newArrayList(cacheIndex.getValuesForKeysStartingWith(identifier.toString()));
+ Map<EntityCacheRelationKey, List<Entity>> relationEnitiesMap =
+ cacheData.getAllPresent(entityKeysToRemove);
+
+ // first invalidate this entity
+ EntityCacheKey currentKey =
cacheIndex.getValueForExactKey(identifier.toString());
+ if (currentKey != null) {
+ // already removed
+ cacheData.invalidate(currentKey);
+ cacheIndex.remove(currentKey.toString());
+ }
+
+ // Remove child entities
+ relationEnitiesMap.forEach(
+ (key, entities) -> {
+ if (key.relationType() == null) {
+ // If the relation type is null, it means it's a single entity, we
can skip it.
+ return;
+ }
+ entities.forEach(
+ entity -> {
+ NameIdentifier child = ((HasIdentifier)
entity).nameIdentifier();
+ if (!child.equals(identifier)) {
+ invalidateEntitiesOld(child);
Review Comment:
Removed this test function.
##########
core/src/main/java/org/apache/gravitino/cache/CaffeineEntityCache.java:
##########
@@ -335,16 +355,125 @@ private <KEY, VALUE> Caffeine<KEY, VALUE>
newBaseBuilder(Config cacheConfig) {
*
* @param identifier The identifier of the entity to invalidate
*/
- private boolean invalidateEntities(NameIdentifier identifier) {
+ private boolean invalidateEntitiesOld(NameIdentifier identifier) {
List<EntityCacheKey> entityKeysToRemove =
Lists.newArrayList(cacheIndex.getValuesForKeysStartingWith(identifier.toString()));
+ Map<EntityCacheRelationKey, List<Entity>> relationEnitiesMap =
+ cacheData.getAllPresent(entityKeysToRemove);
+
+ // first invalidate this entity
+ EntityCacheKey currentKey =
cacheIndex.getValueForExactKey(identifier.toString());
+ if (currentKey != null) {
+ // already removed
+ cacheData.invalidate(currentKey);
+ cacheIndex.remove(currentKey.toString());
+ }
+
+ // Remove child entities
+ relationEnitiesMap.forEach(
+ (key, entities) -> {
+ if (key.relationType() == null) {
+ // If the relation type is null, it means it's a single entity, we
can skip it.
+ return;
+ }
+ entities.forEach(
+ entity -> {
+ NameIdentifier child = ((HasIdentifier)
entity).nameIdentifier();
+ if (!child.equals(identifier)) {
+ invalidateEntitiesOld(child);
+ }
+ });
+ });
Review Comment:
Removed this test function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]