Documentation ¶
Index ¶
- Variables
- func CreateDatabase(ctx context.Context, opt types.PostgresOpt) (err error)
- type DB
- func (db *DB) BuildRevisionRanges(ctx context.Context, groupName string) ([]*types.RevisionRange, error)
- func (db *DB) CreateEntity(ctx context.Context, opt types.CreateEntityOpt) error
- func (db *DB) CreateFeature(ctx context.Context, opt metadata.CreateFeatureOpt) error
- func (db *DB) CreateFeatureGroup(ctx context.Context, opt metadata.CreateFeatureGroupOpt) error
- func (db *DB) CreateRevision(ctx context.Context, opt metadata.CreateRevisionOpt) error
- func (db *DB) GetEntity(ctx context.Context, name string) (*types.Entity, error)
- func (db *DB) GetFeature(ctx context.Context, featureName string) (*types.Feature, error)
- func (db *DB) GetFeatureGroup(ctx context.Context, groupName string) (*types.FeatureGroup, error)
- func (db *DB) GetLatestRevision(ctx context.Context, groupName string) (*types.Revision, error)
- func (db *DB) GetRevision(ctx context.Context, opt metadata.GetRevisionOpt) (*types.Revision, error)
- func (db *DB) ListEntity(ctx context.Context) ([]*types.Entity, error)
- func (db *DB) ListFeature(ctx context.Context, opt types.ListFeatureOpt) (types.FeatureList, error)
- func (db *DB) ListFeatureGroup(ctx context.Context, entityName *string) ([]*types.FeatureGroup, error)
- func (db *DB) ListRevision(ctx context.Context, opt metadata.ListRevisionOpt) ([]*types.Revision, error)
- func (db *DB) UpdateEntity(ctx context.Context, opt types.UpdateEntityOpt) (int64, error)
- func (db *DB) UpdateFeature(ctx context.Context, opt types.UpdateFeatureOpt) (int64, error)
- func (db *DB) UpdateFeatureGroup(ctx context.Context, opt types.UpdateFeatureGroupOpt) (int64, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DB_FUNCTIONS = []string{
`
CREATE OR REPLACE FUNCTION update_modify_time() RETURNS trigger AS $$
BEGIN
NEW.modify_time = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
`,
}
View Source
var META_TABLE_SCHEMAS = map[string]string{
"feature": `
CREATE TABLE feature (
id SERIAL2 UNIQUE,
name VARCHAR(32) NOT NULL,
group_name VARCHAR(32) NOT NULL,
db_value_type VARCHAR(32) NOT NULL,
value_type VARCHAR(16) NOT NULL,
description VARCHAR(128) DEFAULT '',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modify_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (name)
);
COMMENT ON COLUMN feature.value_type IS 'data type of feature value';
COMMENT ON COLUMN feature.db_value_type IS 'database data type of feature value';
`,
"feature_group": `
CREATE TABLE feature_group (
id SERIAL2 UNIQUE,
name VARCHAR(32) NOT NULL,
entity_name VARCHAR(32) NOT NULL,
online_revision_id INT DEFAULT NULL,
category VARCHAR(16) NOT NULL,
description VARCHAR(64) DEFAULT '',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modify_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (name)
);
COMMENT ON COLUMN feature_group.online_revision_id IS 'group online point-in-time epoch seconds';
COMMENT ON COLUMN feature_group.category IS 'group category: batch, stream ...';
`,
"feature_entity": `
CREATE TABLE feature_entity (
id SERIAL2 UNIQUE,
name VARCHAR(32) NOT NULL,
length SMALLINT NOT NULL,
description VARCHAR(64) DEFAULT '',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modify_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (name)
);
COMMENT ON COLUMN feature_entity.length IS 'feature entity value max length';
`,
"feature_group_revision": `
CREATE TABLE feature_group_revision (
id SERIAL UNIQUE,
group_name VARCHAR(32) NOT NULL,
revision BIGINT NOT NULL,
data_table VARCHAR(64) NOT NULL,
description VARCHAR(64) DEFAULT '',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modify_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (group_name, revision)
);
COMMENT ON COLUMN feature_group_revision.revision IS 'group data point-in-time epoch seconds';
COMMENT ON COLUMN feature_group_revision.data_table IS 'feature data table name';
`,
}
View Source
var META_VIEW_SCHEMAS = map[string]string{
"rich_feature": `
CREATE VIEW rich_feature AS
SELECT
tmp2.*,
fgr2.revision AS online_revision
FROM
(SELECT
tmp.*,
fgr.revision AS offline_revision,
fgr.data_table AS offline_data_table
FROM
(SELECT
f.*,
fg.entity_name, fg.category, fg.online_revision_id
FROM feature AS f
LEFT JOIN feature_group AS fg
ON f.group_name = fg.name) AS tmp
LEFT JOIN feature_group_revision AS fgr
ON
tmp.group_name = fgr.group_name AND
fgr.revision = (
SELECT MAX(revision)
FROM feature_group_revision
WHERE feature_group_revision.group_name = tmp.group_name
)) AS tmp2
LEFT JOIN feature_group_revision AS fgr2
ON tmp2.online_revision_id = fgr2.id;
`,
"rich_feature_group": `
CREATE VIEW rich_feature_group AS
SELECT
fg_tmp.*,
fgr2.revision AS offline_revision,
fgr2.data_table AS offline_data_table
FROM
(SELECT
fg.id, fg.name, fg.entity_name, fg.category, fg.online_revision_id, fg.description, fg.create_time, fg.modify_time,
fgr.revision AS online_revision
FROM feature_group AS fg
LEFT JOIN feature_group_revision AS fgr
ON fg.online_revision_id = fgr.id) AS fg_tmp
LEFT JOIN feature_group_revision AS fgr2
ON
fg_tmp.name = fgr2.group_name AND
fgr2.revision = (
SELECT MAX(revision)
FROM feature_group_revision
WHERE feature_group_revision.group_name = fg_tmp.name
);
`,
}
View Source
var TRIGGER_TEMPLATE = `` /* 139-byte string literal not displayed */
Functions ¶
func CreateDatabase ¶
func CreateDatabase(ctx context.Context, opt types.PostgresOpt) (err error)
Types ¶
type DB ¶
func (*DB) BuildRevisionRanges ¶
func (*DB) CreateEntity ¶
func (*DB) CreateFeature ¶
func (*DB) CreateFeatureGroup ¶
func (*DB) CreateRevision ¶
func (*DB) GetFeature ¶
func (*DB) GetFeatureGroup ¶
func (*DB) GetLatestRevision ¶
func (*DB) GetRevision ¶
func (*DB) ListFeature ¶
func (db *DB) ListFeature(ctx context.Context, opt types.ListFeatureOpt) (types.FeatureList, error)
func (*DB) ListFeatureGroup ¶
func (*DB) ListRevision ¶
func (*DB) UpdateEntity ¶
func (*DB) UpdateFeature ¶
func (*DB) UpdateFeatureGroup ¶
Click to show internal directories.
Click to hide internal directories.