You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ze...@apache.org on 2024/01/09 21:25:31 UTC

(arrow) branch main updated: GH-38988: [Go] Expose dictionary size from DictionaryBuilder (#39521)

This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 92520c67b4 GH-38988: [Go] Expose dictionary size from DictionaryBuilder (#39521)
92520c67b4 is described below

commit 92520c67b4fbeddf5a0c4e829ce2ca0bf54adccd
Author: ella-chao <el...@datadoghq.com>
AuthorDate: Tue Jan 9 21:25:24 2024 +0000

    GH-38988: [Go] Expose dictionary size from DictionaryBuilder (#39521)
    
    
    
    ### Rationale for this change
    
    Details are in https://github.com/apache/arrow/issues/38988
    
    ### What changes are included in this PR?
    
    This adds a method to `DictionaryBuilder` that returns the current dictionary size.
    
    ### Are these changes tested?
    
    Updated an existing test to account for this new method.
    
    ### Are there any user-facing changes?
    
    Yes, a new method is added to `DictionaryBuilder`.
    
    * Closes: #38988
    
    Authored-by: Ella Chao <el...@datadoghq.com>
    Signed-off-by: Matt Topol <zo...@gmail.com>
---
 go/arrow/array/dictionary.go      | 5 +++++
 go/arrow/array/dictionary_test.go | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/go/arrow/array/dictionary.go b/go/arrow/array/dictionary.go
index 125c02391f..bbde4e4f1e 100644
--- a/go/arrow/array/dictionary.go
+++ b/go/arrow/array/dictionary.go
@@ -412,6 +412,7 @@ type DictionaryBuilder interface {
 	AppendArray(arrow.Array) error
 	AppendIndices([]int, []bool)
 	ResetFull()
+	DictionarySize() int
 }
 
 type dictionaryBuilder struct {
@@ -1004,6 +1005,10 @@ func (b *dictionaryBuilder) AppendIndices(indices []int, valid []bool) {
 	}
 }
 
+func (b *dictionaryBuilder) DictionarySize() int {
+	return b.memoTable.Size()
+}
+
 type NullDictionaryBuilder struct {
 	dictionaryBuilder
 }
diff --git a/go/arrow/array/dictionary_test.go b/go/arrow/array/dictionary_test.go
index 5a3e0e10c2..f32cc9555f 100644
--- a/go/arrow/array/dictionary_test.go
+++ b/go/arrow/array/dictionary_test.go
@@ -92,6 +92,8 @@ func (p *PrimitiveDictionaryTestSuite) TestDictionaryBuilderBasic() {
 	p.EqualValues(4, bldr.Len())
 	p.EqualValues(1, bldr.NullN())
 
+	p.EqualValues(2, bldr.DictionarySize())
+
 	arr := bldr.NewArray().(*array.Dictionary)
 	defer arr.Release()