translator

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DB = "dc_v3"

DB is the database name.

Variables

This section is empty.

Functions

func Bind

func Bind(mappings []*base.Mapping, queries []*base.Query) (map[*base.Query][]*base.Mapping, error)

Bind binds mapping and query statements.

func GetEntityType

func GetEntityType(mappings []*base.Mapping) map[string][]string

GetEntityType obtains a map from entity key to the types.

func GetExplicitTypeProp

func GetExplicitTypeProp(mappings []*base.Mapping) map[string][]string

GetExplicitTypeProp obtains a map from type to list of predicate

func GetFuncDeps

func GetFuncDeps(mappings []*base.Mapping) (map[base.Entity]map[string]interface{}, error)

GetFuncDeps obtains the functional deps from schema mapping.

func GetNodeRef

func GetNodeRef(queries []*base.Query) map[base.Node]struct{}

GetNodeRef obtains a list of node reference from query statements.

func GetNodeType

func GetNodeType(queries []*base.Query) (map[string]string, error)

GetNodeType obtains a map from node alias to the types.

func GetOutArcInfo

func GetOutArcInfo(mappings []*base.Mapping, nodeType string) (map[string][]OutArcInfo, error)

GetOutArcInfo gets the table and columns corresponding to the node properties.

func GetProvColumn

func GetProvColumn(mappings []*base.Mapping) (map[string]base.Column, error)

GetProvColumn obtains the provenance column for each table.

func GetQueryID

func GetQueryID(queries []*base.Query, matchTriple map[*base.Query]bool) map[*base.Query]int

GetQueryID obtains the id for query statement. If two query statements match to Triples table, they would have same query id if they have the same predciate and subject. If two query statements match to non-Triples table, they would have the same query id if they have the same subject. The same query id means they point to the same spanner table instance in SQL query.

func GetSubTypeMap

func GetSubTypeMap(tableTypesJSONFilePath string) (map[string]string, error)

GetSubTypeMap gets subtype map.

func MatchTriple

func MatchTriple(mappings []*base.Mapping, queries []*base.Query) (map[*base.Query]bool, error)

MatchTriple takes list of queries and mappings and determines whether a query matches Triples table.

func ParseMapping

func ParseMapping(mcf, database string) ([]*base.Mapping, error)

ParseMapping parses schema mapping mcf into a list of Mapping struct.

func ParseQuery

func ParseQuery(queryString string) ([]base.Node, []*base.Query, error)

ParseQuery parses a datalog query into list of nodes and list of query statements.

func PruneMapping

func PruneMapping(mappings []*base.Mapping) []*base.Mapping

PruneMapping prunes foreign key entity mappings.

func RewriteQuery

func RewriteQuery(queries []*base.Query, subTypeMap map[string]string) []*base.Query

RewriteQuery rewrites typeOf query for entity that is a subType.

Types

type Binding

type Binding struct {
	Query   *base.Query
	Mapping *base.Mapping
}

Binding contains a query and mapping object which bind together.

type Constraint

type Constraint struct {
	// Left hand side of an SQL condition
	LHS base.Column
	// Right hand side of an SQL condition
	RHS interface{}
}

Constraint wraps the SQL lhs and rhs variable.

func GetConstraint

func GetConstraint(
	graph Graph,
	funcDeps map[base.Entity]map[string]interface{}) ([]Constraint, map[base.Node]string, error)

GetConstraint obtains a list of constraints object that can be used to construct SQL query.

type Graph

type Graph map[interface{}]map[interface{}]struct{}

Graph represents the struct for terms matching.

func (Graph) String

func (graph Graph) String() string

String gets the string reprentation of a graph.

type InArcInfo

type InArcInfo struct {
	Table  string
	Pred   string
	SubCol string
	ObjCol string
}

InArcInfo is used for in arcs pred column.

func GetInArcInfo

func GetInArcInfo(mappings []*base.Mapping, nodeType string) ([]InArcInfo, error)

GetInArcInfo gets the table and columns corresponding to the node properties.

type OutArcInfo

type OutArcInfo struct {
	Pred   string
	Column string
	IsNode bool
}

OutArcInfo is used for out arcs pred column.

type ProvInfo

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

ProvInfo contains the provenance query metadata

type Translation

type Translation struct {
	SQL        string
	Nodes      []base.Node
	Bindings   []Binding
	Constraint []Constraint
	Prov       map[int][]int
}

Translation contains the translated result.

func Translate

func Translate(
	mappings []*base.Mapping, nodes []base.Node, queries []*base.Query,
	subTypeMap map[string]string, options ...*base.QueryOptions) (
	*Translation, error)

Translate takes a datalog query and translates to GoogleSQL query based on schema mapping.

Jump to

Keyboard shortcuts

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