[ https://issues.apache.org/jira/browse/ARROW-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16443325#comment-16443325 ]
ASF GitHub Bot commented on ARROW-1361: --------------------------------------- BryanCutler closed pull request #972: ARROW-1361: [Java] Adding methods to get type param values in NullableValueVector URL: https://github.com/apache/arrow/pull/972 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/java/vector/src/main/codegen/templates/FixedValueVectors.java b/java/vector/src/main/codegen/templates/FixedValueVectors.java index 61164ab6c..be06a498e 100644 --- a/java/vector/src/main/codegen/templates/FixedValueVectors.java +++ b/java/vector/src/main/codegen/templates/FixedValueVectors.java @@ -67,6 +67,12 @@ this.${typeParam.name} = ${typeParam.name}; </#list> } + + <#list typeParams as typeParam> + public ${typeParam.type} get${typeParam.name?cap_first}() { + return ${typeParam.name}; + } + </#list> <#else> public ${className}(String name, BufferAllocator allocator) { super(name, allocator); @@ -80,12 +86,12 @@ public MinorType getMinorType() { @Override public Field getField() { - throw new UnsupportedOperationException("internal vector"); + throw new UnsupportedOperationException("internal vector"); } @Override public FieldReader getReader(){ - throw new UnsupportedOperationException("non-nullable vectors cannot be used in readers"); + throw new UnsupportedOperationException("non-nullable vectors cannot be used in readers"); } @Override @@ -287,7 +293,7 @@ public void copyFrom(int fromIndex, int thisIndex, ${className} from){ public void copyFromSafe(int fromIndex, int thisIndex, ${className} from){ while(thisIndex >= getValueCapacity()) { - reAlloc(); + reAlloc(); } copyFrom(fromIndex, thisIndex, from); } diff --git a/java/vector/src/main/codegen/templates/NullableValueVectors.java b/java/vector/src/main/codegen/templates/NullableValueVectors.java index bd322ea30..f7a6804c2 100644 --- a/java/vector/src/main/codegen/templates/NullableValueVectors.java +++ b/java/vector/src/main/codegen/templates/NullableValueVectors.java @@ -65,7 +65,9 @@ <#if minor.typeParams??> <#assign typeParams = minor.typeParams?reverse> <#list typeParams as typeParam> - private final ${typeParam.type} ${typeParam.name}; + public ${typeParam.type} get${typeParam.name?cap_first}() { + return values.get${typeParam.name?cap_first}(); + } </#list> /** @@ -97,7 +99,7 @@ <#assign typeParams = minor.typeParams?reverse> ${minor.arrowType} arrowType = (${minor.arrowType})fieldType.getType(); <#list typeParams as typeParam> - this.${typeParam.name} = arrowType.get${typeParam.name?cap_first}(); + ${typeParam.type} ${typeParam.name} = arrowType.get${typeParam.name?cap_first}(); </#list> this.values = new ${valuesName}(valuesField, allocator<#list typeParams as typeParam>, ${typeParam.name}</#list>); <#else> @@ -331,7 +333,7 @@ public void zeroVector() { @Override public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack) { - return getTransferPair(ref, allocator); + return getTransferPair(ref, allocator); } @Override diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java index 774fbe084..a10d5b2c5 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java @@ -41,15 +41,17 @@ } } - private int scale = 3; - @Test public void test() { + int precision = 10; + int scale = 3; BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); - NullableDecimalVector decimalVector = TestUtils.newVector(NullableDecimalVector.class, "decimal", new ArrowType.Decimal(10, scale), allocator); - try (NullableDecimalVector oldConstructor = new NullableDecimalVector("decimal", allocator, 10, scale);) { + NullableDecimalVector decimalVector = TestUtils.newVector(NullableDecimalVector.class, "decimal", new ArrowType.Decimal(precision, scale), allocator); + try (NullableDecimalVector oldConstructor = new NullableDecimalVector("decimal", allocator, precision, scale);) { assertEquals(decimalVector.getField().getType(), oldConstructor.getField().getType()); } + assertEquals(decimalVector.getPrecision(), precision); + assertEquals(decimalVector.getScale(), scale); decimalVector.allocateNew(); BigDecimal[] values = new BigDecimal[intValues.length]; for (int i = 0; i < intValues.length; i++) { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [Java] Add minor type param accessors to NullableValueVectors > ------------------------------------------------------------- > > Key: ARROW-1361 > URL: https://issues.apache.org/jira/browse/ARROW-1361 > Project: Apache Arrow > Issue Type: Improvement > Components: Java - Vectors > Reporter: Bryan Cutler > Assignee: Bryan Cutler > Priority: Major > Labels: pull-request-available > > A {{NullableValueVector}} creates private copies of each param in the minor > type, but does not have any way public api to access them. So if given a > {{NullableValueVector}} you would have to use the {{Field}} and cast to the > correct type. For example, with a {{NullableTimeStampMicroTZVector}} and > trying to get the timezone: > {noformat} > if field.getType.isInstanceOf[ArrowType.Timestamp] && > field.getType.asInstanceOf[ArrowType.Timestamp].getTimezone > {noformat} > It would be more convenient to have direct accessors for these type params. > Also, it is possible to do some minor refactoring because > {{NullableValueVectors}} does not use these type params, so there is no need > to store them. They already exist in the inner vector object and the Field > type. -- This message was sent by Atlassian JIRA (v7.6.3#76005)