record

package
v0.0.0-...-49e5460 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProjectionFields

func ProjectionFields(fields []string) [][]string

func Sort

func Sort(sortKeys []string, reverseList []bool, data []Record)

sort the given data by the given keys

Types

type Record

type Record map[string]interface{}

func (Record) Flatten

func (r Record) Flatten() map[string]interface{}

Flatten a record into 1-level map[string]interface{}

func (Record) Get

func (r Record) Get(nameParts []string) (interface{}, bool)

Get the value addressed by `nameParts`

func (Record) Pop

func (r Record) Pop(nameParts []string) (interface{}, bool)

Pop will pop an item at `nameParts` and return the value and a boolean on whether it was successful (similar to map accessing)

func (Record) Project

func (r Record) Project(projectionFields [][]string) Record

func (Record) Remove

func (r Record) Remove(nameParts []string) bool

Remove deletes the value at `nameParts` bool returns whether it is deleted

func (Record) Set

func (r Record) Set(nameParts []string, newValue interface{}) bool

Set will set a the value at `nameParts` to `newValue` and return a bool on whether it was successful

type RecordHeap

type RecordHeap struct {
	Heap []RecordItem
	// contains filtered or unexported fields
}

RecordHeap is a heap for use in sorting Record objects Records need "special" sorting as we potentially have many fields to sort by, so we effectively need to sort by each key until one has a comparison that sorts -- otherwise we continue down the list of sortKeys until we find one or we hit the end. In addition to the sort we also need to support "reverse" but we need the heap to still work with pop/push. To make this work we just have a reverseList option per sortKey, and the underlying sort list will negate the Less() return if "reverse" is true

func NewRecordHeap

func NewRecordHeap(splitSortKeys [][]string, reverseList []bool) *RecordHeap

func (RecordHeap) Len

func (r RecordHeap) Len() int

func (RecordHeap) Less

func (r RecordHeap) Less(i, j int) (l bool)

func (*RecordHeap) Pop

func (r *RecordHeap) Pop() interface{}

func (*RecordHeap) PopDirect

func (r *RecordHeap) PopDirect() RecordItem

func (*RecordHeap) Push

func (r *RecordHeap) Push(x interface{})

func (*RecordHeap) PushDirect

func (r *RecordHeap) PushDirect(x RecordItem)

func (RecordHeap) Swap

func (r RecordHeap) Swap(i, j int)

type RecordItem

type RecordItem struct {
	Record Record
	Source int
}

Jump to

Keyboard shortcuts

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