toddfarmer opened a new issue, #206:
URL: https://github.com/apache/arrow-cookbook/issues/206

   Changes to the Java APIs since version 7.0 result in the cookbook example 
[Query Data Content for 
File](https://arrow.apache.org/cookbook/java/dataset.html#query-data-content-for-file)
 no longer compiling.  The updated API appears to be used in [this test 
case](https://github.com/apache/arrow/blob/dc97883dee25ba8da55c7591060c44de2ea00865/java/dataset/src/test/java/org/apache/arrow/dataset/TestDataset.java#L78-L90),
 and the following modified cookbook code resulted in successful 
compilation/execution:
   
   ```java
       String uri = "file:" + System.getProperty("user.dir") + 
"/thirdpartydeps/parquetfiles/data1.parquet";
       ScanOptions options = new ScanOptions(/*batchSize*/ 100);
       try (
               BufferAllocator allocator = new RootAllocator();
               DatasetFactory datasetFactory = new 
FileSystemDatasetFactory(allocator, NativeMemoryPool.getDefault(), 
FileFormat.PARQUET, uri);
               Dataset dataset = datasetFactory.finish();
               Scanner scanner = dataset.newScan(options);
               VectorSchemaRoot vsr = VectorSchemaRoot.create(scanner.schema(), 
allocator)
       ) {
         scanner.scan().forEach(scanTask -> {
           VectorLoader loader = new VectorLoader(vsr);
           ArrowReader reader = scanTask.execute();
           try {
             while (reader.loadNextBatch()) {
               VectorSchemaRoot root = reader.getVectorSchemaRoot();
               final VectorUnloader unloader = new VectorUnloader(root);
               loader.load(unloader.getRecordBatch());
               System.out.print(vsr.contentToTSVString());
               System.out.println("DONE!");
             }
           } catch (IOException ex) {
             ex.printStackTrace();
           }
         });
       } catch (Exception e) {
         e.printStackTrace();
       }
   ```


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