Documentation
¶
Index ¶
- Constants
- Variables
- func Since(tt Timestamp) time.Duration
- type Entry
- func (ent *Entry) DecodeEntry(buff []byte)
- func (ent *Entry) DecodeEntryAlt(buff []byte)
- func (ent *Entry) DecodeHeader(buff []byte) (int, error)
- func (ent *Entry) DecodeReader(rdr io.Reader) error
- func (ent *Entry) DeepCopy() (c Entry)
- func (ent *Entry) Encode(buff []byte) error
- func (ent *Entry) EncodeHeader(buff []byte) error
- func (ent *Entry) EncodeWriter(wtr io.Writer) error
- func (ent *Entry) Key() EntryKey
- func (ent *Entry) MarshallBytes() ([]byte, error)
- func (ent *Entry) Size() uint64
- type EntryBlock
- func (eb *EntryBlock) Add(e *Entry)
- func (eb *EntryBlock) Count() int
- func (eb *EntryBlock) Decode(b []byte) error
- func (eb EntryBlock) DeepCopy() EntryBlock
- func (eb *EntryBlock) Encode() ([]byte, error)
- func (eb *EntryBlock) EncodeAppend(buff []byte) ([]byte, error)
- func (eb *EntryBlock) EncodeEntries(buff []byte) (int, error)
- func (eb *EntryBlock) EncodeInto(buff []byte) (int, error)
- func (eb EntryBlock) EncodedSize() uint64
- func (eb *EntryBlock) Entries() []*Entry
- func (eb *EntryBlock) Entry(i int) *Entry
- func (eb EntryBlock) EntryKey(i int) (int64, error)
- func (eb EntryBlock) Key() int64
- func (eb EntryBlock) Len() int
- func (eb *EntryBlock) Merge(neb *EntryBlock) error
- func (eb *EntryBlock) Peel(cnt int, sz uint64) (neb EntryBlock)
- func (eb *EntryBlock) SetKey(k EntryKey) error
- func (eb EntryBlock) Size() uint64
- type EntryKey
- type EntrySlice
- type EntryTag
- type Timestamp
- func (t Timestamp) Add(d time.Duration) (tt Timestamp)
- func (t Timestamp) After(tt Timestamp) bool
- func (t Timestamp) Before(tt Timestamp) bool
- func (t *Timestamp) Decode(buff []byte)
- func (t Timestamp) Encode(buff []byte)
- func (t Timestamp) Equal(tt Timestamp) bool
- func (t Timestamp) Format(layout string) string
- func (t Timestamp) IsZero() bool
- func (t Timestamp) MarshalBinary() ([]byte, error)
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t Timestamp) MarshalText() ([]byte, error)
- func (t Timestamp) StandardTime() time.Time
- func (t Timestamp) String() string
- func (t Timestamp) Sub(tt Timestamp) time.Duration
- func (t *Timestamp) UnmarshalBinary(data []byte) error
- func (t *Timestamp) UnmarshalJSON(data []byte) error
- func (t *Timestamp) UnmarshalText(data []byte) error
Constants ¶
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 )
const (
EntryBlockHeaderSize = 4 + 4 + 8
)
const (
TS_SIZE int = 12
)
Variables ¶
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") )
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") )
var (
ErrTSDataSizeInvalid = errors.New("byte slice size invalid")
)
Functions ¶
Types ¶
type Entry ¶
func (*Entry) DecodeEntry ¶
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 ¶
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) DeepCopy ¶
DeepCopy provides a complete copy of an entry, this is REALLY expensive, so make sure its worth it
func (*Entry) EncodeHeader ¶
EncodeHeader Encodes the header into the buffer for the file transport think file indexer
func (*Entry) MarshallBytes ¶
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 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 Timestamp ¶
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 ¶
FromStandard converts the time.Time datatype to our Timestamp format
func (Timestamp) Add ¶
Add subtracts Timestamp tt from Timestamp t and returns the golang time.Duration datatype which is essentially a nanosecond count
func (*Timestamp) Decode ¶
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 ¶
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) Format ¶
Format prints the Timestamp in text using the same layout format as time.Time
func (Timestamp) MarshalBinary ¶
MarshalBinary marshals the timestamp into an 12 byte byte slice
func (Timestamp) MarshalJSON ¶
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 ¶
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 ¶
StandardTime converts our Timestamp format to the golang time.Time datatype
func (Timestamp) Sub ¶
Sub subtracts Timestamp tt from Timestamp t and returns the golang time.Duration datatype which is essentially a nanosecond count
func (*Timestamp) UnmarshalBinary ¶
UnmarshalBinary unmarshals a 12 byte encoding of a Timestamp This type is NOT compatible with the time.Time format
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON unmarshals the timestamp JSON into the Timestamp format This format is compatible with the time.Time format
func (*Timestamp) UnmarshalText ¶
UnmarshalText unmarshals the Timestamp from a byte array the format is compatible with the golang time.Time Text format