Skip to content
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

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft

Feature/ant 2636 arrow #25

wants to merge 10 commits into from

Conversation

vargastat
Copy link
Contributor

No description provided.

import java.util.function.Function;

public class ArrowReader {
private static final BufferAllocator ALLOCATOR = new RootAllocator();
Copy link
Contributor Author

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);
Copy link
Contributor Author

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)));
Copy link
Contributor Author

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);
}
}
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

@salemsd salemsd force-pushed the feature/ANT_2636_arrow branch from e01b7eb to 129d4b2 Compare February 3, 2025 13:32
Copy link

sonarqubecloud bot commented Feb 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant