Documentation ¶
Index ¶
- Constants
- Variables
- func Check(inFiles ...string) map[string]error
- func FileInfo(inFile string) (offsetsBySource common.OffsetsBySource, fieldsString string, ...)
- func MetaDataFor(source core.FlatRowSource, fields core.Fields) *common.QueryMetaData
- type DB
- func (db *DB) AllTableStats() map[string]TableStats
- func (db *DB) ApplySchema(_schema Schema) error
- func (db *DB) ApplySchemaFromFile(filename string) error
- func (db *DB) CheckTable(table string, filename string) error
- func (db *DB) Close()
- func (db *DB) CreateTable(opts *TableOpts) error
- func (db *DB) FilterAndMerge(table string, whereClause string, shouldSort bool, outFile string, ...) error
- func (db *DB) FlushAll()
- func (db *DB) Follow(f *common.Follow, cb func([]byte, wal.Offset) error)
- func (db *DB) Go(task func(stop <-chan interface{}))
- func (db *DB) Insert(stream string, ts time.Time, dims map[string]interface{}, ...) error
- func (db *DB) InsertRaw(stream string, ts time.Time, dims bytemap.ByteMap, vals bytemap.ByteMap) error
- func (db *DB) PrintTableStats(table string) string
- func (db *DB) Query(sqlString string, isSubQuery bool, subQueryResults [][]interface{}, ...) (core.FlatRowSource, error)
- func (db *DB) RegisterQueryHandler(partition int, query planner.QueryClusterFN)
- func (db *DB) TableStats(table string) TableStats
- type DBOpts
- type Schema
- type TableOpts
- type TableStats
Constants ¶
const ( // File format versions FileVersion_4 = 4 FileVersion_5 = 5 CurrentFileVersion = FileVersion_5 )
const ( DefaultIterationCoalesceInterval = 3 * time.Second DefaultIterationConcurrency = 2 DefaultClusterQueryTimeout = 1 * time.Hour DefaultMaxFollowQueue = 100000 )
Variables ¶
var (
ErrMissingQueryHandler = errors.New("Missing query handler for partition")
)
var (
ErrOutOfMemory = errors.New("out of memory")
)
Functions ¶
func Check ¶
Check checks all of the given inFiles for readability and returns errors for all files that are in error.
func FileInfo ¶
func FileInfo(inFile string) (offsetsBySource common.OffsetsBySource, fieldsString string, fields core.Fields, err error)
FileInfo returns information about the given data file
func MetaDataFor ¶
func MetaDataFor(source core.FlatRowSource, fields core.Fields) *common.QueryMetaData
Types ¶
type DB ¶
type DB struct { Panic func(interface{}) // contains filtered or unexported fields }
DB is a zenodb database.
func (*DB) AllTableStats ¶
func (db *DB) AllTableStats() map[string]TableStats
AllTableStats returns all TableStats for all tables, keyed to the table names.
func (*DB) ApplySchema ¶
func (*DB) ApplySchemaFromFile ¶
func (*DB) CheckTable ¶
CheckTable checks the given data file for the given table to make sure it's readable
func (*DB) Close ¶
func (db *DB) Close()
Close closes the database, waiting for all background tasks to complete.
func (*DB) CreateTable ¶
CreateTable creates a table based on the given opts.
func (*DB) FilterAndMerge ¶
func (db *DB) FilterAndMerge(table string, whereClause string, shouldSort bool, outFile string, inFiles ...string) error
FilterAndMerge merges the specified inFiles into the given outFile, where inFiles and outFiles are all valid filestore files. The schema is based on the named table. If whereClause is specified, rows are filtered by comparing them to the whereClause. The merge is performed as a disk-based merge in order to use minimal memory. If shouldSort is true, the output will be sorted by key.
func (*DB) Go ¶
func (db *DB) Go(task func(stop <-chan interface{}))
Go starts a goroutine with a task. The task should look for the stop channel to close, at which point it should terminate as quickly as possible. When db.Close() is called, it will close the stop channel and wait for all running tasks to complete.
func (*DB) PrintTableStats ¶
PrintTableStats prints the stats for the named table to a string.
func (*DB) RegisterQueryHandler ¶
func (db *DB) RegisterQueryHandler(partition int, query planner.QueryClusterFN)
func (*DB) TableStats ¶
func (db *DB) TableStats(table string) TableStats
TableStats returns the TableStats for the named table.
type DBOpts ¶
type DBOpts struct { // ReadOnly puts the database into a mode whereby it does not persist anything // to disk. This is useful for embedding the database in tools like zenomerge. ReadOnly bool // Dir points at the directory that contains the data files. Dir string // SchemaFile points at a YAML schema file that configures the tables and // views in the database. SchemaFile string // AliasesFile points at a file that contains expression aliases in the form // name=template(%v, %v), with one alias per line. AliasesFile string // EnableGeo enables geolocation functions EnableGeo bool // ISPProvider configures a provider of ISP lookups. Specify this to allow the // use of ISP functions. ISPProvider isp.Provider // IPCacheSize determines the size of the ip cache for geo and ISP lookups IPCacheSize int // RedisClient provides a connection to redis which enables the use of Redis // expressions like HGET. RedisClient *redis.Client // RedisCacheSize controls the size of redis hash caches RedisCacheSize int // VirtualTime, if true, tells zenodb to use a virtual clock that advances // based on the timestamps of Points received via inserts. VirtualTime bool // WALSyncInterval governs how frequently to sync the WAL to disk. 0 means // it syncs after every write (which is not great for performance). WALSyncInterval time.Duration // MaxWALMemoryBacklog sets the maximum number of writes to buffer in memory. MaxWALMemoryBacklog int // MaxWALSize limits how much WAL data to keep (in bytes) MaxWALSize int // WALCompressionSize specifies the size beyond which to compress WAL segments WALCompressionSize int // MaxMemoryRatio caps the maximum memory of this process. When the system // comes under memory pressure, it will start flushing table memstores. MaxMemoryRatio float64 // IterationCoalesceInterval specifies how long we wait between iteration // requests in order to coalesce multiple related ones. IterationCoalesceInterval time.Duration // IterationConcurrency specifies how many iterations can be performed in // parallel IterationConcurrency int // MaxBackupWait limits how long we're willing to wait for a backup before // resuming file operations MaxBackupWait time.Duration // Passthrough flags this node as a passthrough (won't store data in tables, // just WAL). Passthrough nodes will also outsource queries to specific // partition handlers. Requires that NumPartitions be specified. Passthrough bool // ID uniquely identifies a leader in the cluster or a follower for a given partition ID int // NumPartitions identifies how many partitions to split data from // passthrough nodes. NumPartitions int // Partition identies the partition owned by this follower Partition int // ClusterQueryConcurrency specifies the maximum concurrency for clustered // query handlers. ClusterQueryConcurrency int // ClusterQueryTimeout specifies the maximum amount of time leader will wait // for followers to answer a query ClusterQueryTimeout time.Duration // MaxFollowAge limits how far back to go when follower pulls data from // leader MaxFollowAge time.Duration // MaxFollowQueue limits how many rows to queue for any single follower (defaults to 100,000) MaxFollowQueue int // Follow is a function that allows a follower to request following a stream // from one or more sources (passthrough nodes). Follow func(f func(sources []int) map[int]*common.Follow, cb func(data []byte, newOffset wal.Offset, source int) error) RegisterRemoteQueryHandler func(db *DB, partition int, query planner.QueryClusterFN) // Panic is an optional function for triggering panics Panic func(interface{}) // WhitelistedDimensions allow specifying an optional whitelist of dimensions to include in the WAL. // If specified, only dimensions appearing in the whiteliste will be recorded in the WAL. WhitelistedDimensions map[string]bool }
DBOpts provides options for configuring the database.
func (*DBOpts) BuildLogger ¶
BuildLogger builds a logger for the database configured with these DBOpts
type TableOpts ¶
type TableOpts struct { // Name is the name of the table. Name string // View indicates if this table is a view on top of an existing table. View bool // MinFlushLatency sets a lower bound on how frequently the memstore is // flushed to disk. MinFlushLatency time.Duration // MaxFlushLatency sets an upper bound on how long to wait before flushing the // memstore to disk. MaxFlushLatency time.Duration // RetentionPeriod limits how long data is kept in the table (based on the // timestamp of the data itself). RetentionPeriod time.Duration // Backfill limits how far back to grab data from the WAL when first creating // a table. If 0, backfill is limited only by the RetentionPeriod. Backfill time.Duration // PartitionBy can be used in clustered deployments to decide which // dimensions to use in partitioning data. If unspecified, all dimensions are // used for partitioning. PartitionBy []string // SQL is the SELECT query that determines the fields, filtering and input // source for this table. SQL string // Virtual, if true, means that the table's data isn't actually stored or // queryable. Virtual tables are useful for defining a base set of fields // from which other tables can select. Virtual bool // contains filtered or unexported fields }
TableOpts configures a table.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bytetree provides a Radix tree that stores []byte keys and values.
|
Package bytetree provides a Radix tree that stores []byte keys and values. |
zeno
zeno is the executable for the ZenoDB database, and can run as a standalone server, as a cluster leader or as a cluster follower.
|
zeno is the executable for the ZenoDB database, and can run as a standalone server, as a cluster leader or as a cluster follower. |
zenotool
zenotool provides the ability to filter and merge zeno datafiles offline.
|
zenotool provides the ability to filter and merge zeno datafiles offline. |
Package encoding handles encoding of zenodb data in binary form.
|
Package encoding handles encoding of zenodb data in binary form. |
Package expr provides a framework for Expressions that evaluate to floating point values and allow various functions that can aggregate data, perform calculations on that data, evaluate boolean expressions against that data and serialize the data to/from bytes for durable storage in the database.
|
Package expr provides a framework for Expressions that evaluate to floating point values and allow various functions that can aggregate data, perform calculations on that data, evaluate boolean expressions against that data and serialize the data to/from bytes for durable storage in the database. |
Package planner provides functionality for planning the execution of queries.
|
Package planner provides functionality for planning the execution of queries. |
Package sql provides the ability to parse SQL queries.
|
Package sql provides the ability to parse SQL queries. |