-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
GH-38246: [JAVA] added new getTransferPair() function that takes in a Field type for Complex Type Vectors #38261
Conversation
|
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.
Let's keep this class immutable. A method that makes a copy of the field with children is OK, but mutating the field isn't.
if (field.getChildren().contains(getDataVector().getField())) { | ||
return field; | ||
} | ||
field.setChildren(Collections.singletonList(getDataVector().getField())); | ||
return field; |
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.
Instead of mutating the field here, we can keep the check, but just create (and cache) a new field if needed. IMO, if the garbage is that much of a concern, the creator of the vector should provide the expected type up front (this only exists because a ListVector can set its child type dynamically).
@@ -134,8 +134,12 @@ public interface ValueVector extends Closeable, Iterable<ValueVector> { | |||
|
|||
TransferPair getTransferPair(String ref, BufferAllocator allocator); | |||
|
|||
TransferPair getTransferPair(Field field, BufferAllocator allocator); |
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.
Hmm, it's unfortunate that this makes existing callsites ambiguous...we should've renamed it in the original PR.
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.
While there's no docstring for the existing function, let's add a docstring for the new ones at least.
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.
Why was this test changed?
field.setChildren(children); | ||
return field; |
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.
caching the field is OK, but let's not mutate it.
@@ -121,9 +119,27 @@ public static LargeListVector empty(String name, BufferAllocator allocator) { | |||
*/ | |||
public LargeListVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { | |||
super(allocator); | |||
this.name = name; | |||
this.field = new Field(name, fieldType, null); |
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.
can't this constructor delegate to the one below?
@@ -95,7 +94,23 @@ public static ListVector empty(String name, BufferAllocator allocator) { | |||
public ListVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { | |||
super(name, allocator, callBack); | |||
this.validityBuffer = allocator.getEmpty(); | |||
this.fieldType = checkNotNull(fieldType); | |||
this.field = new Field(name, fieldType, null); |
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.
delegate this ctor to the one below?
this.listSize = ((ArrowType.FixedSizeList) fieldType.getType()).getListSize(); | ||
Preconditions.checkArgument(listSize >= 0, "list size must be non-negative"); | ||
this.valueCount = 0; | ||
this.validityAllocationSizeInBytes = getValidityBufferSizeFromCount(INITIAL_VALUE_ALLOCATION); | ||
this.field = new Field(name, fieldType, null); |
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.
delegate this ctor to the one below?
@lidavidm could you plz re-review? |
@lidavidm still need re-review, plz |
After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit a376e3c. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 15 possible false positives for unstable benchmarks that are known to sometimes produce them. |
…s in a Field type for Complex Type Vectors (apache#38261) (#57) ### Rationale for this change Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### What changes are included in this PR? - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### Are these changes tested? Yes, some tests have been added to verify these changes. ### Are there any user-facing changes? Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]> (cherry picked from commit a376e3c)
…s in a Field type for Complex Type Vectors (apache#38261) ### Rationale for this change Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### What changes are included in this PR? - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### Are these changes tested? Yes, some tests have been added to verify these changes. ### Are there any user-facing changes? Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]>
…s in a Field type for Complex Type Vectors (apache#38261) ### Rationale for this change Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### What changes are included in this PR? - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### Are these changes tested? Yes, some tests have been added to verify these changes. ### Are there any user-facing changes? Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]>
…s in a Field type for Complex Type Vectors (apache#38261) (#57) ### Rationale for this change Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### What changes are included in this PR? - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### Are these changes tested? Yes, some tests have been added to verify these changes. ### Are there any user-facing changes? Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]> (cherry picked from commit a376e3c)
…s in a Field type for Complex Type Vectors (apache#38261) ### Rationale for this change Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### What changes are included in this PR? - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### Are these changes tested? Yes, some tests have been added to verify these changes. ### Are there any user-facing changes? Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]>
…s in a Field type for Complex Type Vectors (apache#38261) (#57) Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. Yes, some tests have been added to verify these changes. Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]> (cherry picked from commit a376e3c)
…s in a Field type for Complex Type Vectors (apache#38261) (#57) Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. Yes, some tests have been added to verify these changes. Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]> (cherry picked from commit a376e3c)
…s in a Field type for Complex Type Vectors (apache#38261) (#57) Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. Yes, some tests have been added to verify these changes. Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]> (cherry picked from commit a376e3c)
…s in a Field type for Complex Type Vectors (apache#38261) (#57) Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. Yes, some tests have been added to verify these changes. Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]> (cherry picked from commit a376e3c)
…s in a Field type for Complex Type Vectors (apache#38261) ### Rationale for this change Additionally, a new function **getTransferPair(Field, Allocator)** is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector. Added Field.setChildren() method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### What changes are included in this PR? - `getTransferPair` method for ComplexType Vectors and for BaseVariableWidthVector's - added `Field.setChildren()` method and made **children** not final - for updating **field** object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object. ### Are these changes tested? Yes, some tests have been added to verify these changes. ### Are there any user-facing changes? Yes. **This PR includes breaking changes to public APIs.** * Closes: apache#38246 Lead-authored-by: Ivan Chesnov <[email protected]> Co-authored-by: Ivan Chesnov <[email protected]> Signed-off-by: David Li <[email protected]>
Rationale for this change
Additionally, a new function getTransferPair(Field, Allocator) is introduced so that a new Field method is not constructed each time getTransferPair is called on the Vector.
Added Field.setChildren() method and made children not final - for updating field object inside complex vector(it possible that Field will be without children on creation) - optimisation for keeping using already existing Field object.
What changes are included in this PR?
getTransferPair
method for ComplexType Vectors and for BaseVariableWidthVector'sAre these changes tested?
Yes, some tests have been added to verify these changes.
Are there any user-facing changes?
Yes.
This PR includes breaking changes to public APIs.