I am fetching arrow tabular data from an api, the content-type of the response is application/vnd.apache.arrow.stream. In my react code, I am trying to read the response as such. I am not sure if this is the optimized way of reading arrow data.
function extractDataFromTable(table) {
let extractedData = [];
// Iterate over each row of the table
for (const row of table) {
const rowJson = row.toJSON();
if (rowJson.origin_lat instanceof Float64Array) {
rowJson.origin_lat = Array.from(rowJson.origin_lat)[0]; // Assuming only one element in the array
}
if (rowJson.origin_lon instanceof Float64Array) {
rowJson.origin_lon = Array.from(rowJson.origin_lon)[0]; // Assuming only one element in the array
}
extractedData.push(rowJson);
}
return extractedData;
}
const response = await axios.get(`${baseURL}/api/new_drives`, {
params: {
name: cname,
},
responseType: "arraybuffer",
});
// Convert the response data to an Apache Arrow table
const buffer = new Uint8Array(response.data);
const table = tableFromIPC(buffer);
// Process the table to extract your data
const extractedData = extractDataFromTable(table);
data.setApiData(extractedData);
is there a better and faster way of reading arrow data?
1