cxzl25 commented on code in PR #1960:
URL: https://github.com/apache/orc/pull/1960#discussion_r1685963387


##########
java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java:
##########
@@ -1562,7 +1563,11 @@ private void nextVector(DecimalColumnVector result,
           }
           setIsRepeatingIfNeeded(result, r);
         }
+        if (!preIsRepeating && result.isRepeating) {

Review Comment:
   `DoubleTreeReader` and `FloatTreeReader` also have similar behavior. If the 
entire batch size is repeated, it will set `isRepeating=true`, which is 
consistent with the behavior of ORC-1266.
   
   ---
   
   
   DoubleTreeReader
   
   
https://github.com/apache/orc/blob/5e6a4cddf8599e351338030a2ceae919308f4848/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java#L1034-L1046
   
   FloatTreeReader
   
   
https://github.com/apache/orc/blob/5e6a4cddf8599e351338030a2ceae919308f4848/java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java#L818-L830
   
   ---
   Some tests
   
   ```java
   
     @Test
     public  void testDoubleIsRepeatingFlag() throws IOException {
       Configuration conf = new Configuration();
       FileSystem fs = FileSystem.get(conf);
       Path testFilePath = new Path(workDir, "testDoubleIsRepeatingFlag.orc");
       fs.delete(testFilePath, true);
   
       Configuration doubleConf = new Configuration(conf);
       doubleConf.set(OrcConf.STRIPE_ROW_COUNT.getAttribute(), "1024");
       doubleConf.set(OrcConf.ROWS_BETWEEN_CHECKS.getAttribute(), "1");
       String typeStr = "double";
       TypeDescription schema = TypeDescription.fromString("struct<col1:" + 
typeStr + ">");
       Writer w = OrcFile.createWriter(testFilePath, 
OrcFile.writerOptions(doubleConf).setSchema(schema));
   
       VectorizedRowBatch b = schema.createRowBatch();
       DoubleColumnVector f1 = (DoubleColumnVector) b.cols[0];
       for (int i = 0; i < 1024; i++) {
         f1.vector[i] = -119.4594594595D;
       }
       b.size = 1024;
       w.addRowBatch(b);
   
       b.reset();
       for (int i = 0; i < 1024; i++) {
         f1.vector[i] = 9318.4351351351D;
       }
       b.size = 1024;
       w.addRowBatch(b);
   
       b.reset();
       for (int i = 0; i < 1024; i++) {
         f1.vector[i] = -4298.1513513514D;
       }
       b.size = 1024;
       w.addRowBatch(b);
   
       b.reset();
       w.close();
   
       Reader.Options options = new Reader.Options();
       try (Reader reader = OrcFile.createReader(testFilePath, 
OrcFile.readerOptions(conf));
            RecordReader rows = reader.rows(options)) {
         VectorizedRowBatch batch = schema.createRowBatch();
   
         rows.nextBatch(batch);
         assertEquals(1024, batch.size);
         assertTrue(batch.cols[0].isRepeating);
   
         rows.nextBatch(batch);
         assertEquals(1024, batch.size);
         assertTrue(batch.cols[0].isRepeating);
   
         rows.nextBatch(batch);
         assertEquals(1024, batch.size);
         assertTrue(batch.cols[0].isRepeating);
   
       }
     }
   
     @Test
     public  void testFloatIsRepeatingFlag() throws IOException {
       Configuration conf = new Configuration();
       FileSystem fs = FileSystem.get(conf);
       Path testFilePath = new Path(workDir, "testFloatIsRepeatingFlag.orc");
       fs.delete(testFilePath, true);
   
       Configuration floatConf = new Configuration(conf);
       floatConf.set(OrcConf.STRIPE_ROW_COUNT.getAttribute(), "1024");
       floatConf.set(OrcConf.ROWS_BETWEEN_CHECKS.getAttribute(), "1");
       String typeStr = "float";
       TypeDescription schema = TypeDescription.fromString("struct<col1:" + 
typeStr + ">");
       Writer w = OrcFile.createWriter(testFilePath, 
OrcFile.writerOptions(floatConf).setSchema(schema));
   
       VectorizedRowBatch b = schema.createRowBatch();
       DoubleColumnVector f1 = (DoubleColumnVector) b.cols[0];
       for (int i = 0; i < 1024; i++) {
         f1.vector[i] = -119.4594594595D;
       }
       b.size = 1024;
       w.addRowBatch(b);
   
       b.reset();
       for (int i = 0; i < 1024; i++) {
         f1.vector[i] = 9318.4351351351D;
       }
       b.size = 1024;
       w.addRowBatch(b);
   
       b.reset();
       for (int i = 0; i < 1024; i++) {
         f1.vector[i] = -4298.1513513514D;
       }
       b.size = 1024;
       w.addRowBatch(b);
   
       b.reset();
       w.close();
   
       Reader.Options options = new Reader.Options();
       try (Reader reader = OrcFile.createReader(testFilePath, 
OrcFile.readerOptions(conf));
            RecordReader rows = reader.rows(options)) {
         VectorizedRowBatch batch = schema.createRowBatch();
   
         rows.nextBatch(batch);
         assertEquals(1024, batch.size);
         assertTrue(batch.cols[0].isRepeating);
   
         rows.nextBatch(batch);
         assertEquals(1024, batch.size);
         assertTrue(batch.cols[0].isRepeating);
   
         rows.nextBatch(batch);
         assertEquals(1024, batch.size);
         assertTrue(batch.cols[0].isRepeating);
       }
     }
   ```



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

Reply via email to