You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "clintropolis (via GitHub)" <gi...@apache.org> on 2023/03/28 02:13:24 UTC

[GitHub] [druid] clintropolis opened a new pull request, #13988: add backwards compat mode for frontCoded stringEncodingStrategy

clintropolis opened a new pull request, #13988:
URL: https://github.com/apache/druid/pull/13988

   ### Description
   Follow up to #13854, to add a backwards compatibility mode for users of Druid 25.0 to upgrade to Druid 26.0 in a manner that allows for errorless rolling upgrades and downgrades by writing out the older format version. 
   
   #### Release note
   The `frontCoded` type of `stringEncodingStrategy` on `indexSpec`, has been improved with a new segment format version which typically has faster read speeds and reduced segment size. However, this improvement is backwards incompatible with Druid 25.0, so a new `formatVersion` option has been added, which defaults to the new `1`, but can be specified as `0` to allow migration to Druid 26.0 by the way of writing out the older format until the ability to rollback to Druid 25.0 is no longer determined to be needed.
   
   <hr>
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] imply-cheddar commented on a diff in pull request #13988: add backwards compat mode for frontCoded stringEncodingStrategy

Posted by "imply-cheddar (via GitHub)" <gi...@apache.org>.
imply-cheddar commented on code in PR #13988:
URL: https://github.com/apache/druid/pull/13988#discussion_r1149972375


##########
processing/src/test/java/org/apache/druid/segment/column/StringEncodingStrategyTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.druid.segment.column;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.apache.druid.segment.data.FrontCodedIndexed;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StringEncodingStrategyTest
+{
+  private static final ObjectMapper JSON_MAPPER = new DefaultObjectMapper();
+
+
+  @Test
+  public void testUtf8Serde() throws JsonProcessingException
+  {
+    StringEncodingStrategy utf8 = new StringEncodingStrategy.Utf8();
+    String there = JSON_MAPPER.writeValueAsString(utf8);
+    StringEncodingStrategy andBackAgain = JSON_MAPPER.readValue(there, StringEncodingStrategy.class);
+    Assert.assertEquals(utf8, andBackAgain);
+  }
+
+  @Test
+  public void testFrontCodedDefaultSerde() throws JsonProcessingException
+  {
+    StringEncodingStrategy frontCoded = new StringEncodingStrategy.FrontCoded(null, null);
+    String there = JSON_MAPPER.writeValueAsString(frontCoded);
+    StringEncodingStrategy andBackAgain = JSON_MAPPER.readValue(there, StringEncodingStrategy.class);
+    Assert.assertEquals(frontCoded, andBackAgain);
+  }

Review Comment:
   How about validate that this does a v1 and add some comments that help indicate that when/if that test breaks, it means default behavior changed and we need to think through the deployment model.
   
   Also, then add a test that explicitly does v1 as well?



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on a diff in pull request #13988: add backwards compat mode for frontCoded stringEncodingStrategy

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on code in PR #13988:
URL: https://github.com/apache/druid/pull/13988#discussion_r1149980320


##########
processing/src/test/java/org/apache/druid/segment/column/StringEncodingStrategyTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.druid.segment.column;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.apache.druid.segment.data.FrontCodedIndexed;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StringEncodingStrategyTest
+{
+  private static final ObjectMapper JSON_MAPPER = new DefaultObjectMapper();
+
+
+  @Test
+  public void testUtf8Serde() throws JsonProcessingException
+  {
+    StringEncodingStrategy utf8 = new StringEncodingStrategy.Utf8();
+    String there = JSON_MAPPER.writeValueAsString(utf8);
+    StringEncodingStrategy andBackAgain = JSON_MAPPER.readValue(there, StringEncodingStrategy.class);
+    Assert.assertEquals(utf8, andBackAgain);
+  }
+
+  @Test
+  public void testFrontCodedDefaultSerde() throws JsonProcessingException
+  {
+    StringEncodingStrategy frontCoded = new StringEncodingStrategy.FrontCoded(null, null);
+    String there = JSON_MAPPER.writeValueAsString(frontCoded);
+    StringEncodingStrategy andBackAgain = JSON_MAPPER.readValue(there, StringEncodingStrategy.class);
+    Assert.assertEquals(frontCoded, andBackAgain);
+  }

Review Comment:
   added `FrontCodedIndexed.DEFAULT_VERSION` (and also moved `DEFAULT_BUCKET_SIZE` here), and test for both of them as well as explicit test for v1



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis merged pull request #13988: add backwards compat mode for frontCoded stringEncodingStrategy

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis merged PR #13988:
URL: https://github.com/apache/druid/pull/13988


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org