store

package
v0.7.42 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store is the data-access seam: a DataStore interface and its parquet-go implementation, reading Parquet tables from a directory or from any io.ReaderAt (for example an HTTP range reader).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned by Get when no row has the id, and by table lookups for a missing table.

Functions

func ReadManifest

func ReadManifest(dir string) (map[string]any, error)

ReadManifest reads `<dir>/manifest.json`; it returns nil, nil when there is none.

Types

type DataStore

type DataStore interface {
	// Get returns the row whose id column equals id, or an error wrapping ErrNotFound.
	Get(table string, id int64) (Row, error)
	// Filter returns the rows where every range holds, in file order.
	Filter(table string, ranges ...Range) ([]Row, error)
	// SearchName returns up to limit rows whose name contains text, case-insensitively.
	SearchName(table, text string, limit int) ([]Row, error)
}

DataStore is read access to game data tables. Every table has a numeric `id` column; text search uses the `name` column.

type DirSource

type DirSource string

DirSource reads `<dir>/<table>.parquet`.

func (DirSource) Open

func (d DirSource) Open(table string) (io.ReaderAt, int64, error)

type HTTPRangeReader

type HTTPRangeReader struct {
	URL    string
	Client *http.Client
	// contains filtered or unexported fields
}

HTTPRangeReader is an io.ReaderAt over one URL, using HTTP Range requests.

func NewHTTPRangeReader

func NewHTTPRangeReader(client *http.Client, url string) (*HTTPRangeReader, error)

NewHTTPRangeReader finds the object's size with a HEAD request.

func (*HTTPRangeReader) ReadAt

func (r *HTTPRangeReader) ReadAt(p []byte, off int64) (int, error)

func (*HTTPRangeReader) Requests

func (r *HTTPRangeReader) Requests() int64

Requests is the number of range requests made so far.

func (*HTTPRangeReader) Size

func (r *HTTPRangeReader) Size() int64

type HTTPSource

type HTTPSource struct {
	Base   string
	Client *http.Client
}

HTTPSource serves `<base>/<table>.parquet` over HTTP range requests.

func (HTTPSource) Open

func (h HTTPSource) Open(table string) (io.ReaderAt, int64, error)

type ParquetStore

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

ParquetStore is a DataStore over a Source.

func New

func New(src Source) *ParquetStore

func NewDir

func NewDir(dir string) *ParquetStore

NewDir reads `<dir>/<table>.parquet`.

func (*ParquetStore) Column

func (s *ParquetStore) Column(table, column string) ([]any, error)

Column returns every value of one column in file order, reading only that column's pages.

func (*ParquetStore) Filter

func (s *ParquetStore) Filter(table string, ranges ...Range) ([]Row, error)

func (*ParquetStore) Get

func (s *ParquetStore) Get(table string, id int64) (Row, error)

func (*ParquetStore) OpenFile

func (s *ParquetStore) OpenFile(table string) (*parquet.File, error)

OpenFile returns the table's Parquet file, opened once and kept.

func (*ParquetStore) SearchName

func (s *ParquetStore) SearchName(table, text string, limit int) ([]Row, error)

type Range

type Range struct {
	Column   string
	Min, Max any
}

Range keeps rows whose Column lies in [Min, Max]; a nil bound is open. Bounds are numbers or strings, matching the column's type.

type ReaderSource

type ReaderSource map[string]SizedReaderAt

ReaderSource serves tables from memory or any other io.ReaderAt, by table name.

func (ReaderSource) Open

func (s ReaderSource) Open(table string) (io.ReaderAt, int64, error)

type Row

type Row map[string]any

Row is one table row by column name. Integers are int64, floats float64, text string, booleans bool, nulls nil; a list column is a []any of those (empty for an empty list).

type SizedReaderAt

type SizedReaderAt struct {
	io.ReaderAt
	Size int64
}

SizedReaderAt is an io.ReaderAt that knows its length.

type Source

type Source interface {
	Open(table string) (io.ReaderAt, int64, error)
}

Source opens a table's bytes.

Jump to

Keyboard shortcuts

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