builder

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxSizeReached = fmt.Errorf("max size reached")

Functions

func AppendArray

func AppendArray(cb ColumnBuilder, arr arrow.Array) error

TODO(asubiotto): This function doesn't handle NULLs in the case of optimized builders.

func AppendGoValue

func AppendGoValue(cb ColumnBuilder, v any) error

func AppendValue

func AppendValue(cb ColumnBuilder, arr arrow.Array, i int) error

func RollbackPrevious

func RollbackPrevious(cb ColumnBuilder) error

Types

type ColumnBuilder

type ColumnBuilder interface {
	Retain()
	Release()
	Len() int
	AppendNull()
	Reserve(int)
	NewArray() arrow.Array
}

ColumnBuilder is a subset of the array.Builder interface implemented by the optimized builders in this file.

func NewBuilder

func NewBuilder(mem memory.Allocator, t arrow.DataType) ColumnBuilder

type ListBuilder

type ListBuilder struct {
	// contains filtered or unexported fields
}

ListBuilder is a wrapper over an array.ListBuilder that uses ColumnBuilder as a values buffer.

func NewListBuilder

func NewListBuilder(mem memory.Allocator, etype arrow.DataType) *ListBuilder

func (*ListBuilder) Append

func (b *ListBuilder) Append(v bool)

func (*ListBuilder) AppendNull

func (b *ListBuilder) AppendNull()

func (*ListBuilder) AppendValues

func (b *ListBuilder) AppendValues(offsets []int32, valid []bool)

func (*ListBuilder) Len

func (b *ListBuilder) Len() int

func (*ListBuilder) NewArray

func (b *ListBuilder) NewArray() arrow.Array

NewArray creates a List array from the memory buffers used by the builder and resets the ListBuilder so it can be used to build a new array.

func (*ListBuilder) NewListArray

func (b *ListBuilder) NewListArray() (a *array.List)

NewListArray creates a List array from the memory buffers used by the builder and resets the ListBuilder so it can be used to build a new array.

func (*ListBuilder) Release

func (b *ListBuilder) Release()

Release decreases the reference count by 1. When the reference count goes to zero, the memory is freed.

func (*ListBuilder) Reserve

func (b *ListBuilder) Reserve(n int)

Reserve ensures there is enough space for appending n elements by checking the capacity and calling Resize if necessary.

func (*ListBuilder) Resize

func (b *ListBuilder) Resize(n int)

Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(), additional memory will be allocated. If n is smaller, the allocated memory may reduced.

func (*ListBuilder) Retain

func (b *ListBuilder) Retain()

func (*ListBuilder) ValueBuilder

func (b *ListBuilder) ValueBuilder() ColumnBuilder

type OptBinaryBuilder

type OptBinaryBuilder struct {
	// contains filtered or unexported fields
}

OptBinaryBuilder is an optimized array.BinaryBuilder.

func NewOptBinaryBuilder

func NewOptBinaryBuilder(dtype arrow.BinaryDataType) *OptBinaryBuilder

func (*OptBinaryBuilder) Append

func (b *OptBinaryBuilder) Append(v []byte) error

func (*OptBinaryBuilder) AppendData

func (b *OptBinaryBuilder) AppendData(data []byte, offsets []uint32) error

AppendData appends a flat slice of bytes to the builder, with an accompanying slice of offsets. This data is considered to be non-null.

func (*OptBinaryBuilder) AppendNull

func (b *OptBinaryBuilder) AppendNull()

AppendNull adds a new null value to the array being built. This is slow, don't use it.

func (*OptBinaryBuilder) AppendNulls

func (b *OptBinaryBuilder) AppendNulls(n int)

AppendNulls appends n null values to the array being built. This is specific to distinct optimizations in FrostDB.

func (*OptBinaryBuilder) AppendParquetValues

func (b *OptBinaryBuilder) AppendParquetValues(values []parquet.Value) error

AppendParquetValues appends the given parquet values to the builder. The values may be null, but if it is known upfront that none of the values are null, AppendData offers a more efficient way of appending values.

func (*OptBinaryBuilder) IsNull

func (b *OptBinaryBuilder) IsNull(n int) bool

func (*OptBinaryBuilder) IsValid

func (b *OptBinaryBuilder) IsValid(n int) bool

func (*OptBinaryBuilder) Len

func (b *OptBinaryBuilder) Len() int

Len returns the number of elements in the array builder.

func (*OptBinaryBuilder) NewArray

func (b *OptBinaryBuilder) NewArray() arrow.Array

NewArray creates a new array from the memory buffers used by the builder and resets the Builder so it can be used to build a new array.

func (*OptBinaryBuilder) Release

func (b *OptBinaryBuilder) Release()

Release decreases the reference count by 1. When the reference count goes to zero, the memory is freed. Release may be called simultaneously from multiple goroutines.

func (*OptBinaryBuilder) RepeatLastValue

func (b *OptBinaryBuilder) RepeatLastValue(n int) error

RepeatLastValue is specific to distinct optimizations in FrostDB.

func (*OptBinaryBuilder) Reserve

func (b *OptBinaryBuilder) Reserve(int)

func (*OptBinaryBuilder) ResetToLength

func (b *OptBinaryBuilder) ResetToLength(n int)

ResetToLength is specific to distinct optimizations in FrostDB.

func (*OptBinaryBuilder) Retain

func (b *OptBinaryBuilder) Retain()

func (*OptBinaryBuilder) SetNull

func (b *OptBinaryBuilder) SetNull(i int)

SetNull is setting the value at the index i to null.

func (*OptBinaryBuilder) Value

func (b *OptBinaryBuilder) Value(i int) []byte

type OptBooleanBuilder

type OptBooleanBuilder struct {
	// contains filtered or unexported fields
}

func NewOptBooleanBuilder

func NewOptBooleanBuilder(dtype arrow.DataType) *OptBooleanBuilder

func (*OptBooleanBuilder) Append

func (b *OptBooleanBuilder) Append(data []byte, valid int)

func (*OptBooleanBuilder) AppendData

func (b *OptBooleanBuilder) AppendData(_ []byte)

func (*OptBooleanBuilder) AppendNull

func (b *OptBooleanBuilder) AppendNull()

func (*OptBooleanBuilder) AppendNulls

func (b *OptBooleanBuilder) AppendNulls(n int)

func (*OptBooleanBuilder) AppendParquetValues

func (b *OptBooleanBuilder) AppendParquetValues(values []parquet.Value)

func (*OptBooleanBuilder) AppendSingle

func (b *OptBooleanBuilder) AppendSingle(v bool)

func (*OptBooleanBuilder) IsNull

func (b *OptBooleanBuilder) IsNull(n int) bool

func (*OptBooleanBuilder) IsValid

func (b *OptBooleanBuilder) IsValid(n int) bool

func (*OptBooleanBuilder) Len

func (b *OptBooleanBuilder) Len() int

Len returns the number of elements in the array builder.

func (*OptBooleanBuilder) NewArray

func (b *OptBooleanBuilder) NewArray() arrow.Array

func (*OptBooleanBuilder) Release

func (b *OptBooleanBuilder) Release()

func (*OptBooleanBuilder) RepeatLastValue

func (b *OptBooleanBuilder) RepeatLastValue(n int) error

func (*OptBooleanBuilder) Reserve

func (b *OptBooleanBuilder) Reserve(int)

func (*OptBooleanBuilder) ResetToLength

func (b *OptBooleanBuilder) ResetToLength(n int)

ResetToLength is specific to distinct optimizations in FrostDB.

func (*OptBooleanBuilder) Retain

func (b *OptBooleanBuilder) Retain()

func (*OptBooleanBuilder) Set

func (b *OptBooleanBuilder) Set(i int, v bool)

func (*OptBooleanBuilder) SetNull

func (b *OptBooleanBuilder) SetNull(i int)

SetNull is setting the value at the index i to null.

func (*OptBooleanBuilder) Value

func (b *OptBooleanBuilder) Value(i int) bool

type OptInt32Builder

type OptInt32Builder struct {
	// contains filtered or unexported fields
}

func NewOptInt32Builder

func NewOptInt32Builder(dtype arrow.DataType) *OptInt32Builder

func (*OptInt32Builder) Add

func (b *OptInt32Builder) Add(i int, v int32)

func (*OptInt32Builder) Append

func (b *OptInt32Builder) Append(v int32)

func (*OptInt32Builder) AppendData

func (b *OptInt32Builder) AppendData(data []int32)

AppendData appends a slice of int32s to the builder. This data is considered to be non-null.

func (*OptInt32Builder) AppendNull

func (b *OptInt32Builder) AppendNull()

func (*OptInt32Builder) AppendNulls

func (b *OptInt32Builder) AppendNulls(n int)

func (*OptInt32Builder) AppendParquetValues

func (b *OptInt32Builder) AppendParquetValues(values []parquet.Value)

func (*OptInt32Builder) IsNull

func (b *OptInt32Builder) IsNull(n int) bool

func (*OptInt32Builder) IsValid

func (b *OptInt32Builder) IsValid(n int) bool

func (*OptInt32Builder) Len

func (b *OptInt32Builder) Len() int

Len returns the number of elements in the array builder.

func (*OptInt32Builder) NewArray

func (b *OptInt32Builder) NewArray() arrow.Array

func (*OptInt32Builder) Release

func (b *OptInt32Builder) Release()

func (*OptInt32Builder) RepeatLastValue

func (b *OptInt32Builder) RepeatLastValue(n int) error

func (*OptInt32Builder) Reserve

func (b *OptInt32Builder) Reserve(n int)

func (*OptInt32Builder) ResetToLength

func (b *OptInt32Builder) ResetToLength(n int)

ResetToLength is specific to distinct optimizations in FrostDB.

func (*OptInt32Builder) Retain

func (b *OptInt32Builder) Retain()

func (*OptInt32Builder) Set

func (b *OptInt32Builder) Set(i int, v int32)

Set sets value v at index i. THis will panic if i is out of bounds. Use this after calling Reserve.

func (*OptInt32Builder) SetNull

func (b *OptInt32Builder) SetNull(i int)

SetNull is setting the value at the index i to null.

func (*OptInt32Builder) Swap

func (b *OptInt32Builder) Swap(i, j int)

Swap swaps values at i and j index.

func (*OptInt32Builder) Value

func (b *OptInt32Builder) Value(i int) int32

type OptInt64Builder

type OptInt64Builder struct {
	// contains filtered or unexported fields
}

func NewOptInt64Builder

func NewOptInt64Builder(dtype arrow.DataType) *OptInt64Builder

func (*OptInt64Builder) Add

func (b *OptInt64Builder) Add(i int, v int64)

func (*OptInt64Builder) Append

func (b *OptInt64Builder) Append(v int64)

func (*OptInt64Builder) AppendData

func (b *OptInt64Builder) AppendData(data []int64)

AppendData appends a slice of int64s to the builder. This data is considered to be non-null.

func (*OptInt64Builder) AppendNull

func (b *OptInt64Builder) AppendNull()

func (*OptInt64Builder) AppendNulls

func (b *OptInt64Builder) AppendNulls(n int)

func (*OptInt64Builder) AppendParquetValues

func (b *OptInt64Builder) AppendParquetValues(values []parquet.Value)

func (*OptInt64Builder) IsNull

func (b *OptInt64Builder) IsNull(n int) bool

func (*OptInt64Builder) IsValid

func (b *OptInt64Builder) IsValid(n int) bool

func (*OptInt64Builder) Len

func (b *OptInt64Builder) Len() int

Len returns the number of elements in the array builder.

func (*OptInt64Builder) NewArray

func (b *OptInt64Builder) NewArray() arrow.Array

func (*OptInt64Builder) Release

func (b *OptInt64Builder) Release()

func (*OptInt64Builder) RepeatLastValue

func (b *OptInt64Builder) RepeatLastValue(n int) error

func (*OptInt64Builder) Reserve

func (b *OptInt64Builder) Reserve(int)

func (*OptInt64Builder) ResetToLength

func (b *OptInt64Builder) ResetToLength(n int)

ResetToLength is specific to distinct optimizations in FrostDB.

func (*OptInt64Builder) Retain

func (b *OptInt64Builder) Retain()

func (*OptInt64Builder) Set

func (b *OptInt64Builder) Set(i int, v int64)

func (*OptInt64Builder) SetNull

func (b *OptInt64Builder) SetNull(i int)

SetNull is setting the value at the index i to null.

func (*OptInt64Builder) Value

func (b *OptInt64Builder) Value(i int) int64

Value returns the ith value of the builder.

type OptimizedBuilder

type OptimizedBuilder interface {
	ColumnBuilder
	AppendNulls(int)
	ResetToLength(int)
	RepeatLastValue(int) error
	IsNull(i int) bool
	IsValid(i int) bool
	SetNull(i int)
}

OptimizedBuilder is a set of FrostDB specific builder methods.

type RecordBuilder

type RecordBuilder struct {
	// contains filtered or unexported fields
}

RecordBuilder eases the process of building a Record, iteratively, from a known Schema.

func NewRecordBuilder

func NewRecordBuilder(mem memory.Allocator, schema *arrow.Schema) *RecordBuilder

NewRecordBuilder returns a builder, using the provided memory allocator and a schema.

func (*RecordBuilder) ExpandSchema

func (b *RecordBuilder) ExpandSchema(schema *arrow.Schema)

ExpandSchema expands the record builder schema by adding new fields.

func (*RecordBuilder) Field

func (b *RecordBuilder) Field(i int) ColumnBuilder

func (*RecordBuilder) Fields

func (b *RecordBuilder) Fields() []ColumnBuilder

func (*RecordBuilder) NewRecord

func (b *RecordBuilder) NewRecord() arrow.Record

NewRecord creates a new record from the memory buffers and resets the RecordBuilder so it can be used to build a new record.

The returned Record must be Release()'d after use.

NewRecord panics if the fields' builder do not have the same length.

func (*RecordBuilder) Release

func (b *RecordBuilder) Release()

Release decreases the reference count by 1.

func (*RecordBuilder) Reserve

func (b *RecordBuilder) Reserve(size int)

func (*RecordBuilder) Reset

func (b *RecordBuilder) Reset()

Reset will call ResetFull on any dictionary builders to prevent memo tables from growing unbounded.

func (*RecordBuilder) Retain

func (b *RecordBuilder) Retain()

Retain increases the reference count by 1. Retain may be called simultaneously from multiple goroutines.

func (*RecordBuilder) Schema

func (b *RecordBuilder) Schema() *arrow.Schema

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL