@@ -30,7 +30,7 @@ const (
3030 stringArrayMaximumCapacity = math .MaxInt32
3131)
3232
33- // A type which represents an immutable sequence of variable-length UTF-8 strings.
33+ // String is a type which represents an immutable sequence of variable-length UTF-8 strings.
3434type String struct {
3535 array
3636 offsets []int32
@@ -45,11 +45,18 @@ func NewStringData(data *Data) *String {
4545 return a
4646}
4747
48+ // Reset resets the String with a different set of Data.
49+ func (a * String ) Reset (data * Data ) {
50+ a .setData (data )
51+ }
52+
4853// Value returns the slice at index i. This value should not be mutated.
4954func (a * String ) Value (i int ) string {
5055 i = i + a .array .data .offset
5156 return a .values [a .offsets [i ]:a .offsets [i + 1 ]]
5257}
58+
59+ // ValueOffset returns the offset of the value at index i.
5360func (a * String ) ValueOffset (i int ) int { return int (a .offsets [i ]) }
5461
5562func (a * String ) String () string {
@@ -104,6 +111,7 @@ type StringBuilder struct {
104111 builder * BinaryBuilder
105112}
106113
114+ // NewStringBuilder creates a new StringBuilder.
107115func NewStringBuilder (mem memory.Allocator ) * StringBuilder {
108116 b := & StringBuilder {
109117 builder : NewBinaryBuilder (mem , arrow .BinaryTypes .String ),
@@ -134,10 +142,12 @@ func (b *StringBuilder) Cap() int { return b.builder.Cap() }
134142// NullN returns the number of null values in the array builder.
135143func (b * StringBuilder ) NullN () int { return b .builder .NullN () }
136144
145+ // Append appends a string to the builder.
137146func (b * StringBuilder ) Append (v string ) {
138147 b .builder .Append ([]byte (v ))
139148}
140149
150+ // AppendNull appends a null to the builder.
141151func (b * StringBuilder ) AppendNull () {
142152 b .builder .AppendNull ()
143153}
@@ -149,6 +159,7 @@ func (b *StringBuilder) AppendValues(v []string, valid []bool) {
149159 b .builder .AppendStringValues (v , valid )
150160}
151161
162+ // Value returns the string at index i.
152163func (b * StringBuilder ) Value (i int ) string {
153164 return string (b .builder .Value (i ))
154165}
0 commit comments