Skip to content

Added getMetadataMap to Array #157

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

Merged
merged 2 commits into from
May 4, 2020
Merged

Added getMetadataMap to Array #157

merged 2 commits into from
May 4, 2020

Conversation

gsvic
Copy link
Contributor

@gsvic gsvic commented May 4, 2020

Added the getMetadataMap method, which returns a HashMap containing the Array metadata in a key-value manner.

@gsvic gsvic requested a review from Shelnutt2 May 4, 2020 13:06
@gsvic gsvic force-pushed the vg/feature/ArrayMetadataGet branch from 2f9c4cb to ce660cc Compare May 4, 2020 13:07
@gsvic gsvic mentioned this pull request May 4, 2020
* @return The metadata
* @throws TileDBError
*/
public Map<String, Object> getMetadataMap() throws TileDBError {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so we need to know the metadata type for the each key ahead of time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea behind that is that we can get the class of each object returned using .getClass. We could also provide the type as well, by returning something like Pair<NativeArray, Datatype> or Pair<Object, Datatype> but this would make the API more complex, without providing something more than .getClass() provides.

So we need either know the metadata type ahead of time or consider do some type-check before reading each value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH, Java! Forgetting about it always; LGTM than! I will remove this method from my PR than and can leave only a simple putMetadata overload :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! You can take a look here on how to use the .getClass() method: https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html

You can also take a look on how getClass() is used in that unit test: https://github.com/TileDB-Inc/TileDB-Java/pull/157/files#diff-d38ae1adae50d20e357b8edd3c64de26R554

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsvic thanks ;) I'm just looking at everything through the prism of a typed API (got used to it after years in Scala).

@gsvic gsvic merged commit 2260504 into master May 4, 2020
@gsvic gsvic deleted the vg/feature/ArrayMetadataGet branch June 3, 2020 13:05
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.

3 participants