entry

package
v3.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: BSD-2-Clause, BSD-2-Clause Imports: 5 Imported by: 30

Documentation

Index

Constants

View Source
const (
	/* 34 = 4 + 8 + 8 + 2 + 16

	 */
	ENTRY_HEADER_SIZE int      = 34
	SRC_SIZE          int      = 16
	IPV4_SRC_SIZE     int      = 4
	DefaultTagName    string   = `default`
	DefaultTagId      EntryTag = 0
	GravwellTagName   string   = `gravwell`
	GravwellTagId     EntryTag = 0xFFFF

	MaxDataSize   uint32 = 0x7FFFFFFF
	MaxSliceCount uint32 = 0x3FFFFFFF
)
View Source
const (
	EntryBlockHeaderSize = 4 + 4 + 8
)
View Source
const (
	TS_SIZE int = 12
)

Variables

View Source
var (
	ErrNilEntry          error = errors.New("Cannot add nil entry")
	ErrInvalidKey        error = errors.New("Entry key does not match block")
	ErrBadKey            error = errors.New("EntryBlock key is invalid")
	ErrKeyAlreadySet     error = errors.New("Entry key for block already set")
	ErrInvalidEntryBlock error = errors.New("EntryBlock is invalid")
	ErrBlockTooLarge     error = errors.New("EntryBlock is too large to encode")
	ErrInvalidDestBuff   error = errors.New("EntryBlock buffer is too small")
	ErrInvalidSrcBuff    error = errors.New("Buffer is invalid for an EntryBlock")
	ErrPartialDecode     error = errors.New("Buffer is short/invalid for EntryBlock decode")
)
View Source
var (
	ErrInvalidHeader     = errors.New("Invalid Entry header in decode")
	ErrInvalidBufferSize = errors.New("Invalid buffer size, too small")
	ErrFailedHeaderWrite = errors.New("Failed to write header while encoding")
	ErrFailedBodyWrite   = errors.New("Failed to write body while encoding")
	ErrFailedBodyRead    = errors.New("Failed to read body while decoding")
	ErrSliceLenTooLarge  = errors.New("Slice length is too large for encoding")
	ErrSliceSizeTooLarge = errors.New("Slice size is too large for encoding")
)
View Source
var (
	ErrTSDataSizeInvalid = errors.New("byte slice size invalid")
)

Functions

func Since

func Since(tt Timestamp) time.Duration

Since returns the time since the Timestamp tt in as the golang datatype time.Duration

Types

type Entry

type Entry struct {
	TS   Timestamp
	SRC  net.IP
	Tag  EntryTag
	Data []byte
}

func (*Entry) DecodeEntry

func (ent *Entry) DecodeEntry(buff []byte)

DecodeEntry will copy values out of the buffer to generate an entry with its own copies of data. This ensures that entries don't maintain ties to blocks DecodeEntry assumes that a size check has already happened

func (*Entry) DecodeEntryAlt

func (ent *Entry) DecodeEntryAlt(buff []byte)

DecodeEntryAlt doesn't copy the SRC or data out, it just references the slice handed in it also assumes a size check for the entry header size has occurred by the caller

func (*Entry) DecodeHeader

func (ent *Entry) DecodeHeader(buff []byte) (int, error)

func (*Entry) DecodeReader

func (ent *Entry) DecodeReader(rdr io.Reader) error

func (*Entry) DeepCopy

func (ent *Entry) DeepCopy() (c Entry)

DeepCopy provides a complete copy of an entry, this is REALLY expensive, so make sure its worth it

func (*Entry) Encode

func (ent *Entry) Encode(buff []byte) error

func (*Entry) EncodeHeader

func (ent *Entry) EncodeHeader(buff []byte) error

EncodeHeader Encodes the header into the buffer for the file transport think file indexer

func (*Entry) EncodeWriter

func (ent *Entry) EncodeWriter(wtr io.Writer) error

func (*Entry) Key

func (ent *Entry) Key() EntryKey

func (*Entry) MarshallBytes

func (ent *Entry) MarshallBytes() ([]byte, error)

func (*Entry) Size

func (ent *Entry) Size() uint64

type EntryBlock

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

standard entry block, primarily used in ingesters

func NewDeepCopyEntryBlock

func NewDeepCopyEntryBlock(set []*Entry, sz uint64) (neb EntryBlock)

NewDeepCopyEntryBlock creates a new EntryBlock with a deep copy on all data in the provided set the sz size parameter is used as a hint for allocation, provide zero if unknown

func NewEntryBlock

func NewEntryBlock(set []*Entry, size uint64) EntryBlock

NewEntryBlock creates a new entry block from the set and size parameters the size is taken at face value and should represent the storage size needed to encode the given set

func NewEntryBlockNP

func NewEntryBlockNP(set []Entry, size uint64) (eb EntryBlock)

NewEntryBlock creates a new entry block from the set and size parameters the size is taken at face value and should represent the storage size needed to encode the given set. The slice of Entry handed in is NOT copied, caller should not modify the slice until the block is done

func (*EntryBlock) Add

func (eb *EntryBlock) Add(e *Entry)

Add adds an entry to the entry block, if no key is currently set, the entries TS is used

func (*EntryBlock) Count

func (eb *EntryBlock) Count() int

Count returns the number of entries held in the block

func (*EntryBlock) Decode

func (eb *EntryBlock) Decode(b []byte) error

Decode will decode an EntryBlock from a buffer, with error checking

func (EntryBlock) DeepCopy

func (eb EntryBlock) DeepCopy() EntryBlock

Deep copy performs an agressive deep copy of the entire block, all entries, and any underlying buffers this is useful when you are pulling entries out of a RO memory reagion and want to ensure your block is entirely orthogonal to the backing memory region. WARNING: this will hammer the memory allocator, only use when you know what you are doing

func (*EntryBlock) Encode

func (eb *EntryBlock) Encode() ([]byte, error)

Encode encodes the EntryBlock to a buffer suitable for transmitting across a network or storing to a file

func (*EntryBlock) EncodeAppend

func (eb *EntryBlock) EncodeAppend(buff []byte) ([]byte, error)

EncodeAppend takes the current buffer, and appends addional entries to the buffer we also update the header

func (*EntryBlock) EncodeEntries

func (eb *EntryBlock) EncodeEntries(buff []byte) (int, error)

EncodeEntries encodes just the set of entries into the provided buffer

func (*EntryBlock) EncodeInto

func (eb *EntryBlock) EncodeInto(buff []byte) (int, error)

EncodeInto encodes the entry block into the given buffer. The buffer MUST be large enough to hold the entire block, an encoded size and nil is returned on success 0 and an error is returned if the buffer is too small the size checks are performed on the actual entries as well as the block size

func (EntryBlock) EncodedSize

func (eb EntryBlock) EncodedSize() uint64

EncodedSize returns the size of an entry block as would be encoded to disk without compression

func (*EntryBlock) Entries

func (eb *EntryBlock) Entries() []*Entry

Entries returns the underlying entry slice

func (*EntryBlock) Entry

func (eb *EntryBlock) Entry(i int) *Entry

Entry returns the ith entry from the block. If i is an invalid index nil is returned

func (EntryBlock) EntryKey

func (eb EntryBlock) EntryKey(i int) (int64, error)

EntryKey returns the key associated with an entry in the block and an error if the entry doesn't exist

func (EntryBlock) Key

func (eb EntryBlock) Key() int64

Key returns the timestamp associated with the block, There is no garuntee that all entries are part of this key, if the construction of the block didn't adhere to grouping the key means little The key is basically a hint

func (EntryBlock) Len

func (eb EntryBlock) Len() int

Len returns the number of entries allocated, there is no garuntee the entries are all non-nil

func (*EntryBlock) Merge

func (eb *EntryBlock) Merge(neb *EntryBlock) error

Merge merges a provided entry block into the given entry block, the keys for the two blocks must match

func (*EntryBlock) Peel

func (eb *EntryBlock) Peel(cnt int, sz uint64) (neb EntryBlock)

Peel splits off a set of entries from the EntryBlock, returning a new EntryBlock and updating the state of the current EntryBlock, the count and size are used as barrier we peel until we hit either the count or the size

func (*EntryBlock) SetKey

func (eb *EntryBlock) SetKey(k EntryKey) error

SetKey manually sets the key of a block, this is not an override, if the key is already set an error is returned

func (EntryBlock) Size

func (eb EntryBlock) Size() uint64

Size returns the size of the entry block (without encoding header)

type EntryKey

type EntryKey int64

type EntrySlice

type EntrySlice []Entry

func (*EntrySlice) DecodeReader

func (es *EntrySlice) DecodeReader(rdr io.Reader) error

func (EntrySlice) EncodeWriter

func (es EntrySlice) EncodeWriter(wtr io.Writer) error

func (*EntrySlice) Size

func (es *EntrySlice) Size() uint64

type EntryTag

type EntryTag uint16

type Timestamp

type Timestamp struct {
	Sec  int64
	Nsec int64
}

Timestamp is the base timestamp structure all timestamps are assumed to be UTC Sec is the second count since 0000-00-00 00:00:00 UTC Nsec is the nanosecond offset from Sec

func FromStandard

func FromStandard(ts time.Time) Timestamp

FromStandard converts the time.Time datatype to our Timestamp format

func Now

func Now() Timestamp

Now retrieves the current UTC time

func UnixTime

func UnixTime(s, ns int64) Timestamp

func (Timestamp) Add

func (t Timestamp) Add(d time.Duration) (tt Timestamp)

Add subtracts Timestamp tt from Timestamp t and returns the golang time.Duration datatype which is essentially a nanosecond count

func (Timestamp) After

func (t Timestamp) After(tt Timestamp) bool

After returns whether time instance t is after parameter time tt

func (Timestamp) Before

func (t Timestamp) Before(tt Timestamp) bool

Before returns whether time instance t is before the parameter time tt

func (*Timestamp) Decode

func (t *Timestamp) Decode(buff []byte)

Decode reads the timestamp from a buffer, it is designed to be fast and inlined it DOES NOT check the buffer size, so the caller better

func (Timestamp) Encode

func (t Timestamp) Encode(buff []byte)

Encode writes the timestamp to a buffer, it is designed to be fast and inlined, it DOES NOT check the buffer size, so the caller better

func (Timestamp) Equal

func (t Timestamp) Equal(tt Timestamp) bool

Equal returns whether time instance t is identical to parameter time tt

func (Timestamp) Format

func (t Timestamp) Format(layout string) string

Format prints the Timestamp in text using the same layout format as time.Time

func (Timestamp) IsZero

func (t Timestamp) IsZero() bool

IsZero returns whether the second and nanosecond components are both zero

func (Timestamp) MarshalBinary

func (t Timestamp) MarshalBinary() ([]byte, error)

MarshalBinary marshals the timestamp into an 12 byte byte slice

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the timestamp into the golang time.Time JSON format this is a total hack, and we will write our own marshallers soon

func (Timestamp) MarshalText

func (t Timestamp) MarshalText() ([]byte, error)

MarshalText marshals the timestamp into the golang time.Time text format this is a total hack, and we will write our own marshallers soon

func (Timestamp) StandardTime

func (t Timestamp) StandardTime() time.Time

StandardTime converts our Timestamp format to the golang time.Time datatype

func (Timestamp) String

func (t Timestamp) String() string

String returns the standard string representation of Timestamp

func (Timestamp) Sub

func (t Timestamp) Sub(tt Timestamp) time.Duration

Sub subtracts Timestamp tt from Timestamp t and returns the golang time.Duration datatype which is essentially a nanosecond count

func (*Timestamp) UnmarshalBinary

func (t *Timestamp) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals a 12 byte encoding of a Timestamp This type is NOT compatible with the time.Time format

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the timestamp JSON into the Timestamp format This format is compatible with the time.Time format

func (*Timestamp) UnmarshalText

func (t *Timestamp) UnmarshalText(data []byte) error

UnmarshalText unmarshals the Timestamp from a byte array the format is compatible with the golang time.Time Text format

Jump to

Keyboard shortcuts

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