Rahul-324 commented on issue #1057:
URL: https://github.com/apache/arrow-java/issues/1057#issuecomment-4025991897

   ScanOptions options = new ScanOptions(/*batchSize=*/ 65_536);
   
   try (RootAllocator allocator = new RootAllocator(512 * 1024 * 1024);
        NativeMemoryPool nativePool = NativeMemoryPool.createListenable(
                DirectReservationListener.instance());
        FileSystemDatasetFactory datasetFactory = new FileSystemDatasetFactory(
                allocator, nativePool, FileFormat.PARQUET, hdfsUri);
        Dataset dataset = datasetFactory.finish();
        Scanner scanner = dataset.newScan(options);
        ArrowReader reader = scanner.scanBatches()) {
   
       long totalRows = 0;
       int batchCount = 0;
   
       
       VectorSchemaRoot root = reader.getVectorSchemaRoot();
   
       while (reader.loadNextBatch()) {
           int rowCount = root.getRowCount();
           totalRows += rowCount;
           batchCount++;
           System.out.println("Batch " + batchCount + " - rows: " + rowCount + 
", total: " + totalRows);
       }
   
       System.out.println("Total batches: " + batchCount);
       System.out.println("Total rows: " + totalRows);
   
   } catch (Exception e) {
       logger.error("Error processing parquet file", e);
   }
   
   
   


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