Documentation ¶
Index ¶
- Variables
- func Count[T any](s Unary[T]) (cnt int, err error)
- func CountDual[K, V any](s Dual[K, V]) (cnt int, err error)
- func CountKV(s KV) (int, error)
- func CountU64(s U64) (int, error)
- func ExpectEqual[V comparable](tb testing.TB, s1, s2 Unary[V])
- func ExpectEqualU64(tb testing.TB, s1, s2 Unary[uint64])
- func ToArr[T any](s Unary[T]) (res []T, err error)
- func ToArrKVMust(s KV) ([][]byte, [][]byte)
- func ToArrU64Must(s U64) []uint64
- func ToDualArray[K, V any](s Dual[K, V]) (keys []K, values []V, err error)
- func ToKVArray(s KV) ([][]byte, [][]byte, error)
- func ToU64Arr(s U64) ([]uint64, error)
- type ArrStream
- type Closer
- type Dual
- type EmptyDual
- type EmptyUnary
- type FilterDualIter
- type FilterUnaryIter
- type IntersectIter
- type KV
- type NextPageDual
- type NextPageUnary
- type Paginated
- type PaginatedDual
- type PairsWithErrorIter
- type RangeIter
- type TransformDualIter
- type TransformKV2U64Iter
- type U64
- type Unary
- type UnionKVIter
- type UnionUnary
Constants ¶
This section is empty.
Variables ¶
var ( EmptyU64 = &EmptyUnary[uint64]{} EmptyKV = &EmptyDual[[]byte, []byte]{} )
Functions ¶
func ExpectEqual ¶
func ExpectEqual[V comparable](tb testing.TB, s1, s2 Unary[V])
func ToArrKVMust ¶
func ToArrU64Must ¶
func ToDualArray ¶
Types ¶
type ArrStream ¶
type ArrStream[V any] struct { // contains filtered or unexported fields }
func ReverseArray ¶
type Dual ¶
Dual - return 2 items - usually called Key and Value (or `k` and `v`) Example:
for s.HasNext() { k, v, err := s.Next() if err != nil { return err } }
type EmptyUnary ¶
type EmptyUnary[T any] struct{}
func (EmptyUnary[T]) HasNext ¶
func (EmptyUnary[T]) HasNext() bool
func (EmptyUnary[T]) Next ¶
func (EmptyUnary[T]) Next() (v T, err error)
type FilterDualIter ¶
type FilterDualIter[K, V any] struct { // contains filtered or unexported fields }
FilterDualIter - analog `map` (in terms of map-filter-reduce pattern) please avoid reading from Disk/DB more elements and then filter them. Better push-down filter conditions to lower-level iterator to reduce disk reads amount.
func FilterDual ¶
func FilterDual[K, V any](it Dual[K, V], filter func(K, V) bool) *FilterDualIter[K, V]
func (*FilterDualIter[K, v]) Close ¶
func (m *FilterDualIter[K, v]) Close()
func (*FilterDualIter[K, V]) HasNext ¶
func (m *FilterDualIter[K, V]) HasNext() bool
func (*FilterDualIter[K, V]) Next ¶
func (m *FilterDualIter[K, V]) Next() (k K, v V, err error)
type FilterUnaryIter ¶
type FilterUnaryIter[T any] struct { // contains filtered or unexported fields }
FilterUnaryIter - analog `map` (in terms of map-filter-reduce pattern) please avoid reading from Disk/DB more elements and then filter them. Better push-down filter conditions to lower-level iterator to reduce disk reads amount.
func FilterUnary ¶
func FilterUnary[T any](it Unary[T], filter func(T) bool) *FilterUnaryIter[T]
func (*FilterUnaryIter[T]) Close ¶
func (m *FilterUnaryIter[T]) Close()
func (*FilterUnaryIter[T]) HasNext ¶
func (m *FilterUnaryIter[T]) HasNext() bool
func (*FilterUnaryIter[T]) Next ¶
func (m *FilterUnaryIter[T]) Next() (k T, err error)
type IntersectIter ¶
type IntersectIter[T constraints.Ordered] struct { // contains filtered or unexported fields }
IntersectIter
func (*IntersectIter[T]) Close ¶
func (m *IntersectIter[T]) Close()
func (*IntersectIter[T]) HasNext ¶
func (m *IntersectIter[T]) HasNext() bool
func (*IntersectIter[T]) Next ¶
func (m *IntersectIter[T]) Next() (T, error)
type NextPageDual ¶
type NextPageDual[K, V any] func(pageToken string) (keys []K, values []V, nextPageToken string, err error)
internal types
type NextPageUnary ¶
internal types
type Paginated ¶
type Paginated[T any] struct { // contains filtered or unexported fields }
PaginatedIter - for remote-list pagination
Rationale: If an API does not support pagination from the start, supporting it later is troublesome because adding pagination breaks the API's behavior. Clients that are unaware that the API now uses pagination could incorrectly assume that they received a complete result, when in fact they only received the first page.
To support pagination (returning list results in pages) in a List method, the API shall:
- The client uses this field to request a specific page of the list results.
- define an int32 field page_size in the List method's request message. Clients use this field to specify the maximum number of results to be returned by the server. The server may further constrain the maximum number of results returned in a single page. If the page_size is 0, the server will decide the number of results to be returned.
- define a string field next_page_token in the List method's response message. This field represents the pagination token to retrieve the next page of results. If the value is "", it means no further results for the request.
see: https://cloud.google.com/apis/design/design_patterns
func Paginate ¶
func Paginate[T any](f NextPageUnary[T]) *Paginated[T]
func PaginateU64 ¶
func PaginateU64(f NextPageUnary[uint64]) *Paginated[uint64]
type PaginatedDual ¶
type PaginatedDual[K, V any] struct { // contains filtered or unexported fields }
func PaginateDual ¶
func PaginateDual[K, V any](f NextPageDual[K, V]) *PaginatedDual[K, V]
func PaginateKV ¶
func PaginateKV(f NextPageDual[[]byte, []byte]) *PaginatedDual[[]byte, []byte]
func (*PaginatedDual[K, V]) Close ¶
func (it *PaginatedDual[K, V]) Close()
func (*PaginatedDual[K, V]) HasNext ¶
func (it *PaginatedDual[K, V]) HasNext() bool
func (*PaginatedDual[K, V]) Next ¶
func (it *PaginatedDual[K, V]) Next() (k K, v V, err error)
type PairsWithErrorIter ¶
type PairsWithErrorIter struct {
// contains filtered or unexported fields
}
PairsWithErrorIter - return N, keys and then error
func PairsWithError ¶
func PairsWithError(errorAt int) *PairsWithErrorIter
func (*PairsWithErrorIter) HasNext ¶
func (m *PairsWithErrorIter) HasNext() bool
type RangeIter ¶
type RangeIter[T constraints.Integer] struct { // contains filtered or unexported fields }
func Range ¶
func Range[T constraints.Integer](from, to T) *RangeIter[T]
type TransformDualIter ¶
type TransformDualIter[K, V any] struct { // contains filtered or unexported fields }
TransformDualIter - analog `map` (in terms of map-filter-reduce pattern)
func TransformDual ¶
func TransformDual[K, V any](it Dual[K, V], transform func(K, V) (K, V, error)) *TransformDualIter[K, V]
func TransformKV ¶
func (*TransformDualIter[K, v]) Close ¶
func (m *TransformDualIter[K, v]) Close()
func (*TransformDualIter[K, V]) HasNext ¶
func (m *TransformDualIter[K, V]) HasNext() bool
func (*TransformDualIter[K, V]) Next ¶
func (m *TransformDualIter[K, V]) Next() (K, V, error)
type TransformKV2U64Iter ¶
type TransformKV2U64Iter[K, V []byte] struct { // contains filtered or unexported fields }
func TransformKV2U64 ¶
func TransformKV2U64[K, V []byte](it KV, transform func(K, V) (uint64, error)) *TransformKV2U64Iter[K, V]
func (*TransformKV2U64Iter[K, v]) Close ¶
func (m *TransformKV2U64Iter[K, v]) Close()
func (*TransformKV2U64Iter[K, V]) HasNext ¶
func (m *TransformKV2U64Iter[K, V]) HasNext() bool
func (*TransformKV2U64Iter[K, V]) Next ¶
func (m *TransformKV2U64Iter[K, V]) Next() (uint64, error)
type Unary ¶
Unary - return 1 item. Example:
for s.HasNext() { v, err := s.Next() if err != nil { return err } }
type UnionKVIter ¶
type UnionKVIter struct {
// contains filtered or unexported fields
}
UnionKVIter - merge 2 kv.Pairs streams to 1 in lexicographically order 1-st stream has higher priority - when 2 streams return same key
func (*UnionKVIter) Close ¶
func (m *UnionKVIter) Close()
func (m *UnionKVIter) ToArray() (keys, values [][]byte, err error) { return ToKVArray(m) }
func (*UnionKVIter) HasNext ¶
func (m *UnionKVIter) HasNext() bool
type UnionUnary ¶
type UnionUnary[T constraints.Ordered] struct { // contains filtered or unexported fields }
UnionUnary
func (*UnionUnary[T]) Close ¶
func (m *UnionUnary[T]) Close()
func (*UnionUnary[T]) HasNext ¶
func (m *UnionUnary[T]) HasNext() bool
func (*UnionUnary[T]) Next ¶
func (m *UnionUnary[T]) Next() (res T, err error)