emkornfield commented on a change in pull request #10716:
URL: https://github.com/apache/arrow/pull/10716#discussion_r686489838



##########
File path: go/parquet/internal/encoding/memo_table.go
##########
@@ -0,0 +1,380 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package encoding
+
+import (
+       "math"
+       "unsafe"
+
+       "github.com/apache/arrow/go/arrow"
+       "github.com/apache/arrow/go/arrow/array"
+       "github.com/apache/arrow/go/arrow/memory"
+       "github.com/apache/arrow/go/parquet"
+       "github.com/apache/arrow/go/parquet/internal/hashing"
+)
+
+//go:generate go run ../../../arrow/_tools/tmpl/main.go -i 
-data=physical_types.tmpldata memo_table_types.gen.go.tmpl
+
+// MemoTable interface that can be used to swap out implementations of the 
hash table
+// used for handling dictionary encoding. Dictionary encoding is built against 
this interface
+// to make it easy for code generation and changing implementations.
+//
+// Values should remember the order they are inserted to generate a valid 
dictionary index
+type MemoTable interface {
+       // Reset drops everything in the table allowing it to be reused
+       Reset()
+       // Size returns the current number of unique values stored in the table
+       // including whether or not a null value has been passed in using 
GetOrInsertNull
+       Size() int
+       // CopyValues populates out with the values currently in the table, out 
must
+       // be a slice of the appropriate type for the table type.
+       CopyValues(out interface{})
+       // CopyValuesSubset is like CopyValues but only copies a subset of 
values starting
+       // at the indicated index.
+       CopyValuesSubset(start int, out interface{})
+       // Get returns the index of the table the specified value is, and a 
boolean indicating
+       // whether or not the value was found in the table. Will panic if val 
is not the appropriate
+       // type for the underlying table.
+       Get(val interface{}) (int, bool)
+       // GetOrInsert is the same as Get, except if the value is not currently 
in the table it will
+       // be inserted into the table.
+       GetOrInsert(val interface{}) (idx int, existed bool, err error)
+       // GetNull returns the index of the null value and whether or not it 
was found in the table
+       GetNull() (int, bool)
+       // GetOrInsertNull returns the index of the null value, if it didn't 
already exist in the table,
+       // it is inserted.
+       GetOrInsertNull() (idx int, existed bool)
+}
+
+// BinaryMemoTable is an extension of the MemoTable interface adding extra 
methods
+// for handling byte arrays/strings/fixed length byte arrays.
+type BinaryMemoTable interface {
+       MemoTable
+       // ValuesSize returns the total number of bytes needed to copy all of 
the values
+       // from this table.
+       ValuesSize() int

Review comment:
       this includes overhead for string length?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to