core

package
v0.22.11 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseTypeBool        = "bool"       //
	BaseTypeDecimal     = "decimal"    //
	BaseTypeID          = "id"         // non-keyed mutex
	BaseTypeIDSet       = "idset"      // non-keyed set
	BaseTypeIDSetQ      = "idsetq"     // non-keyed set timequantum
	BaseTypeInt         = "int"        //
	BaseTypeString      = "string"     // keyed mutex
	BaseTypeStringSet   = "stringset"  // keyed set
	BaseTypeStringSetQ  = "stringsetq" // keyed set timequantum
	BaseTypeTimestamp   = "timestamp"  //
	PrimaryKeyFieldName = FieldName("_id")
)
View Source
const (
	TimeUnitSeconds      = "s"
	TimeUnitMilliseconds = "ms"
	TimeUnitMicroseconds = "µs"
	TimeUnitUSeconds     = "us"
	TimeUnitNanoseconds  = "ns"
)

Constants related to timestamp.

Variables

This section is empty.

Functions

func CheckEpochOutOfRange

func CheckEpochOutOfRange(epoch, min, max time.Time) error

CheckEpochOutOfRange checks if the epoch is after max or before min

func IsValidTimeUnit

func IsValidTimeUnit(unit string) bool

IsValidTimeUnit returns true if unit is valid.

func TimeUnitNanos

func TimeUnitNanos(unit string) int64

TimeUnitNanos returns the number of nanoseconds in unit.

func TimestampToVal

func TimestampToVal(unit string, ts time.Time) int64

TimestampToVal takes a time unit and a time.Time and converts it to an integer value

func ValToTimestamp

func ValToTimestamp(unit string, val int64) (time.Time, error)

ValToTimestamp takes a timeunit and an integer value and converts it to time.Time

Types

type BaseType

type BaseType string

BaseType is a typed string used for field types.

type DistinctTimestamp

type DistinctTimestamp struct {
	Values []string
	Name   string
}

func (DistinctTimestamp) ToRows

func (d DistinctTimestamp) ToRows(callback func(*proto.RowResponse) error) error

ToRows implements the ToRowser interface.

func (DistinctTimestamp) ToTable

func (d DistinctTimestamp) ToTable() (*proto.TableResponse, error)

ToTable implements the ToTabler interface for DistinctTimestamp

func (*DistinctTimestamp) Union

Union returns the union of the values of `d` and `other`

type ExtractedIDColumn

type ExtractedIDColumn struct {
	ColumnID uint64
	Rows     [][]uint64
}

type ExtractedIDMatrix

type ExtractedIDMatrix struct {
	Fields  []string
	Columns []ExtractedIDColumn
}

func (*ExtractedIDMatrix) Append

func (e *ExtractedIDMatrix) Append(m ExtractedIDMatrix)

type ExtractedTable

type ExtractedTable struct {
	Fields  []ExtractedTableField  `json:"fields"`
	Columns []ExtractedTableColumn `json:"columns"`
}

func (ExtractedTable) ToRows

func (t ExtractedTable) ToRows(callback func(*proto.RowResponse) error) error

ToRows implements the ToRowser interface.

func (ExtractedTable) ToTable

func (t ExtractedTable) ToTable() (*proto.TableResponse, error)

ToTable converts the table to protobuf format.

type ExtractedTableColumn

type ExtractedTableColumn struct {
	Column KeyOrID       `json:"column"`
	Rows   []interface{} `json:"rows"`
}

type ExtractedTableField

type ExtractedTableField struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type Field

type Field struct {
	Name    FieldName    `json:"name"`
	Type    BaseType     `json:"type"`
	Options FieldOptions `json:"options"`
}

Field represents a field and its configuration.

func (*Field) IsPrimaryKey

func (f *Field) IsPrimaryKey() bool

IsPrimaryKey returns true if the field is the primary key field (of either type ID or STRING).

type FieldName

type FieldName string

FieldName is a typed string used for field names.

type FieldOptions

type FieldOptions struct {
	Min            pql.Decimal         `json:"min,omitempty"`
	Max            pql.Decimal         `json:"max,omitempty"`
	Scale          int64               `json:"scale,omitempty"`
	NoStandardView bool                `json:"no-standard-view,omitempty"` // TODO: we should remove this
	CacheType      string              `json:"cache-type,omitempty"`
	CacheSize      uint32              `json:"cache-size,omitempty"`
	TimeUnit       string              `json:"time-unit,omitempty"`
	Epoch          time.Time           `json:"epoch,omitempty"`
	TimeQuantum    quantum.TimeQuantum `json:"time-quantum,omitempty"`
	TTL            time.Duration       `json:"ttl,omitempty"`
	ForeignIndex   string              `json:"foreign-index,omitempty"`
	TrackExistence bool                `json:"track-existence"`
}

FieldOptions represents options to set when initializing a field.

type FieldRow

type FieldRow struct {
	Field  Field  `json:"field"`
	RowID  uint64 `json:"rowID"`
	RowKey string `json:"rowKey,omitempty"`
	Value  *int64 `json:"value,omitempty"`
}

FieldRow is used to distinguish rows in a group by result.

func (*FieldRow) Clone

func (fr *FieldRow) Clone() (clone *FieldRow)

func (FieldRow) MarshalJSON

func (fr FieldRow) MarshalJSON() ([]byte, error)

MarshalJSON marshals FieldRow to JSON such that either a Key or an ID is included.

func (FieldRow) String

func (fr FieldRow) String() string

String is the FieldRow stringer.

type GroupCount

type GroupCount struct {
	Group      []FieldRow   `json:"group"`
	Count      uint64       `json:"count"`
	Agg        int64        `json:"-"`
	DecimalAgg *pql.Decimal `json:"-"`
}

GroupCount represents a result item for a group by query.

func ApplyConditionToGroupCounts

func ApplyConditionToGroupCounts(gcs []GroupCount, subj string, cond *pql.Condition) []GroupCount

ApplyConditionToGroupCounts filters the contents of gcs according to the condition. Currently, `count` and `sum` are the only fields supported.

func (*GroupCount) Clone

func (g *GroupCount) Clone() (r *GroupCount)

func (GroupCount) Compare

func (g GroupCount) Compare(o GroupCount) int

Compare is used in ordering two GroupCount objects.

type GroupCounts

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

GroupCounts is a list of GroupCount.

func NewGroupCounts

func NewGroupCounts(agg string, groups ...GroupCount) *GroupCounts

NewGroupCounts creates a GroupCounts with the given type and slice of GroupCount objects. There's intentionally no externally-accessible way to change the []GroupCount after creation.

func (*GroupCounts) AggregateColumn

func (g *GroupCounts) AggregateColumn() string

AggregateColumn gives the likely column name to use for aggregates, because for historical reasons we used "sum" when it was a sum, but don't want to use that when it's something else. This will likely get revisited.

func (*GroupCounts) Groups

func (g *GroupCounts) Groups() []GroupCount

Groups is a convenience method to let us not worry as much about the potentially-nil nature of a *GroupCounts.

func (*GroupCounts) MarshalJSON

func (g *GroupCounts) MarshalJSON() ([]byte, error)

MarshalJSON makes GroupCounts satisfy interface json.Marshaler and customizes the JSON output of the aggregate field label.

func (*GroupCounts) ToRows

func (g *GroupCounts) ToRows(callback func(*proto.RowResponse) error) error

ToRows implements the ToRowser interface.

func (*GroupCounts) ToTable

func (g *GroupCounts) ToTable() (*proto.TableResponse, error)

ToTable implements the ToTabler interface.

type KeyOrID

type KeyOrID struct {
	ID    uint64
	Key   string
	Keyed bool
}

func (KeyOrID) MarshalJSON

func (kid KeyOrID) MarshalJSON() ([]byte, error)

type RowIdentifiers

type RowIdentifiers struct {
	Rows  []uint64 `json:"rows"`
	Keys  []string `json:"keys,omitempty"`
	Field string
}

RowIdentifiers is a return type for a list of row ids or row keys. The names `Rows` and `Keys` are meant to follow the same convention as the Row query which returns `Columns` and `Keys`. TODO: Rename this to something better. Anything.

func (*RowIdentifiers) Clone

func (r *RowIdentifiers) Clone() (clone *RowIdentifiers)

func (RowIdentifiers) ToRows

func (r RowIdentifiers) ToRows(callback func(*proto.RowResponse) error) error

ToRows implements the ToRowser interface.

func (RowIdentifiers) ToTable

func (r RowIdentifiers) ToTable() (*proto.TableResponse, error)

ToTable implements the ToTabler interface.

type SignedRow

type SignedRow struct {
	Neg   *rows.Row `json:"neg"`
	Pos   *rows.Row `json:"pos"`
	Field string    `json:"-"`
}

SignedRow represents a signed *Row with two (neg/pos) *Rows.

func (*SignedRow) Clone

func (s *SignedRow) Clone() (r *SignedRow)

func (SignedRow) ToRows

func (s SignedRow) ToRows(callback func(*proto.RowResponse) error) error

ToRows implements the ToRowser interface.

func (SignedRow) ToTable

func (s SignedRow) ToTable() (*proto.TableResponse, error)

ToTable implements the ToTabler interface.

func (*SignedRow) Union

func (sr *SignedRow) Union(other SignedRow) SignedRow

type StringTableKeyer

type StringTableKeyer string

StringTableKeyer is a helper type which can wrap a string, making it a TableKeyer. This is useful for certain calls to Execute() which take a string index name.

func (StringTableKeyer) Key

func (s StringTableKeyer) Key() TableKey

type Table

type Table struct {
	ID         TableID   `json:"id,omitempty"`
	Name       TableName `json:"name,omitempty"`
	Fields     []*Field  `json:"fields"`
	PartitionN int       `json:"partitionN"`

	Description string `json:"description,omitempty"`
	Owner       string `json:"owner,omitempty"`
	UpdatedBy   string `json:"updatedBy,omitempty"`
}

Table represents a table and its configuration.

func (*Table) Field

func (t *Table) Field(name FieldName) (*Field, bool)

Field returns the field with the provided name. If a field with that name does not exist, the returned boolean will be false.

func (*Table) FieldNames

func (t *Table) FieldNames() []FieldName

FieldNames returns the list of field names associated with the table.

func (*Table) HasValidPrimaryKey

func (t *Table) HasValidPrimaryKey() bool

HasValidPrimaryKey returns false if the table does not contain a primary key field (which is required), or if the primary key field is not a valid type.

func (*Table) Key

func (t *Table) Key() TableKey

func (*Table) StringKeys

func (t *Table) StringKeys() bool

StringKeys returns true if the table's primary key is either a string or a concatenation of fields.

type TableID

type TableID string

type TableKey

type TableKey string

TableKey is a globally unique identifier for a table; it is effectively the compound key: (org, database, table). This is (hopefully) the value that will be used when interfacing with services which are unaware of table qualifiers. For example, the FeatureBase server has no notion of organization or database; its top level type is index/indexName/table. So in this case, until and unless we introduce table qualifiers into FeatureBase, we will use TableKey as the value for index.Name.

func (TableKey) Key

func (tk TableKey) Key() TableKey

type TableKeyer

type TableKeyer interface {
	Key() TableKey
}

TableKeyer is an interface implemented by any type which can produce, and be represented by, a TableKey. In the case of a QualifiedTable, its TableKey might be something like `tbl__org__db__tableid`, while a general pilosa implemenation might represent a table as a basic table name `foo`.

type TableName

type TableName string

type ValCount

type ValCount struct {
	Val          int64        `json:"value"`
	FloatVal     float64      `json:"floatValue"`
	DecimalVal   *pql.Decimal `json:"decimalValue"`
	TimestampVal time.Time    `json:"timestampValue"`
	Count        int64        `json:"count"`
}

ValCount represents a grouping of sum & count for Sum() and Average() calls. Also Min, Max....

func (*ValCount) Add

func (vc *ValCount) Add(other ValCount) ValCount

func (*ValCount) Clone

func (v *ValCount) Clone() (r *ValCount)

func (*ValCount) Larger

func (vc *ValCount) Larger(other ValCount) ValCount

larger returns the larger of the two ValCounts.

func (*ValCount) Smaller

func (vc *ValCount) Smaller(other ValCount) ValCount

smaller returns the smaller of the two ValCounts.

func (ValCount) ToRows

func (v ValCount) ToRows(callback func(*proto.RowResponse) error) error

ToRows implements the ToRowser interface.

func (ValCount) ToTable

func (v ValCount) ToTable() (*proto.TableResponse, error)

ToTable implements the ToTabler interface.

Jump to

Keyboard shortcuts

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