[ 
https://issues.apache.org/jira/browse/DRILL-5709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16120782#comment-16120782
 ] 

ASF GitHub Bot commented on DRILL-5709:
---------------------------------------

GitHub user paul-rogers opened a pull request:

    https://github.com/apache/drill/pull/901

    DRILL-5709: Provide a value vector method to convert a vector to nullable

    Please see the DRILL-5709 for an explanation and example.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paul-rogers/drill DRILL-5709

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/drill/pull/901.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #901
    
----
commit ced37d52d161daae333d6048150f92c181defa53
Author: Paul Rogers <prog...@maprtech.com>
Date:   2017-08-09T03:04:24Z

    DRILL-5709: Provide a value vector method to convert a vector to nullable
    
    Please see the DRILL-5709 for an explanation and example.

----


> Provide a value vector method to convert a vector to nullable
> -------------------------------------------------------------
>
>                 Key: DRILL-5709
>                 URL: https://issues.apache.org/jira/browse/DRILL-5709
>             Project: Apache Drill
>          Issue Type: Improvement
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>             Fix For: 1.12.0
>
>
> The hash agg spill work has need to convert a non-null scalar vector to the 
> nullable equivalent. For efficiency, the code wishes to simply transfer the 
> underlying data buffer(s), and create the required "bits" vector, rather than 
> generating code that does the transfer row-by-row.
> The solution is to add a {{toNullable(ValueVector nullableVector)}} method to 
> the {{ValueVector}} class, then implement it where needed.
> Since the target code only works with scalars (that is, no arrays, no maps, 
> no lists), the code only handles these cases, throwing an 
> {{UnsupportedOperationException}} in other cases.
> Usage:
> {code}
> ValueVector nonNullableVector = // your non-nullable vector
> MajorType type = MajorType.newBuilder(nonNullableVector.getType)
>     .setMode(DataMode.OPTIONAL)
>     .build();
> MaterializedField field = MaterializedField.create(name, type);
> ValueVector nullableVector = TypeHelper.getNewVector(field, 
> oContext.getAllocator());
> nonNullableVector.toNullable(nullableVector);
> // Data is now in nullableVector
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to