You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "snazy (via GitHub)" <gi...@apache.org> on 2026/06/27 08:58:45 UTC
[PR] Prepare NoSQL pagination tokens for Jackson 3 [polaris]
snazy opened a new pull request, #4917:
URL: https://github.com/apache/polaris/pull/4917
This prepares `NoSqlPaginationToken` for the core pagination Jackson 3 migration in #4910.
`NoSqlPaginationToken` currently embeds `ObjRef` and `IndexKey` directly. Those types have their own Jackson serializers, so migrating `PageToken` / `Token` / `PageTokenUtil` to Jackson 3 without migrating the full NoSQL serialization stack at the same time breaks pagination-token serialization.
This change decouples that dependency by storing the native binary payloads in the token wire format as bytes.
The wire format remains intentionally short and binary-compatible with the previous representation.
This PR adds the Jackson 3 dependencies needed by `NoSqlPaginationToken` so the type can carry both Jackson 2 and Jackson 3 immutable type annotations. That is intentional preparation for the core pagination migration PR #4910, so this has to land before.
The alternative would have been to push all poplaris-core and all NoSQL changes at once in one giant PR.
Additional test coverage for wire-format compatibiltiy has been addded. These tests pin both the current behavior and the wire compatibility that the follow-up Jackson 3 pagination migration depends on.
--
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-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prepare NoSQL pagination tokens for Jackson 3 [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy merged PR #4917:
URL: https://github.com/apache/polaris/pull/4917
--
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-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prepare NoSQL pagination tokens for Jackson 3 [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #4917:
URL: https://github.com/apache/polaris/pull/4917#discussion_r3500245927
##########
persistence/nosql/persistence/metastore/src/test/java/org/apache/polaris/persistence/nosql/metastore/TestNoSqlPaginationToken.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.persistence.nosql.metastore;
+
+import static org.apache.polaris.persistence.nosql.api.index.IndexKey.key;
+import static org.apache.polaris.persistence.nosql.api.obj.ObjRef.objRef;
+import static org.junit.jupiter.params.provider.Arguments.arguments;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.List;
+import java.util.OptionalInt;
+import java.util.stream.Stream;
+import org.apache.polaris.core.persistence.pagination.Page;
+import org.apache.polaris.core.persistence.pagination.PageToken;
+import org.apache.polaris.persistence.nosql.api.index.IndexKey;
+import org.apache.polaris.persistence.nosql.api.obj.ObjRef;
+import org.assertj.core.api.SoftAssertions;
+import org.assertj.core.api.junit.jupiter.InjectSoftAssertions;
+import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+@ExtendWith(SoftAssertionsExtension.class)
+public class TestNoSqlPaginationToken {
+ private static final ObjectMapper JSON_MAPPER = JsonMapper.builder().build();
+ private static final ObjectMapper SMILE_MAPPER = SmileMapper.builder().build();
+
+ @InjectSoftAssertions SoftAssertions soft;
+
+ @ParameterizedTest
+ @MethodSource("tokens")
+ public void serializationRoundtripSmile(ObjRef containerObjRef, IndexKey indexKey)
+ throws Exception {
+ var token = NoSqlPaginationToken.paginationToken(containerObjRef, indexKey);
+ var expectedContainerObjRefBytes = containerObjRef.toBytes();
+ var expectedKeyBytes = bytes(indexKey.asByteBuffer());
+
+ var serialized = SMILE_MAPPER.writerFor(NoSqlPaginationToken.class).writeValueAsBytes(token);
+ var jsonNode = SMILE_MAPPER.readTree(serialized);
+ soft.assertThat(jsonNode.fieldNames()).toIterable().containsExactlyInAnyOrder("t", "c", "k");
+ soft.assertThat(jsonNode.path("t").asText()).isEqualTo(NoSqlPaginationToken.ID);
+ soft.assertThat(jsonNode.path("c").asText())
+ .isEqualTo(Base64.getEncoder().encodeToString(expectedContainerObjRefBytes));
+ soft.assertThat(jsonNode.path("k").asText())
+ .isEqualTo(Base64.getEncoder().encodeToString(expectedKeyBytes));
+ assertRoundTrip(
+ SMILE_MAPPER.readValue(serialized, NoSqlPaginationToken.class),
+ containerObjRef,
+ indexKey,
+ expectedContainerObjRefBytes,
+ expectedKeyBytes);
+ }
+
+ @ParameterizedTest
+ @MethodSource("tokens")
+ public void serializationRoundtripJson(ObjRef containerObjRef, IndexKey indexKey)
+ throws Exception {
+ var token = NoSqlPaginationToken.paginationToken(containerObjRef, indexKey);
+ var expectedContainerObjRefBytes = containerObjRef.toBytes();
+ var expectedKeyBytes = bytes(indexKey.asByteBuffer());
+
+ var serialized = JSON_MAPPER.writerFor(NoSqlPaginationToken.class).writeValueAsString(token);
Review Comment:
Could the mapper be a test method parameter for sharing test logic between `serializationRoundtripJson` and `serializationRoundtripSmile`?
--
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-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prepare NoSQL pagination tokens for Jackson 3 [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #4917:
URL: https://github.com/apache/polaris/pull/4917#discussion_r3500427757
##########
persistence/nosql/persistence/metastore/src/test/java/org/apache/polaris/persistence/nosql/metastore/TestNoSqlPaginationToken.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.persistence.nosql.metastore;
+
+import static org.apache.polaris.persistence.nosql.api.index.IndexKey.key;
+import static org.apache.polaris.persistence.nosql.api.obj.ObjRef.objRef;
+import static org.junit.jupiter.params.provider.Arguments.arguments;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.List;
+import java.util.OptionalInt;
+import java.util.stream.Stream;
+import org.apache.polaris.core.persistence.pagination.Page;
+import org.apache.polaris.core.persistence.pagination.PageToken;
+import org.apache.polaris.persistence.nosql.api.index.IndexKey;
+import org.apache.polaris.persistence.nosql.api.obj.ObjRef;
+import org.assertj.core.api.SoftAssertions;
+import org.assertj.core.api.junit.jupiter.InjectSoftAssertions;
+import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+@ExtendWith(SoftAssertionsExtension.class)
+public class TestNoSqlPaginationToken {
+ private static final ObjectMapper JSON_MAPPER = JsonMapper.builder().build();
+ private static final ObjectMapper SMILE_MAPPER = SmileMapper.builder().build();
+
+ @InjectSoftAssertions SoftAssertions soft;
+
+ @ParameterizedTest
+ @MethodSource("tokens")
+ public void serializationRoundtripSmile(ObjRef containerObjRef, IndexKey indexKey)
+ throws Exception {
+ var token = NoSqlPaginationToken.paginationToken(containerObjRef, indexKey);
+ var expectedContainerObjRefBytes = containerObjRef.toBytes();
+ var expectedKeyBytes = bytes(indexKey.asByteBuffer());
+
+ var serialized = SMILE_MAPPER.writerFor(NoSqlPaginationToken.class).writeValueAsBytes(token);
+ var jsonNode = SMILE_MAPPER.readTree(serialized);
+ soft.assertThat(jsonNode.fieldNames()).toIterable().containsExactlyInAnyOrder("t", "c", "k");
+ soft.assertThat(jsonNode.path("t").asText()).isEqualTo(NoSqlPaginationToken.ID);
+ soft.assertThat(jsonNode.path("c").asText())
+ .isEqualTo(Base64.getEncoder().encodeToString(expectedContainerObjRefBytes));
+ soft.assertThat(jsonNode.path("k").asText())
+ .isEqualTo(Base64.getEncoder().encodeToString(expectedKeyBytes));
+ assertRoundTrip(
+ SMILE_MAPPER.readValue(serialized, NoSqlPaginationToken.class),
+ containerObjRef,
+ indexKey,
+ expectedContainerObjRefBytes,
+ expectedKeyBytes);
+ }
+
+ @ParameterizedTest
+ @MethodSource("tokens")
+ public void serializationRoundtripJson(ObjRef containerObjRef, IndexKey indexKey)
+ throws Exception {
+ var token = NoSqlPaginationToken.paginationToken(containerObjRef, indexKey);
+ var expectedContainerObjRefBytes = containerObjRef.toBytes();
+ var expectedKeyBytes = bytes(indexKey.asByteBuffer());
+
+ var serialized = JSON_MAPPER.writerFor(NoSqlPaginationToken.class).writeValueAsString(token);
Review Comment:
Not really. At least not long term. I tried it and it looked quite awkward then.
--
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-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org