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/03/17 20:03:36 UTC

[GitHub] [arrow] westonpace commented on issue #12618: [RFC] [Java] Higher-level "DataFrame"-like API. Lower barrier to entry, increase adoption/audience and productivity.

westonpace commented on issue #12618:
URL: https://github.com/apache/arrow/issues/12618#issuecomment-1071331036


   In the spirit of brainstorming, JDBC has some similar interfaces (not that anyone I've ever met particularly loves them).  For creating data there is `java.sql.PreparedStatement` (although bulk inserts are less common in the OLTP world):
   
   ```
       PreparedStatement ps = c.prepareStatement("INSERT INTO table VALUES (?, ?, ?)");
       ps.setString("name", "Alice");
       ps.setInt("age", 21);
       ps.setDouble("weight", 50.0);
       ps.addBatch();
       ps.clearParameters();
       ps.setString("name", "Bob");
       ps.setInt("age", 30);
       ps.setDouble("weight", 60.0);
       ps.addBatch();
       // Could presumably go from ps to VectorSchemaRoot somehow
   ```
   
   For reading data there is `java.sql.ResultSet`:
   
   ```
       ResultSet rs = ...; // From VectorSchemaRoot
       var name1 = rs.getString("name");
       var age1 = rs.getInt("age");
       var weight1 = rs.getDouble("weight");
       rs.next();
       var name2 = rs.getString("name");
       var age2 = rs.getInt("age");
       var weight2 = rs.getDouble("weight");
   ```
   
   Even if you don't use these directly it might be valuable to have compatibility with them, especially `java.sql.ResultSet`.  It's also an abstract class so I wonder if you could have a `java.sql.ResultSet` that is a zero-copy view of Arrow data.
   
   Although I believe JPA / Hibernate style APIs are probably more popular these days:
   
   ```
       List<People> people = GetPeople();
       VectorSchemaRoot root = VectorSchemaRootFromObjects(people);
   ```


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