Documentation
¶
Overview ¶
Package apps defines the application interface and implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App interface {
// Name returns the application name.
Name() string
// Description returns a human-readable description.
Description() string
// WorkloadType returns the workload type (OLTP, OLAP, Mixed).
WorkloadType() string
// CreateSchema creates the application's database schema.
CreateSchema(ctx context.Context, pool *pgxpool.Pool) error
// DropSchema drops the application's database schema.
DropSchema(ctx context.Context, pool *pgxpool.Pool) error
// GenerateData generates test data for the application.
GenerateData(ctx context.Context, pool *pgxpool.Pool, cfg GeneratorConfig) error
// GetQueries returns the available queries for this application.
GetQueries() []QueryDefinition
// ExecuteQuery executes a randomly selected query based on the query mix.
ExecuteQuery(ctx context.Context, pool *pgxpool.Pool) QueryResult
// ExecuteQueryConn executes a randomly selected query using a single connection.
ExecuteQueryConn(ctx context.Context, conn *pgx.Conn) QueryResult
// RequiresPgvector returns true if the app needs pgvector extension.
RequiresPgvector() bool
}
App defines the interface that all applications must implement.
type DB ¶
type DB interface {
Begin(ctx context.Context) (pgx.Tx, error)
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
DB is an interface that both *pgxpool.Pool and *pgx.Conn satisfy. This allows query executors to work with either a connection pool or a dedicated single connection.
type GeneratorConfig ¶
type GeneratorConfig struct {
// TargetSize is the target database size in bytes.
TargetSize int64
// EmbeddingMode controls how vector embeddings are generated.
// Options: random, openai, sentence, vectorizer
EmbeddingMode string
// EmbeddingDimensions is the vector dimension size.
EmbeddingDimensions int
// VectorizerURL is the URL for pgedge-vectorizer service.
VectorizerURL string
// OpenAIAPIKey is the API key for OpenAI embeddings.
OpenAIAPIKey string
}
GeneratorConfig holds configuration for data generation.
type QueryDefinition ¶
type QueryDefinition struct {
// Name is the query identifier.
Name string
// Description describes what the query does.
Description string
// Weight is the relative frequency of this query (0-100).
Weight int
// Type is the query type (read, write, mixed).
Type string
}
QueryDefinition describes a query type in the application's workload.
type QueryResult ¶
type QueryResult struct {
// QueryName identifies the query type.
QueryName string
// Duration is how long the query took.
Duration int64
// RowsAffected is the number of rows affected (for DML).
RowsAffected int64
// Error is set if the query failed.
Error error
}
QueryResult holds the result of a query execution.
type SizeMaintainer ¶
type SizeMaintainer interface {
// MaintainSize checks if the database has grown beyond the target size
// and deletes old data to bring it back within bounds.
// Returns the number of records deleted and any error.
MaintainSize(ctx context.Context, conn *pgx.Conn, targetSize int64) (int64, error)
}
SizeMaintainer is an optional interface that apps can implement to support automatic cleanup of old data to maintain the target database size.
type TableDefinition ¶
type TableDefinition struct {
// Name is the table name.
Name string
// BaseRowSize is the estimated average row size in bytes.
BaseRowSize int64
// ScaleRatio determines how row count scales relative to base.
// For example, if the base table has 1000 rows at scale 1,
// a table with ScaleRatio 10 would have 10000 rows.
ScaleRatio float64
}
TableDefinition describes a table in the application's schema.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package analytics implements the Analytics Warehouse application (TPC-H based).
|
Package analytics implements the Analytics Warehouse application (TPC-H based). |
|
Package brokerage implements the Brokerage Firm application (TPC-E based).
|
Package brokerage implements the Brokerage Firm application (TPC-E based). |
|
Package docmgmt implements the Document Management application with semantic search.
|
Package docmgmt implements the Document Management application with semantic search. |
|
Package ecommerce implements the E-commerce application with semantic search.
|
Package ecommerce implements the E-commerce application with semantic search. |
|
Package knowledgebase implements the Knowledge Base application with semantic search.
|
Package knowledgebase implements the Knowledge Base application with semantic search. |
|
Package retail implements the Retail Analytics application (TPC-DS based).
|
Package retail implements the Retail Analytics application (TPC-DS based). |
|
Package wholesale implements the Wholesale Supplier application (TPC-C based).
|
Package wholesale implements the Wholesale Supplier application (TPC-C based). |