mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
missing comments
This commit is contained in:
parent
3512dd4549
commit
35c1648c75
3 changed files with 25 additions and 17 deletions
|
|
@ -22,18 +22,22 @@ type StaticNodeSet struct {
|
|||
nodes []*Node
|
||||
}
|
||||
|
||||
// NewStaticNodeSet creates a static nodeset
|
||||
func NewStaticNodeSet() *StaticNodeSet {
|
||||
return &StaticNodeSet{}
|
||||
}
|
||||
|
||||
// Nodes implements the NodeSet interface and returns a list of nodes in the cluster
|
||||
func (s *StaticNodeSet) Nodes() []*Node {
|
||||
return s.nodes
|
||||
}
|
||||
|
||||
// Open implements the NodeSet interface to start network activity, but is a nop
|
||||
func (s *StaticNodeSet) Open() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Join add nodes from the cluster to the NodeSet
|
||||
func (s *StaticNodeSet) Join(nodes []*Node) error {
|
||||
s.nodes = nodes
|
||||
return nil
|
||||
|
|
@ -49,9 +53,9 @@ func init() {
|
|||
NopBroadcaster = &nopBroadcaster{}
|
||||
}
|
||||
|
||||
// NopBroadcaster represents a Broadcaster that doesn't do anything.
|
||||
var NopBroadcaster Broadcaster
|
||||
|
||||
// nopBroadcaster represents a Broadcaster that doesn't do anything.
|
||||
type nopBroadcaster struct{}
|
||||
|
||||
// SendSync A no-op implemenetation of Broadcaster SendSync method.
|
||||
|
|
@ -85,6 +89,7 @@ type nopBroadcastReceiver struct{}
|
|||
|
||||
func (n *nopBroadcastReceiver) Start(b BroadcastHandler) error { return nil }
|
||||
|
||||
// NopBroadcastReceiver is a no op implementation of the BroadcastReceiver
|
||||
var NopBroadcastReceiver = &nopBroadcastReceiver{}
|
||||
|
||||
const (
|
||||
|
|
@ -95,6 +100,7 @@ const (
|
|||
MessageTypeDeleteFrame = 5
|
||||
)
|
||||
|
||||
// MarshalMessage encodes the protobuf message into a byte slice
|
||||
func MarshalMessage(m proto.Message) ([]byte, error) {
|
||||
var typ uint8
|
||||
switch obj := m.(type) {
|
||||
|
|
@ -118,6 +124,7 @@ func MarshalMessage(m proto.Message) ([]byte, error) {
|
|||
return append([]byte{typ}, buf...), nil
|
||||
}
|
||||
|
||||
// UnmarshalMessage decodes the byte slice into a protobuf message
|
||||
func UnmarshalMessage(buf []byte) (proto.Message, error) {
|
||||
typ, buf := buf[0], buf[1:]
|
||||
|
||||
|
|
|
|||
29
client.go
29
client.go
|
|
@ -315,6 +315,7 @@ func (c *Client) Import(ctx context.Context, index, frame string, slice uint64,
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalImportPayload marshalls the import parameters into a protobuf byte slice
|
||||
func MarshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte, error) {
|
||||
// Separate row and column IDs to reduce allocations.
|
||||
rowIDs := Bits(bits).RowIDs()
|
||||
|
|
@ -982,36 +983,36 @@ func (p Bits) Less(i, j int) bool {
|
|||
}
|
||||
|
||||
// RowIDs returns a slice of all the row IDs.
|
||||
func (a Bits) RowIDs() []uint64 {
|
||||
other := make([]uint64, len(a))
|
||||
for i := range a {
|
||||
other[i] = a[i].RowID
|
||||
func (p Bits) RowIDs() []uint64 {
|
||||
other := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
other[i] = p[i].RowID
|
||||
}
|
||||
return other
|
||||
}
|
||||
|
||||
// ColumnIDs returns a slice of all the column IDs.
|
||||
func (a Bits) ColumnIDs() []uint64 {
|
||||
other := make([]uint64, len(a))
|
||||
for i := range a {
|
||||
other[i] = a[i].ColumnID
|
||||
func (p Bits) ColumnIDs() []uint64 {
|
||||
other := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
other[i] = p[i].ColumnID
|
||||
}
|
||||
return other
|
||||
}
|
||||
|
||||
// Timestamps returns a slice of all the timestamps.
|
||||
func (a Bits) Timestamps() []int64 {
|
||||
other := make([]int64, len(a))
|
||||
for i := range a {
|
||||
other[i] = a[i].Timestamp
|
||||
func (p Bits) Timestamps() []int64 {
|
||||
other := make([]int64, len(p))
|
||||
for i := range p {
|
||||
other[i] = p[i].Timestamp
|
||||
}
|
||||
return other
|
||||
}
|
||||
|
||||
// GroupBySlice returns a map of bits by slice.
|
||||
func (a Bits) GroupBySlice() map[uint64][]Bit {
|
||||
func (p Bits) GroupBySlice() map[uint64][]Bit {
|
||||
m := make(map[uint64][]Bit)
|
||||
for _, bit := range a {
|
||||
for _, bit := range p {
|
||||
slice := bit.ColumnID / SliceWidth
|
||||
m[slice] = append(m[slice], bit)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -801,7 +801,7 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql.
|
|||
if err != nil {
|
||||
return fmt.Errorf("reading SetRowAttrs() row: %v", err)
|
||||
} else if !ok {
|
||||
return fmt.Errorf("SetRowAttrs() row field '%v' required.", rowLabel)
|
||||
return fmt.Errorf("SetRowAttrs() row field '%v' required", rowLabel)
|
||||
}
|
||||
|
||||
// Copy args and remove reserved fields.
|
||||
|
|
@ -860,7 +860,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("reading SetRowAttrs() row: %v", rowLabel)
|
||||
} else if !ok {
|
||||
return nil, fmt.Errorf("SetRowAttrs row field '%v' required.", rowLabel)
|
||||
return nil, fmt.Errorf("SetRowAttrs row field '%v' required", rowLabel)
|
||||
}
|
||||
|
||||
// Copy args and remove reserved fields.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue