-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/ant 2636 arrow #25
base: develop
Are you sure you want to change the base?
Conversation
import java.util.function.Function; | ||
|
||
public class ArrowReader { | ||
private static final BufferAllocator ALLOCATOR = new RootAllocator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be closed or created with try-with-ressources as per https://arrow.apache.org/docs/java/memory.html#bufferallocator.. to avoid memory leaks
var vector = root.getVector(field.getName()); | ||
var values = new double[vector.getValueCount()]; | ||
for (var i = 0; i < vector.getValueCount(); i++) { | ||
values[i] = ((Float8Vector) vector).get(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe is better to use instanceof instead of class casting..
var rowCount = lines.size(); | ||
var columnCount = lines.getFirst().split("\\s+").length; | ||
|
||
return readMatrix(lines, rowCount, columnCount, Double::parseDouble, (data, value) -> data.add(Double.parseDouble(value))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to handle case when line has less columns or more columns that the column count and skip them
|
||
return new Matrix(columns); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may a 2-D array might be enough as we are dealing with primitives, take a look at this Java Arrays vs ArrayLists Guide | Medium
IntStream.range(0, size).forEach(i -> vector.set(i, values[i])); | ||
} | ||
|
||
public void write(Matrix matrix, OutputStream out) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if matrix is not null before treatement
e01b7eb
to
129d4b2
Compare
|
No description provided.