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

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

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