dimas-b commented on code in PR #1838: URL: https://github.com/apache/polaris/pull/1838#discussion_r2140628324
########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java: ########## @@ -459,29 +461,37 @@ public <T> Page<T> listEntities( entityType.getCode(), "realm_id", realmId); + Map<String, Object> whereGreater = Map.of(); // Limit can't be pushed down, due to client side filtering // absence of transaction. + String orderByColumnName = null; + if (pageToken.paginationRequested()) { + orderByColumnName = ModelEntity.ID_COLUMN; + if (pageToken.hasDataReference()) { + long boundary = entityIdBoundary(pageToken); + whereGreater = Map.of(ModelEntity.ID_COLUMN, boundary); + } + } + try { PreparedQuery query = QueryGenerator.generateSelectQuery( - ModelEntity.ALL_COLUMNS, ModelEntity.TABLE_NAME, params); - List<PolarisBaseEntity> results = new ArrayList<>(); + ModelEntity.ALL_COLUMNS, + ModelEntity.TABLE_NAME, + whereEquals, + whereGreater, + orderByColumnName); + AtomicReference<Page<T>> results = new AtomicReference<>(); datasourceOperations.executeSelectOverStream( query, new ModelEntity(), stream -> { var data = stream.filter(entityFilter); - if (pageToken instanceof HasPageSize hasPageSize) { - data = data.limit(hasPageSize.getPageSize()); - } - data.forEach(results::add); + results.set( + Page.mapped(pageToken, data, transformer, EntityIdPaging::encodedDataReference)); Review Comment: The filter (line 490) is implicitly part of the page construction login by being a stage in the `data` stream. The use of `PageToken.pageSize()` inside `Page.mapped()` is merely a convenience / guardrail to avoid assuming that the stream is limited to the exact page size. ########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java: ########## @@ -459,29 +461,37 @@ public <T> Page<T> listEntities( entityType.getCode(), "realm_id", realmId); + Map<String, Object> whereGreater = Map.of(); // Limit can't be pushed down, due to client side filtering // absence of transaction. + String orderByColumnName = null; + if (pageToken.paginationRequested()) { + orderByColumnName = ModelEntity.ID_COLUMN; + if (pageToken.hasDataReference()) { + long boundary = entityIdBoundary(pageToken); + whereGreater = Map.of(ModelEntity.ID_COLUMN, boundary); + } + } + try { PreparedQuery query = QueryGenerator.generateSelectQuery( - ModelEntity.ALL_COLUMNS, ModelEntity.TABLE_NAME, params); - List<PolarisBaseEntity> results = new ArrayList<>(); + ModelEntity.ALL_COLUMNS, + ModelEntity.TABLE_NAME, + whereEquals, + whereGreater, + orderByColumnName); + AtomicReference<Page<T>> results = new AtomicReference<>(); datasourceOperations.executeSelectOverStream( query, new ModelEntity(), stream -> { var data = stream.filter(entityFilter); - if (pageToken instanceof HasPageSize hasPageSize) { - data = data.limit(hasPageSize.getPageSize()); - } - data.forEach(results::add); + results.set( + Page.mapped(pageToken, data, transformer, EntityIdPaging::encodedDataReference)); Review Comment: The filter (line 490) is implicitly part of the page construction logic by being a stage in the `data` stream. The use of `PageToken.pageSize()` inside `Page.mapped()` is merely a convenience / guardrail to avoid assuming that the stream is limited to the exact page size. -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org