obelix74 commented on code in PR #3385: URL: https://github.com/apache/polaris/pull/3385#discussion_r2841969127
########## polaris-core/src/main/java/org/apache/polaris/core/persistence/metrics/MetricsSchemaBootstrap.java: ########## @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.core.persistence.metrics; + +import com.google.common.annotations.Beta; + +/** + * Service Provider Interface (SPI) for bootstrapping the metrics schema. + * + * <p>This interface enables different persistence backends (JDBC, NoSQL, custom) to implement + * metrics schema initialization in a way appropriate for their storage model. The metrics schema is + * separate from the entity schema and can be bootstrapped independently. + * + * <p>Implementations should be idempotent - calling {@link #bootstrap(String)} multiple times on + * the same realm should have no effect after the first successful call. + * + * <h3>Dependency Injection</h3> + * + * <p>This interface is designed to be injected via CDI (Contexts and Dependency Injection). The + * deployment module should provide a {@code @Produces} method that creates the appropriate + * implementation based on the configured persistence backend. + * + * <h3>Usage</h3> + * + * <p>The metrics schema can be bootstrapped: + * + * <ul> + * <li>During initial realm bootstrap with the {@code --include-metrics} flag + * <li>Independently via the {@code bootstrap-metrics} CLI command + * <li>Programmatically by injecting this interface and calling {@link #bootstrap(String)} + * </ul> + * + * <p><b>Note:</b> This SPI is currently experimental. The API may change in future releases. + * + * @see MetricsPersistence + */ +@Beta +public interface MetricsSchemaBootstrap { + + /** + * Bootstraps the metrics schema for the specified realm to the latest version. + * + * <p>This operation is idempotent - calling it multiple times on the same realm should have no + * effect after the first successful call when already at the latest version. + * + * <p>If the schema is already bootstrapped at a lower version, this will upgrade to the latest + * version. + * + * <p>Implementations should: + * + * <ul> + * <li>Create the necessary tables/collections for storing metrics data + * <li>Create any required indexes for efficient querying + * <li>Record the metrics schema version for future migrations + * </ul> + * + * @param realmId the realm identifier to bootstrap the metrics schema for + * @throws RuntimeException if the bootstrap operation fails + */ + void bootstrap(String realmId); + + /** + * Bootstraps or upgrades the metrics schema for the specified realm to the target version. + * + * <p>If the current schema version is less than the target version, this will apply all necessary + * migrations to reach the target version. + * + * @param realmId the realm identifier to bootstrap the metrics schema for + * @param targetVersion the target schema version to bootstrap/upgrade to + * @throws RuntimeException if the bootstrap operation fails + * @throws IllegalArgumentException if targetVersion is less than current version (downgrades not + * supported) + */ + void bootstrap(String realmId, int targetVersion); + + /** + * Checks if the metrics schema has been bootstrapped for the specified realm. + * + * @param realmId the realm identifier to check + * @return {@code true} if the metrics schema is already bootstrapped, {@code false} otherwise + */ + boolean isBootstrapped(String realmId); Review Comment: Removed. ########## polaris-core/src/main/java/org/apache/polaris/core/persistence/metrics/ReportIdToken.java: ########## @@ -69,56 +69,66 @@ public interface ReportIdToken extends Token { String ID = "r"; /** - * The report ID to use as the cursor. + * The report ID to use as the cursor (tie-breaker for same-timestamp entries). * - * <p>Results should start after this report ID. This is typically the {@code reportId} of the - * last item from the previous page. + * <p>Results should start after this report ID within the same timestamp. This is typically the + * {@code reportId} of the last item from the previous page. */ @JsonProperty("r") String reportId(); + /** + * The timestamp in milliseconds to use as the primary cursor. Review Comment: added javadoc reference to `System.currentTimeMillis()` for the `timestampMs` field in `ReportIdToken`. -- 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]
