You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/13 18:43:46 UTC

[GitHub] [arrow-cookbook] toddfarmer opened a new issue, #206: [Java] Parquet reading example fails with Arrow v8.0

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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-cookbook] lidavidm closed issue #206: [Java] Parquet reading example fails with Arrow v8.0

Posted by GitBox <gi...@apache.org>.
lidavidm closed issue #206: [Java] Parquet reading example fails with Arrow v8.0
URL: https://github.com/apache/arrow-cookbook/issues/206


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org