in http/get_simple/java/client/src/main/java/com/example/ArrowHttpClient.java [35:79]
public static void main(String[] args) {
String serverUrl = "http://localhost:8008";
try {
long startTime = System.currentTimeMillis();
URL url = new URL(serverUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream();
BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
ArrowStreamReader reader = new ArrowStreamReader(inputStream, allocator);
VectorSchemaRoot root = reader.getVectorSchemaRoot();
VectorUnloader unloader = new VectorUnloader(root);
ArrowRecordBatch batch;
Schema schema = root.getSchema();
List<ArrowRecordBatch> batches = new ArrayList<>();
int numRows = 0;
while (reader.loadNextBatch()) {
numRows += root.getRowCount();
batch = unloader.getRecordBatch();
batches.add(batch);
}
long endTime = System.currentTimeMillis();
float execTime = (endTime - startTime) / 1000F;
System.out.println(reader.bytesRead() + " bytes received");
System.out.println(numRows + " records received");
System.out.println(batches.size() + " record batches received");
System.out.printf("%.2f seconds elapsed\n", execTime);
reader.close();
} else {
System.err.println("Failed with response code: " + connection.getResponseCode());
}
} catch (IOException e) {
e.printStackTrace();
}
}