snleee commented on a change in pull request #4737: Druid-Pinot Segment 
Converter Tool
URL: https://github.com/apache/incubator-pinot/pull/4737#discussion_r346674746
 
 

 ##########
 File path: 
contrib/pinot-druid-migration/src/test/java/org/apache/pinot/druid/data/readers/DruidSegmentRecordReaderTest.java
 ##########
 @@ -0,0 +1,180 @@
+/**
+ * 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.pinot.druid.data.readers;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.io.IOException;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.pinot.common.data.FieldSpec;
+import org.apache.pinot.common.data.Schema;
+import org.apache.pinot.core.data.GenericRow;
+import org.apache.pinot.core.data.readers.JSONRecordReader;
+import org.apache.pinot.core.data.recordtransformer.CompositeTransformer;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+
+public class DruidSegmentRecordReaderTest {
+  // test_sample_data is a Druid segment that was created from 
pinot-core/src/test/resources/data/test_sample_data.json
+  private static final File TEST_SAMPLE_DATA = new File(Preconditions
+      
.checkNotNull(DruidSegmentRecordReaderTest.class.getClassLoader().getResource("test_sample_data"))
+      .getFile());
+  private static final File TEST_SAMPLE_DATA_JSON = new File(Preconditions
+      
.checkNotNull(DruidSegmentRecordReaderTest.class.getClassLoader().getResource("test_sample_data_dumped.json"))
+      .getFile());
+  // Same schema as in RecordReaderSampleDataTest
+  private static final Schema TEST_SAMPLE_DATA_SCHEMA = new 
Schema.SchemaBuilder().addSingleValueDimension("column1", 
FieldSpec.DataType.LONG)
+        .addSingleValueDimension("column2", FieldSpec.DataType.LONG)
+        .addSingleValueDimension("column3", FieldSpec.DataType.STRING)
+        .addSingleValueDimension("column7", FieldSpec.DataType.STRING)
+        .addSingleValueDimension("unknown_dimension", 
FieldSpec.DataType.STRING)
+        .addMetric("met_impressionCount", 
FieldSpec.DataType.LONG).addMetric("unknown_metric", FieldSpec.DataType.DOUBLE)
+        .build();
+  // Test based on CSVRecordReaderTest
+  private static final File CSV_TEST = new File(Preconditions
+      
.checkNotNull(DruidSegmentRecordReaderTest.class.getClassLoader().getResource("test_druid_from_csv"))
+      .getFile());
+  private static final Schema CSV_TEST_SCHEMA = new 
Schema.SchemaBuilder().addSingleValueDimension("__time", 
FieldSpec.DataType.LONG)
+      .addMultiValueDimension("STR_MV", FieldSpec.DataType.STRING)
+      .addMetric("INT_SV", FieldSpec.DataType.LONG)
+      .build();
+  private static final File ALL_TYPES_TEST = new File(Preconditions
+      
.checkNotNull(DruidSegmentRecordReaderTest.class.getClassLoader().getResource("test_druid_all_types"))
+      .getFile());
+  private static final Schema ALL_TYPES_TEST_SCHEMA = new 
Schema.SchemaBuilder().addSingleValueDimension("__time", 
FieldSpec.DataType.LONG)
+      .addSingleValueDimension("stringval", FieldSpec.DataType.STRING)
+      .addMultiValueDimension("tags", FieldSpec.DataType.STRING)
+      .addMetric("intnum", FieldSpec.DataType.LONG)
+      .addMetric("floatnum", FieldSpec.DataType.FLOAT)
+      .build();
+
+  private void testReadRowsWithRecordList(Object[][] records, String[] 
columns, File dataFile, Schema schema)
+      throws IOException {
+    try (DruidSegmentRecordReader testReader = new 
DruidSegmentRecordReader(dataFile, schema)) {
+      CompositeTransformer defaultTransformer = 
CompositeTransformer.getDefaultTransformer(schema);
+
+      List<GenericRow> genericRows = new ArrayList<>();
+      int row = 0;
 
 Review comment:
   `rowCount`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to