Documentation ¶
Index ¶
- Constants
- Variables
- type Column
- func NewColumnEncoded(name string, ctype ColumnType, defval Value) Column
- func NewColumnFloat32(name string, defval float32) Column
- func NewColumnFloat64(name string, defval float64) Column
- func NewColumnInt16(name string, defval int16) Column
- func NewColumnInt32(name string, defval int32) Column
- func NewColumnInt64(name string, defval int64) Column
- func NewColumnInt8(name string, defval int8) Column
- func NewColumnUint16(name string, defval uint16) Column
- func NewColumnUint32(name string, defval uint32) Column
- func NewColumnUint64(name string, defval uint64) Column
- func NewColumnUint8(name string, defval uint8) Column
- func NewColumnUnencoded(name string, ctype ColumnType, defval any) Column
- type ColumnNotFoundError
- type ColumnProjection
- type ColumnType
- type CylindricalEquirectangularIndexer
- type Database
- func (d *Database) Checkpoint() error
- func (d *Database) Create(tableName string, indexer LocationIndexer, columns ...Column) error
- func (d *Database) Drop(tableName string) error
- func (d *Database) GetColumns(tableName string) ([]Column, error)
- func (d *Database) GetMetadata(tableName string, key string) (string, error)
- func (d *Database) GetRows(tableName string, columns []string, locations ...Location) (ResultSet, error)
- func (d *Database) GetTableNames() ([]string, error)
- func (d *Database) SetMetadata(tableName string, key string, value string) error
- func (d *Database) SetRows(tableName string, columns []string, locations []Location, values [][]Value) (int, error)
- func (d *Database) Table(name string) *Table
- type FlatHealpixIndexer
- type GridLocation
- type IndexLocation
- type Location
- type LocationIndexer
- type LocationNotSupportedError
- type LocationOutOfBoundsError
- type MercatorCutoffIndexer
- type NestLocation
- type Page
- type Pagemaster
- func (p *Pagemaster) ClearCache()
- func (p *Pagemaster) FlushAllPages() error
- func (p *Pagemaster) FlushPage(pageIndex int) error
- func (p *Pagemaster) GetChunk(pageIndex int, offset int, size int) ([]byte, error)
- func (p *Pagemaster) GetPage(pageIndex int) ([]byte, error)
- func (p *Pagemaster) Initialize(pages int, page []byte) error
- func (p *Pagemaster) LoadPage(pageIndex int) ([]byte, error)
- func (p *Pagemaster) MaxPagesInCache() int
- func (p *Pagemaster) PageSize() int
- func (p *Pagemaster) PagesInCache() int
- func (p *Pagemaster) SetChunk(pageIndex int, offset int, chunk []byte) error
- func (p *Pagemaster) SetPage(pageIndex int, page []byte) error
- type ProjectedLocation
- type Projection
- type ProjectionlessIndexer
- type RectangularLocation
- type ResultSet
- type RingLocation
- type Row
- type SphericalLocation
- type Store
- func (s *Store) Checkpoint() error
- func (s *Store) DefaultRow() []byte
- func (s *Store) Drop() error
- func (s *Store) FilterColumns(proj Projection) []Column
- func (s *Store) GetRowAt(index int) (Row, error)
- func (s *Store) GetValueAt(index int) (Value, error)
- func (s *Store) Path() string
- func (s *Store) Projection(columns ...string) (Projection, error)
- func (s *Store) RowSize() int
- func (s *Store) RowsPerPage() int
- func (s *Store) SetRowAt(index int, row Row) error
- func (s *Store) SetValueAt(column string, index int, val Value) error
- type Table
- func (t *Table) Checkpoint() error
- func (t *Table) Drop() error
- func (t *Table) GetRows(projectedColumns []string, locations ...Location) (ResultSet, error)
- func (t *Table) Name() string
- func (t *Table) Path() string
- func (t *Table) SetMetadata(key string, value string) error
- func (t *Table) SetRows(columns []string, locations []Location, values [][]Value) (int, error)
- func (t *Table) SetValue(column string, location Location, value Value) error
- func (t *Table) UnmarshalJSON(b []byte) error
- type TableNotFoundError
- type UniqueLocation
- type Value
- func NewFloat32Value(val float32) Value
- func NewFloat64Value(val float64) Value
- func NewInt16Value(val int16) Value
- func NewInt32Value(val int32) Value
- func NewInt64Value(val int64) Value
- func NewInt8Value(val int8) Value
- func NewUint16Value(val uint16) Value
- func NewUint32Value(val uint32) Value
- func NewUint64Value(val uint64) Value
- func NewUint8Value(val uint8) Value
- func (v Value) AsFloat32() float32
- func (v Value) AsFloat64() float64
- func (v Value) AsInt16() int16
- func (v Value) AsInt32() int32
- func (v Value) AsInt64() int64
- func (v Value) AsInt8() int8
- func (v Value) AsUint16() uint16
- func (v Value) AsUint32() uint32
- func (v Value) AsUint64() uint64
- func (v Value) AsUint8() uint8
Constants ¶
const ( DataFileExt = ".dat" MetadataFileExt = ".meta.json" MaxPagesInCache = 64 )
const ( ProjectionKey string = "projection" CreatedAt string = "created-at" )
const ChecksumSize int = 4
4 bytes for int32 checksum in each page
const TableFileExt string = ".tbl.json"
Variables ¶
var (
ErrZeroColumns = errors.New("cannot create a table with zero columns")
)
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct { Name string Type ColumnType Default Value }
The metadata that describes a column of data in the table. Each column has a name used to refer to it in queries. The type describes the range of values able to be stored in the column (and their in-memory size), and the default value will prepopulate the column's slot in every row when the table is created. There are no nullable columns in PixiDB.
func NewColumnEncoded ¶
func NewColumnEncoded(name string, ctype ColumnType, defval Value) Column
Create a new column description with the given name, type, and encoded default value for the type.
func NewColumnFloat32 ¶
Create a new Float32-sized column with the given name and default value.
func NewColumnFloat64 ¶
Create a new Float64-sized column with the given name and default value.
func NewColumnInt16 ¶
Create a new Int16-sized column with the given name and default value.
func NewColumnInt32 ¶
Create a new Int32-sized column with the given name and default value.
func NewColumnInt64 ¶
Create a new Int64-sized column with the given name and default value.
func NewColumnInt8 ¶
Create a new Int8-sized column with the given name and default value.
func NewColumnUint16 ¶
Create a new Uint16-sized column with the given name and default value.
func NewColumnUint32 ¶
Create a new Uint32-sized column with the given name and default value.
func NewColumnUint64 ¶
Create a new Uint64-sized column with the given name and default value.
func NewColumnUint8 ¶
Create a new Uint8-sized column with the given name and default value.
func NewColumnUnencoded ¶
func NewColumnUnencoded(name string, ctype ColumnType, defval any) Column
Create a new column description with the given name and type, and a default Go value that is encoded before being assigned to the column.
func (Column) EncodeValue ¶
Encodes a Go value according to the type of the column. The type of the input Go value should match the specified type of the column.
type ColumnNotFoundError ¶
func NewColumnNotFoundError ¶
func NewColumnNotFoundError(store string, column string) *ColumnNotFoundError
func (ColumnNotFoundError) Error ¶
func (c ColumnNotFoundError) Error() string
type ColumnProjection ¶
type ColumnProjection struct {
// contains filtered or unexported fields
}
type ColumnType ¶
type ColumnType int16
Type representing the PixiDB 'types' of values that can be stored in a field in a table. These types are the 'atomic' types of PixiDB.
const ( ColumnTypeInt8 ColumnType = iota ColumnTypeUint8 ColumnTypeInt16 ColumnTypeUint16 ColumnTypeInt32 ColumnTypeUint32 ColumnTypeInt64 ColumnTypeUint64 ColumnTypeFloat32 ColumnTypeFloat64 )
func (ColumnType) EncodeValue ¶
func (c ColumnType) EncodeValue(val any) Value
Given a standard Go value, encodes it according to the type of the column. The column type must match the type of the Go value.
func (ColumnType) Size ¶
func (c ColumnType) Size() int
The size in bytes of this particular column type.
type CylindricalEquirectangularIndexer ¶
type CylindricalEquirectangularIndexer struct { Parallel float64 `json:"parallel"` Grid ProjectionlessIndexer // contains filtered or unexported fields }
Indexing into a sphere of pixels projected via a cylindrical equirectangular projection. 0,0 is the bottom left corner of the projection space, i.e. (XMin, YMin) => (0, 0). Supports both row-major and column-major order of the grid, which changes how efficient certain consecutive x- or y-accesses are, but does not change where x,y coordinates refer to.
func NewCylindricalEquirectangularIndexer ¶
func NewCylindricalEquirectangularIndexer(parallel float64, width int, height int, rowMajor bool) CylindricalEquirectangularIndexer
Create a new indexer into a grid with the cylindrical equirectangular projection, focused at the given latitude. Many common projections can be created this way.
func (CylindricalEquirectangularIndexer) Name ¶
func (c CylindricalEquirectangularIndexer) Name() string
func (CylindricalEquirectangularIndexer) Projection ¶
func (c CylindricalEquirectangularIndexer) Projection() flatsphere.Projection
func (CylindricalEquirectangularIndexer) Size ¶
func (c CylindricalEquirectangularIndexer) Size() int
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewDatabase ¶
func OpenDatabase ¶
func (*Database) Checkpoint ¶
func (*Database) Create ¶
func (d *Database) Create(tableName string, indexer LocationIndexer, columns ...Column) error
func (*Database) GetMetadata ¶
func (*Database) GetTableNames ¶
func (*Database) SetMetadata ¶
type FlatHealpixIndexer ¶
type FlatHealpixIndexer struct { Scheme healpix.HealpixScheme `json:"scheme"` Order healpix.HealpixOrder `json:"order"` // contains filtered or unexported fields }
Pixelizes a sphere using the HEALPix pixelisation method. This indexer promises a single resolution pixelization, where every pixel has the same angular area. Provides storage options of both ring and nested schemes, for making certain data-access patterns more efficient.
func NewFlatHealpixIndexer ¶
func NewFlatHealpixIndexer(order healpix.HealpixOrder, scheme healpix.HealpixScheme) FlatHealpixIndexer
func (FlatHealpixIndexer) Name ¶
func (h FlatHealpixIndexer) Name() string
func (FlatHealpixIndexer) Projection ¶
func (h FlatHealpixIndexer) Projection() flatsphere.Projection
func (FlatHealpixIndexer) Size ¶
func (h FlatHealpixIndexer) Size() int
type GridLocation ¶
type IndexLocation ¶
type IndexLocation int
type LocationIndexer ¶
type LocationIndexer interface { ToIndex(Location) (int, error) Projection() flatsphere.Projection Name() string Size() int }
Common functionality for converting between various different coordinate systems and pixel indices within a store.
type LocationNotSupportedError ¶
func NewLocationNotSupportedError ¶
func NewLocationNotSupportedError(projection string, location Location) *LocationNotSupportedError
func (LocationNotSupportedError) Error ¶
func (l LocationNotSupportedError) Error() string
type LocationOutOfBoundsError ¶
type LocationOutOfBoundsError struct {
Location Location
}
func NewLocationOutOfBoundsError ¶
func NewLocationOutOfBoundsError(location Location) LocationOutOfBoundsError
func (LocationOutOfBoundsError) Error ¶
func (l LocationOutOfBoundsError) Error() string
type MercatorCutoffIndexer ¶
type MercatorCutoffIndexer struct { NorthCutoff float64 `json:"northCutoff"` SouthCutoff float64 `json:"southCutoff"` Grid ProjectionlessIndexer // contains filtered or unexported fields }
Indexing into a sphere of pixels project via a standard Mercator projection. Because Mercator diverges at the poles, two cutoff parameters are provided for the northern and southern latitudes. These cutoff parallels will mark the boundaries of the top and bottom of the grid respectively. Supports either row-major or column-major storage of the data for particular access patterns.
func (MercatorCutoffIndexer) Name ¶
func (m MercatorCutoffIndexer) Name() string
func (MercatorCutoffIndexer) Projection ¶
func (m MercatorCutoffIndexer) Projection() flatsphere.Projection
func (MercatorCutoffIndexer) Size ¶
func (m MercatorCutoffIndexer) Size() int
type NestLocation ¶
type NestLocation int
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Wrapper struct for a page that has been loaded into memory. Contains a 'dirty' flag to mark the cached page as having received an update in the data that needs to be flushed to disk.
type Pagemaster ¶
type Pagemaster struct {
// contains filtered or unexported fields
}
Abstracts the data access and caching in memory of a large file using a fixed page size. Individual operations intended to be threadsafe and allow for concurrency while maintaining efficiency. This abstraction also implements basic checksumming to validate the integrity of the data. A checksum is stored just before each page in the disk file, but this piece of data is not included in the slices returned by any of the public facing methods of this type. https://en.wikipedia.org/wiki/The_Pagemaster
func NewPagemaster ¶
func NewPagemaster(path string, maxCache int) *Pagemaster
Create a new cached data layer to access the file on disk location at `path`, with the specified number of pages allowed in the cache. No disk side effect. Must call Initialize afterward if the path is to a newly created (empty) file.
func (*Pagemaster) ClearCache ¶
func (p *Pagemaster) ClearCache()
Empties the cache of all pages. Does not destroy the data in the pages, so if those are still referenced elsewhere they will not be garbage collected. No disk side effect.
func (*Pagemaster) FlushAllPages ¶
func (p *Pagemaster) FlushAllPages() error
Writes all pages marked dirty to the disk, locking access to the cache and the file until writing is complete. If a page write files, the process is stopped and an error is returned, but only the successfully written pages will be marked clean. The page on which the write errored, and the remaining dirty pages, will still be marked dirty if the managing process wants to retry flushing.
func (*Pagemaster) FlushPage ¶
func (p *Pagemaster) FlushPage(pageIndex int) error
Writes the page in the cache to disk, whether it is dirty or not. Marks the page as clean afterward. If the page does not exist in the cache, no action is taken. If the write is unsuccessful, the page dirtiness status will be left unchanged.
func (*Pagemaster) GetChunk ¶
Essentially the same actions as GetPage, but returns a portion of the page data at the given byte offset.
func (*Pagemaster) GetPage ¶
func (p *Pagemaster) GetPage(pageIndex int) ([]byte, error)
Get the page with the sequential index given. If the page exists in the cache, does not access the disk. Otherwise, loads the page into the cache and returns it.
func (*Pagemaster) Initialize ¶
func (p *Pagemaster) Initialize(pages int, page []byte) error
For pagemasters created over newly created empty files, this function will initialize the file with the given number of pages, each page filled with the same given template of data. If a write to the file fails, all of the writes that have succeeded to that point will not be undone. However, future calls to Initialize (e.g. a rety), will write over any data that was written previously.
func (*Pagemaster) LoadPage ¶
func (p *Pagemaster) LoadPage(pageIndex int) ([]byte, error)
Retrieve the page at the given index from disk, load it into the cache, and return the data. Always skips cache to read from disk. If the cache is full, a different page is removed from the cache before the requested page is added.
func (*Pagemaster) MaxPagesInCache ¶
func (p *Pagemaster) MaxPagesInCache() int
The maximum number of pages allowed in the cache.
func (*Pagemaster) PageSize ¶
func (p *Pagemaster) PageSize() int
The number of bytes that be written to per page in the file.
func (*Pagemaster) PagesInCache ¶
func (p *Pagemaster) PagesInCache() int
The current number of pages in the cache.
func (*Pagemaster) SetChunk ¶
func (p *Pagemaster) SetChunk(pageIndex int, offset int, chunk []byte) error
Similar to SetPage but only updates the specified portion of data in the page.
func (*Pagemaster) SetPage ¶
func (p *Pagemaster) SetPage(pageIndex int, page []byte) error
Sets the data for the page at the given index, and marks the cache entry as dirty. If the page does not yet exist in the cache, it will exist in the cache afterwards, potentially unloading a different page to make room.
type ProjectedLocation ¶
type Projection ¶
type Projection []ColumnProjection
type ProjectionlessIndexer ¶
type ProjectionlessIndexer struct { Width int `json:"width"` Height int `json:"height"` RowMajor bool `json:"rowmajor"` }
Simple indexing into a grid, no spherical projection provided by this indexer. Supports either row-major or column-major storage of the data for particular access patterns.
func NewProjectionlessIndexer ¶
func NewProjectionlessIndexer(width int, height int, rowMajor bool) ProjectionlessIndexer
func (ProjectionlessIndexer) Name ¶
func (p ProjectionlessIndexer) Name() string
func (ProjectionlessIndexer) Projection ¶
func (p ProjectionlessIndexer) Projection() flatsphere.Projection
func (ProjectionlessIndexer) Size ¶
func (p ProjectionlessIndexer) Size() int
type RectangularLocation ¶
func (RectangularLocation) ToSpherical ¶
func (r RectangularLocation) ToSpherical() SphericalLocation
type RingLocation ¶
type RingLocation int
type SphericalLocation ¶
type Store ¶
type Store struct { // The name by which the store can be referenced in queries. Also the final folder in the path // in which the data file for this store is kept. Name string `json:"-"` ColumnSet []Column `json:"columns"` Rows int `json:"rows"` // contains filtered or unexported fields }
A simple set of rows, divided into fixed-size columns. The number of rows and columns both are known ahead of time, and the most efficient access pattern is by row index. A store keeps all of its data compact in one flat file, storing variable size metadata in a separate structured file.
func (*Store) Checkpoint ¶
func (*Store) DefaultRow ¶
func (*Store) FilterColumns ¶
func (s *Store) FilterColumns(proj Projection) []Column
func (*Store) GetValueAt ¶
Cheat method when a store has only a single column and we don't need to do any projection (because it's the only column)
func (*Store) Projection ¶
func (s *Store) Projection(columns ...string) (Projection, error)
func (*Store) RowsPerPage ¶
type Table ¶
type Table struct { Indexer LocationIndexer `json:"indexer"` IndexerName string `json:"indexerName"` Metadata map[string]string `json:"metadata"` // contains filtered or unexported fields }
func NewTable ¶
func NewTable(path string, indexer LocationIndexer, columns ...Column) (*Table, error)
func (*Table) Checkpoint ¶
func (*Table) UnmarshalJSON ¶
type TableNotFoundError ¶
type TableNotFoundError struct {
Table string
}
func NewTableNotFoundError ¶
func NewTableNotFoundError(tableName string) TableNotFoundError
func (TableNotFoundError) Error ¶
func (t TableNotFoundError) Error() string
type UniqueLocation ¶
type UniqueLocation int
type Value ¶
type Value []byte