googleapis / java-spanner

Apache License 2.0
64 stars 115 forks source link

Support for bool Array in AbstractResultSet #2183

Closed MedhaCS1010 closed 1 year ago

MedhaCS1010 commented 1 year ago

[Request/Enhancement] Abstract Result Set provides option to get array result as unmodifiable list for all the supported types but for primitive types like int64 and float64 it also provides an option to get the result as array.
Can we extend this functionality to support for boolean as well because bool is also a primitive?

[Solution] We can add another BoolArray class similar to Int64Array

Will be happy to raise the PR for the same.

gauravpurohit06 commented 1 year ago

In my opinion adding the primitive support for boolean like we have for int64 and float64 will definitely going to be a performance gain as primitives are a bit faster and we don't have to construct new wrapper objects for each array element.

gauravpurohit06 commented 1 year ago

@olavloite, can you please chime in and provide your thoughts here?

olavloite commented 1 year ago

We already have boolean[] getBooleanArray(..). See https://github.com/googleapis/java-spanner/blob/028505b26f8da0541e8e281fc5f6646b469b332d/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractStructReader.java#L265 (ResultSet extends from AbstractStructReader)

We don't need a specific BoolArray class for that, as the underlying values are already booleans.

gauravpurohit06 commented 1 year ago

Closing it here as we already have boolean[] getBooleanArray(..) support. @MedhaCS1010 , please feel free to log new issues and enhancements request. Thank you!!