qingzhu521 opened a new issue, #2089:
URL: https://github.com/apache/orc/issues/2089

   #include "orc/Exceptions.hh"
   #include "orc/OrcFile.hh"
   #include "orc/Type.hh"
   #include "Timezone.hh"
   
   #include <algorithm>
   #include <fstream>
   #include <iostream>
   #include <list>
   #include <memory>
   #include <getopt.h>
   #include <string>
   #include <sys/time.h>
   #include <time.h>
   using namespace  std;
   
   int main() {
       string schema = 
"struct<c0:smallint,c1:timestamp,c2:smallint,c3:double,c4:double,c5:varchar(500),date_part:varchar(20)>";
       ORC_UNIQUE_PTR<orc::Type> fileType = 
orc::Type::buildTypeFromString(schema);
   
       ORC_UNIQUE_PTR<orc::OutputStream> outStream = 
orc::writeLocalFile("test.orc");
   
       orc::WriterOptions options;
       options.setStripeSize(0);
   
       ORC_UNIQUE_PTR<orc::Writer> writer =
           orc::createWriter(*fileType, outStream.get(), options);
   
       ORC_UNIQUE_PTR<orc::ColumnVectorBatch> rowBatch = 
writer->createRowBatch(2);
   
       /*
   |   2629 | NULL |  -1984 |    38270028153.095 | -3.337680 | 
7<pw4T8Cj*_VmB4sDEFN3'O\\ilL]2m*L[Q+I6+K8.Xta!H?L!L_e-+8A7Ly#(oB.J9D8aWr?*ydB'[r3&STBt'+THNsq
   | 2024121003 |
   |  -8130 | NULL | -22563 |           5399.785 | -1.200099 | rY<IWC+cgsgMt7 
b[6('t1wPZ2t                                                                    
 | 2024121005 |
   
       */
       orc::StructVectorBatch* root = 
           static_cast<orc::StructVectorBatch*>(rowBatch.get());
       
       orc::LongVectorBatch* longBatch = 
dynamic_cast<orc::LongVectorBatch*>(root->fields[0]);
       longBatch->notNull[0] = true;
       longBatch->data[0] = 2629;
       longBatch->notNull[1] = true;
       longBatch->data[1] = -8130;
       longBatch->hasNulls = false;
       longBatch->numElements = 2;
   
       orc::TimestampVectorBatch* timestampBatch = 
dynamic_cast<orc::TimestampVectorBatch*>(root->fields[1]);
       timestampBatch->notNull[0] = false;
       timestampBatch->notNull[1] = false;
       timestampBatch->hasNulls = true;
       timestampBatch->numElements = 2;
   
       orc::LongVectorBatch* longBatch2 = 
dynamic_cast<orc::LongVectorBatch*>(root->fields[2]);
       longBatch2->notNull[0] = true;
       longBatch2->data[0] = -1984;
       longBatch2->notNull[1] = true;
       longBatch2->data[1] = -22563;
       longBatch2->hasNulls = false;
       longBatch2->numElements = 2;
       
       orc::DoubleVectorBatch* doubleBatch = 
dynamic_cast<orc::DoubleVectorBatch*>(root->fields[3]);
       doubleBatch->notNull[0] = true;
       doubleBatch->data[0] = 38270028153.095;
       doubleBatch->notNull[1] = true;
       doubleBatch->data[1] = 5399.785;
       doubleBatch->hasNulls = false;
       doubleBatch->numElements = 2;
   
       orc::DoubleVectorBatch* doubleBatch2 = 
dynamic_cast<orc::DoubleVectorBatch*>(root->fields[4]);
       doubleBatch2->notNull[0] = true;
       doubleBatch2->data[0] = -3.337680;
       doubleBatch2->notNull[1] = true;
       doubleBatch2->data[1] = -1.200099;
       doubleBatch2->hasNulls = false;
       doubleBatch2->numElements = 2;
   
       orc::StringVectorBatch* stringBatch = 
dynamic_cast<orc::StringVectorBatch*>(root->fields[5]);
       stringBatch->notNull[0] = true;
       stringBatch->length[0] = 93;
       stringBatch->data[0] = (char*) 
"<pw4T8Cj*_VmB4sDEFN3'O\\ilL]2m*L[Q+I6+K8.Xta!H?L!L_e-+8A7Ly#(oB.J9D8aWr?*ydB'[r3&STBt'+THNsq";
       stringBatch->notNull[1] = true;
       stringBatch->length[1] = 28;
       stringBatch->data[1] = (char*)"rY<IWC+cgsgMt7 b[6('t1wPZ2t";
       stringBatch->hasNulls = false;
       stringBatch->numElements = 2;
   
       orc::StringVectorBatch* stringBatch2 
=dynamic_cast<orc::StringVectorBatch*>(root->fields[6]);
       stringBatch2->notNull[0] = true;
       stringBatch2->data[0] = (char*)"2024121003";
       stringBatch2->length[0] = 10;
       stringBatch2->notNull[1] = true;
       stringBatch2->data[1] = (char*)"2024121005";
       stringBatch2->hasNulls = false;
       stringBatch2->length[1] = 10;
       stringBatch2->numElements = 2;
       root->numElements = 2;
       // writer->add(*root);
   
   /*
   | -26701 | NULL | -22098 |      646836227.275 |  6.786988 | z                
                                                                               
| 2024121001 |
   | -15326 | NULL | -26701 |      -28089588.567 | -2.322138 | NULL             
                                                                               
| 2024121002 |
   */
       longBatch->notNull[0] = true;
       longBatch->data[0] = -26701;
       longBatch->notNull[1] = true;
       longBatch->data[1] = -15326;
       longBatch->hasNulls = false;
       longBatch->numElements = 2;
   
       timestampBatch->notNull[0] = false;
       timestampBatch->notNull[1] = false;
       timestampBatch->hasNulls = true;
       timestampBatch->numElements = 2;
   
       longBatch2->notNull[0] = true;
       longBatch2->data[0] = -22098;
       longBatch2->notNull[1] = true;
       longBatch2->data[1] = -26701;
       longBatch2->hasNulls = false;
       longBatch2->numElements = 2;
       
       doubleBatch->notNull[0] = true;
       doubleBatch->data[0] = 646836227.275;
       doubleBatch->notNull[1] = true;
       doubleBatch->data[1] = -28089588.567;
       doubleBatch->hasNulls = false;
       doubleBatch->numElements = 2;
   
       doubleBatch2->notNull[0] = true;
       doubleBatch2->data[0] = 6.786988;
       doubleBatch2->notNull[1] = true;
       doubleBatch2->data[1] = -2.322138;
       doubleBatch2->hasNulls = false;
       doubleBatch2->numElements = 2;
   
       stringBatch->notNull[0] = true;
       stringBatch->data[0] = (char*)"a";
       stringBatch->length[0] = 1;
       stringBatch->notNull[1] = false;
       // stringBatch->data[1] = NULL;
       // stringBatch->length[1] = 0;
       stringBatch->hasNulls = true;
       stringBatch->numElements = 1;
   
       stringBatch2->notNull[0] = true;
       stringBatch2->data[0] = (char*)"2024121001";
       stringBatch2->length[0] = 10;
       stringBatch2->notNull[1] = true;
       stringBatch2->data[1] = (char*)"2024121002";
       stringBatch2->length[1] = 10;
       stringBatch2->hasNulls = false;
       stringBatch2->numElements = 2;
       root->numElements = 2;
       writer->add(*root);
   
       writer->close();
       return 0;
   }
   
   produce a file. If we read will report Caught exception in test.orc: bad 
read in RleDecoderV2::readByte


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