schema

package
v0.0.0-...-b183724 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeShardId

func ComputeShardId(NumberOfShards int, key string) int

func DoesTableExists

func DoesTableExists(dbpool *pgxpool.Pool, schemaName, tableName string) (bool, error)

func GetObjectTypesFromDominsKeyJson

func GetObjectTypesFromDominsKeyJson(domainKeysJson string, defaultValue string) (*[]string, error)

Utility Methods

func IsSessionExists

func IsSessionExists(dbpool *pgxpool.Pool, sessionId string) (bool, error)

Utility function to check if session exist

func RegisterSession

func RegisterSession(dbpool *pgxpool.Pool, sourceType, client string, sessionId string, sourcePeriodKey int) error

Register the session in session_registry, sourceType is the source_type of the entity saved on that session_id, which is "file" for loader and "domain_table" for server

func TableExists

func TableExists(dbpool *pgxpool.Pool, schema, table string) (exists bool, err error)

func ToPgType

func ToPgType(dt string) string

Types

type ColumnDefinition

type ColumnDefinition struct {
	ColumnName  string `json:"columnName"`
	Description string `json:"description"`
	DataType    string `json:"dataType"`
	Default     string `json:"default"`
	IsArray     bool   `json:"isArray"`
	IsNotNull   bool   `json:"isNotNull"`
	Deprecated  bool   `json:"deprecated"`
	IsPK        bool   `json:"isPK"`
}

type ConstraintDefinition

type ConstraintDefinition struct {
	Name       string `json:"name"`
	Definition string `json:"definition"`
}

type DomainKeyInfo

type DomainKeyInfo struct {
	// list of input column name making the domain key
	ColumnNames []string
	// list of input column position making the domain key
	ColumnPos []int
	// list of pre-processing functions for the input column (one per column)
	PreprocessFnc []string
	// Object type associated with the Domain Key
	ObjectType string
	// Column position of column `objectType`:domain_key in the output table
	DomainKeyPos int
	// Column position of column `objectType`:shard_id in the output table
	ShardIdPos int
}

func (*DomainKeyInfo) String

func (dk *DomainKeyInfo) String() string

type HeadersAndDomainKeysInfo

type HeadersAndDomainKeysInfo struct {
	TableName        string
	RawHeaders       []string
	Headers          []string
	HashingOverriden bool
	HashingAlgo      string
	HashingSeed      uuid.UUID
	// key is the header
	HeadersPosMap map[string]int
	// key is ObjectType of DomainKeyInfo
	DomainKeysInfoMap map[string]*DomainKeyInfo
	// Reserved columns removed from RawHeaders and included in Headers
	ReservedColumns map[string]bool
	FillerColumns   map[string]bool
	// column prefix used for fixed-width input record
	// The prefix is the first record type (the one with offset == 0)
	// This is empty string for non fixed-width records, therefore ignored
	FixedWidthColumnPrefix string
}

func NewHeadersAndDomainKeysInfo

func NewHeadersAndDomainKeysInfo(tableName string) (*HeadersAndDomainKeysInfo, error)

func (*HeadersAndDomainKeysInfo) ComputeGroupingKey

func (dkInfo *HeadersAndDomainKeysInfo) ComputeGroupingKey(NumberOfShards int, objectType *string, record *[]string, recordTypeOffset int, jetsKey *string) (string, int, error)

func (*HeadersAndDomainKeysInfo) ComputeGroupingKeyI

func (dkInfo *HeadersAndDomainKeysInfo) ComputeGroupingKeyI(NumberOfShards int, objectType *string, record *[]interface{}) (string, int, error)

Alternate version for output records - same as ComputeGroupingKey using interface{} as record

func (*HeadersAndDomainKeysInfo) CreateStagingTable

func (dkInfo *HeadersAndDomainKeysInfo) CreateStagingTable(dbpool *pgxpool.Pool, tableName string) (err error)

Create the Staging Table

func (*HeadersAndDomainKeysInfo) GetHeaderPos

func (dkInfo *HeadersAndDomainKeysInfo) GetHeaderPos() []int

func (*HeadersAndDomainKeysInfo) Initialize

func (dkInfo *HeadersAndDomainKeysInfo) Initialize(mainObjectType string, domainKeysJson *string) error

initialize (domainKeysJson string) -------------------------------------------------------------------------------------- Compute output table columns and associated domain keys passing domainKeysJson as argument for completeness

func (*HeadersAndDomainKeysInfo) InitializeDomainTable

func (dkInfo *HeadersAndDomainKeysInfo) InitializeDomainTable(domainHeaders *[]string, mainObjectType string, domainKeysJson *string) error

func (*HeadersAndDomainKeysInfo) InitializeStagingTable

func (dkInfo *HeadersAndDomainKeysInfo) InitializeStagingTable(rawHeaders *[]string, mainObjectType string, domainKeysJson *string, fixedWidthColumnPrefix string) error

func (*HeadersAndDomainKeysInfo) IsDomainKeyIsJetsKey

func (dkInfo *HeadersAndDomainKeysInfo) IsDomainKeyIsJetsKey(objectType *string) bool

func (*HeadersAndDomainKeysInfo) String

func (dkInfo *HeadersAndDomainKeysInfo) String() string

type IndexDefinition

type IndexDefinition struct {
	IndexName string `json:"indexName"`
	IndexDef  string `json:"indexDef"`
}

type TableDefinition

type TableDefinition struct {
	SchemaName       string                 `json:"schemaName"`
	TableName        string                 `json:"tableName"`
	Columns          []ColumnDefinition     `json:"columns"`
	Indexes          []IndexDefinition      `json:"indexes"`
	TableConstraints []ConstraintDefinition `json:"tableConstraints"`
}

Define Database Table Structure This table/column definition structure is used by the api services and by update_db.

func GetTableSchema

func GetTableSchema(dbpool *pgxpool.Pool, schema string, table string) (*TableDefinition, error)

func (*TableDefinition) CreateTable

func (tableDefinition *TableDefinition) CreateTable(dbpool *pgxpool.Pool) error

func (*TableDefinition) UpdateTable

func (tableDefinition *TableDefinition) UpdateTable(dbpool *pgxpool.Pool, existingSchema *TableDefinition) error

func (*TableDefinition) UpdateTableSchema

func (tableDefinition *TableDefinition) UpdateTableSchema(dbpool *pgxpool.Pool, dropExisting bool) (err error)

TableDefinition Methods -----------------------

Jump to

Keyboard shortcuts

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