paul-rogers commented on code in PR #12745:
URL: https://github.com/apache/druid/pull/12745#discussion_r916340492


##########
processing/src/test/java/org/apache/druid/frame/field/StringFieldReaderTest.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * 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.frame.field;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.datasketches.memory.WritableMemory;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.query.extraction.SubstringDimExtractionFn;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionDictionarySelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.data.IndexedInts;
+import org.apache.druid.segment.data.RangeIndexedInts;
+import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.internal.matchers.ThrowableMessageMatcher;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.mockito.quality.Strictness;
+
+import java.util.Collections;
+import java.util.List;
+
+public class StringFieldReaderTest extends InitializedNullHandlingTest
+{
+  private static final long MEMORY_POSITION = 1;
+
+  @Rule
+  public MockitoRule mockitoRule = 
MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
+
+  @Mock
+  public DimensionSelector writeSelector;
+
+  private WritableMemory memory;
+  private FieldWriter fieldWriter;
+
+  @Before
+  public void setUp()
+  {
+    memory = WritableMemory.allocate(1000);
+    fieldWriter = new StringFieldWriter(writeSelector);
+  }
+
+  @After
+  public void tearDown()
+  {
+    fieldWriter.close();
+  }
+
+  @Test
+  public void test_makeColumnValueSelector_singleString_notArray()
+  {
+    writeToMemory(Collections.singletonList("foo"));

Review Comment:
   Thanks for the unit tests! Tedious to write, but a great way to catch issues 
and document the API.
   
   Should there be tests that verify more than one value? What happens if there 
are zero values? What is the max quantity? What happens when we hit this limit? 
Or, is there no limit and we keep adding memory? Should we test at least a few 
generations of the "add memory" use case?



##########
processing/src/test/java/org/apache/druid/frame/field/StringFieldReaderTest.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * 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.frame.field;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.datasketches.memory.WritableMemory;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.query.extraction.SubstringDimExtractionFn;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionDictionarySelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.data.IndexedInts;
+import org.apache.druid.segment.data.RangeIndexedInts;
+import org.apache.druid.testing.InitializedNullHandlingTest;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.MatcherAssert;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.internal.matchers.ThrowableMessageMatcher;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.mockito.quality.Strictness;
+
+import java.util.Collections;
+import java.util.List;
+
+public class StringFieldReaderTest extends InitializedNullHandlingTest
+{
+  private static final long MEMORY_POSITION = 1;
+
+  @Rule
+  public MockitoRule mockitoRule = 
MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);
+
+  @Mock
+  public DimensionSelector writeSelector;
+
+  private WritableMemory memory;
+  private FieldWriter fieldWriter;
+
+  @Before
+  public void setUp()
+  {
+    memory = WritableMemory.allocate(1000);
+    fieldWriter = new StringFieldWriter(writeSelector);
+  }
+
+  @After
+  public void tearDown()
+  {
+    fieldWriter.close();
+  }
+
+  @Test
+  public void test_makeColumnValueSelector_singleString_notArray()
+  {
+    writeToMemory(Collections.singletonList("foo"));

Review Comment:
   Also, all the test in this area are for a single column. Do we have tests 
that show how to write a row of, say, a string, long and array? That would show 
how we coordinate the offsets, how we write the values together, and how we 
read the entire row.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to