xunliu commented on code in PR #7105:
URL: https://github.com/apache/gravitino/pull/7105#discussion_r2084693422
##########
core/src/main/java/org/apache/gravitino/cache/CaffeineMetaCache.java:
##########
@@ -269,78 +256,63 @@ public void put(Entity entity) {
}
/**
- * Synchronizes the entity to the index.
+ * Synchronizes the Metadata to the index.
*
- * @param entity The entity to synchronize
+ * @param metadata The Metadata to synchronize
*/
- private void syncMetadataToIndex(Entity entity) {
- NameIdentifier nameIdent = CacheUtils.getIdentFromEntity(entity);
- long id = CacheUtils.getIdFromEntity(entity);
+ private void syncMetadataToIndex(Entity metadata) {
+ NameIdentifier nameIdent = CacheUtils.getIdentFromMetadata(metadata);
+ long id = CacheUtils.getIdFromMetadata(metadata);
withLock(
() -> {
- if (LOG.isTraceEnabled()) {
- LOG.trace("SyncFromIdCache: putting name={} for entity id={}",
nameIdent, id);
- }
-
- cacheIndex.put(nameIdent.toString(), MetaCacheKey.of(id,
entity.type()));
+ cacheIndex.put(nameIdent.toString(), MetaCacheKey.of(id,
metadata.type()));
});
}
/**
- * Synchronizes the entity to the cache.
+ * Synchronizes the metadata to the cache.
*
- * @param entity The entity to synchronize
+ * @param metadata The metadata to synchronize
*/
- private void syncMetadataToCache(Entity entity) {
- NameIdentifier nameIdent = CacheUtils.getIdentFromEntity(entity);
- long id = CacheUtils.getIdFromEntity(entity);
+ private void syncMetadataToCache(Entity metadata) {
+ NameIdentifier nameIdent = CacheUtils.getIdentFromMetadata(metadata);
+ long id = CacheUtils.getIdFromMetadata(metadata);
withLock(
() -> {
- if (LOG.isTraceEnabled()) {
- LOG.trace("SyncFromIndexCache: putting id={} for entity name={}",
id, nameIdent);
- }
-
- cacheData.put(MetaCacheKey.of(id, entity.type()), entity);
- cacheIndex.put(nameIdent.toString(), MetaCacheKey.of(id,
entity.type()));
+ cacheData.put(MetaCacheKey.of(id, metadata.type()), metadata);
+ cacheIndex.put(nameIdent.toString(), MetaCacheKey.of(id,
metadata.type()));
});
}
/**
- * Removes the expired entity from the cache. This method is a hook method
for the Cache, when an
- * entry expires, it will call this method.
+ * Removes the expired metadata from the cache. This method is a hook method
for the Cache, when
+ * an entry expires, it will call this method.
*
- * @param entity The entity to remove,
+ * @param metadata The metadata to remove,
*/
@Override
- protected void removeExpiredMetadataFromDataCache(Entity entity) {
- NameIdentifier identifier = CacheUtils.getIdentFromEntity(entity);
+ protected void removeExpiredMetadataFromDataCache(Entity metadata) {
+ NameIdentifier identifier = CacheUtils.getIdentFromMetadata(metadata);
withLock(
() -> {
- if (LOG.isTraceEnabled()) {
- LOG.trace(
- "Expired removal [byId]: removing id={} name={}",
- CacheUtils.getIdFromEntity(entity),
- identifier);
- }
-
cacheIndex.remove(identifier.toString());
});
}
/**
- * Removes the entity from the cache. This method will remove all entries
with the same prefix.
+ * Removes the metadata from the cache. This method will also remove all
metadata with the same
+ * prefix.
*
- * @param rootEntity The root entity to remove.
+ * @param rootMetadata The root metadata to remove.
*/
- private void removeFromMetadata(Entity rootEntity) {
- NameIdentifier prefix = CacheUtils.getIdentFromEntity(rootEntity);
+ private void removeByMetadata(Entity rootMetadata) {
+ NameIdentifier prefix = CacheUtils.getIdentFromMetadata(rootMetadata);
Review Comment:
I think the name `parentIdent` better than `prefix`?
--
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]