[
https://issues.apache.org/jira/browse/KUDU-2731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16785000#comment-16785000
]
Will Berkeley commented on KUDU-2731:
-------------------------------------
See also IMPALA-8284.
Andrew pointed out that for a public API maybe returning a
{{KuduColumnSchema*}} would be better.
> Getting column schema information from KuduSchema requires copying a
> KuduColumnSchema object
> --------------------------------------------------------------------------------------------
>
> Key: KUDU-2731
> URL: https://issues.apache.org/jira/browse/KUDU-2731
> Project: Kudu
> Issue Type: Improvement
> Affects Versions: 1.9.0
> Reporter: Will Berkeley
> Priority: Major
>
> I'm looking at a CPU profile of Impala inserting into Kudu.
> {{KuduTableSink::Send}} has code that schematically does the following:
> {noformat}
> for each row in the batch
> for each column
> if (schema.Column(col_idx).isNullable()) {
> write->mutable_row()->SetNull(col);
> }
> }
> }
> {noformat}
> See
> [kudu-table-sink.cc|https://github.com/apache/impala/blob/branch-3.1.0/be/src/exec/kudu-table-sink.cc#L236].
> However, {{KuduSchema::Column}} copies the column schema and returns it by
> value, so the if statement constructs and destroys a column schema object
> just to check if the column is nullable.
> This is by far the biggest user of CPU in the Impala process (35% or so). The
> workload might be I/O bound writing to Kudu anyway, though. Nevertheless, we
> should provide a way to avoid this copying in the API, either by adding a
> method like
> {noformat}
> class KuduSchema {
> const KuduColumnSchema& get_column(int idx);
> }
> {noformat}
> or a method like
> {noformat}
> class KuduSchema {
> bool is_column_nullable(int idx);
> }
> {noformat}
> The former is the most flexible while the latter frees the client from
> worrying about holding the ref longer than the KuduColumnSchema object lives.
> We might need to add a number of methods similar to the latter method to
> cover other potentially useful things like checking encoding, type, etc.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)