-
Notifications
You must be signed in to change notification settings - Fork 290
Remove overloads of BasePersistence.listEntities #2262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,14 +89,14 @@ public EntityNameLookupRecord( | |
this.subTypeCode = subTypeCode; | ||
} | ||
|
||
/** Constructor to create the object with provided entity */ | ||
public EntityNameLookupRecord(PolarisBaseEntity entity) { | ||
this.catalogId = entity.getCatalogId(); | ||
this.id = entity.getId(); | ||
this.parentId = entity.getParentId(); | ||
this.typeCode = entity.getTypeCode(); | ||
this.name = entity.getName(); | ||
this.subTypeCode = entity.getSubTypeCode(); | ||
public static EntityNameLookupRecord fromEntity(PolarisBaseEntity entity) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the motivation for this change here? if no particular reason, can we keep the original constructor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine to add a new static method like this. I'd suggest to deprecate the constructor first and remove it later if we don't need it. |
||
return new EntityNameLookupRecord( | ||
entity.getCatalogId(), | ||
entity.getId(), | ||
entity.getParentId(), | ||
entity.getName(), | ||
entity.getTypeCode(), | ||
entity.getSubTypeCode()); | ||
} | ||
|
||
@Override | ||
|
@@ -119,7 +119,7 @@ public int hashCode() { | |
|
||
@Override | ||
public String toString() { | ||
return "PolarisEntitiesActiveRecord{" | ||
return "EntityNameLookupRecord{" | ||
+ "catalogId=" | ||
+ catalogId | ||
+ ", id=" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,7 +241,7 @@ default EntityNameLookupRecord lookupEntityIdAndSubTypeByName( | |
if (baseEntity == null) { | ||
return null; | ||
} | ||
return new EntityNameLookupRecord(baseEntity); | ||
return EntityNameLookupRecord.fromEntity(baseEntity); | ||
} | ||
|
||
/** | ||
|
@@ -268,45 +268,6 @@ List<PolarisBaseEntity> lookupEntities( | |
List<PolarisChangeTrackingVersions> lookupEntityVersions( | ||
@Nonnull PolarisCallContext callCtx, List<PolarisEntityId> entityIds); | ||
|
||
/** | ||
* List all entities of the specified type which are child entities of the specified parent | ||
* | ||
* @param callCtx call context | ||
* @param catalogId catalog id for that entity, NULL_ID if the entity is top-level | ||
* @param parentId id of the parent, can be the special 0 value representing the root entity | ||
* @param entityType type of entities to list | ||
* @param pageToken the token to start listing after | ||
* @return the list of entities for the specified list operation | ||
*/ | ||
@Nonnull | ||
Page<EntityNameLookupRecord> listEntities( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest a dev ML discussion or vote for interface change in this class. cc @dennishuo cc @singhpk234 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This particular type is actually not even used by any production code outside of a particular persistence implementation. If a particular implementation needs more functions, those implementations are free to keep it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you help me understand what particular concern one might have? the innermost methods that support all the parameters are still there (so not that hard to switch to if backward-compatibility is the concern) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because |
||
@Nonnull PolarisCallContext callCtx, | ||
long catalogId, | ||
long parentId, | ||
@Nonnull PolarisEntityType entityType, | ||
@Nonnull PageToken pageToken); | ||
|
||
/** | ||
* List entities where some predicate returns true | ||
* | ||
* @param callCtx call context | ||
* @param catalogId catalog id for that entity, NULL_ID if the entity is top-level | ||
* @param parentId id of the parent, can be the special 0 value representing the root entity | ||
* @param entityType type of entities to list | ||
* @param entityFilter the filter to be applied to each entity. Only entities where the predicate | ||
* returns true are returned in the list | ||
* @param pageToken the token to start listing after | ||
* @return the list of entities for which the predicate returns true | ||
*/ | ||
@Nonnull | ||
Page<EntityNameLookupRecord> listEntities( | ||
@Nonnull PolarisCallContext callCtx, | ||
long catalogId, | ||
long parentId, | ||
@Nonnull PolarisEntityType entityType, | ||
@Nonnull Predicate<PolarisBaseEntity> entityFilter, | ||
@Nonnull PageToken pageToken); | ||
|
||
/** | ||
* List entities where some predicate returns true and transform the entities with a function | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
*/ | ||
package org.apache.polaris.core.persistence.transactional; | ||
|
||
import com.google.common.base.Predicates; | ||
import jakarta.annotation.Nonnull; | ||
import jakarta.annotation.Nullable; | ||
import java.util.Comparator; | ||
|
@@ -288,15 +287,7 @@ public EntityNameLookupRecord lookupEntityActiveInCurrentTxn( | |
entityActiveKey.getName())); | ||
|
||
// return record | ||
return (entity == null) | ||
? null | ||
: new EntityNameLookupRecord( | ||
entity.getCatalogId(), | ||
entity.getId(), | ||
entity.getParentId(), | ||
entity.getName(), | ||
entity.getTypeCode(), | ||
entity.getSubTypeCode()); | ||
return (entity == null) ? null : EntityNameLookupRecord.fromEntity(entity); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
|
@@ -311,44 +302,6 @@ public List<EntityNameLookupRecord> lookupEntityActiveBatchInCurrentTxn( | |
.collect(Collectors.toList()); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public @Nonnull Page<EntityNameLookupRecord> listEntitiesInCurrentTxn( | ||
@Nonnull PolarisCallContext callCtx, | ||
long catalogId, | ||
long parentId, | ||
@Nonnull PolarisEntityType entityType, | ||
@Nonnull PageToken pageToken) { | ||
return this.listEntitiesInCurrentTxn( | ||
callCtx, catalogId, parentId, entityType, Predicates.alwaysTrue(), pageToken); | ||
} | ||
|
||
@Override | ||
public @Nonnull Page<EntityNameLookupRecord> listEntitiesInCurrentTxn( | ||
@Nonnull PolarisCallContext callCtx, | ||
long catalogId, | ||
long parentId, | ||
@Nonnull PolarisEntityType entityType, | ||
@Nonnull Predicate<PolarisBaseEntity> entityFilter, | ||
@Nonnull PageToken pageToken) { | ||
// full range scan under the parent for that type | ||
return this.listEntitiesInCurrentTxn( | ||
callCtx, | ||
catalogId, | ||
parentId, | ||
entityType, | ||
entityFilter, | ||
entity -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay so we shouldn't have been lazy with properly expressing the distinctions in the behaviors of the different methods here in In general the |
||
new EntityNameLookupRecord( | ||
entity.getCatalogId(), | ||
entity.getId(), | ||
entity.getParentId(), | ||
entity.getName(), | ||
entity.getTypeCode(), | ||
entity.getSubTypeCode()), | ||
pageToken); | ||
} | ||
|
||
@Override | ||
public @Nonnull <T> Page<T> listEntitiesInCurrentTxn( | ||
@Nonnull PolarisCallContext callCtx, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an unfortunate inefficiency that accidentally slipped through probably because the TreeMap impl gets away with it due to everything being in-memory. The "basic" version should never have delegated to the "filter" or "transformer" version, and indeed even the filter version probably shouldn't have just delegated to the "transformer" version either.
In practice, at the very least the "basic" version (5-arg version) should have had its own underlying query which only retrieved the columns used in
EntityNameLookupRecord
.It's a pretty huge inefficiency (borderline bug) right now for "pure name listing" to have to select all columns from the database only to throw away all the big columns.