Inheritance: GraphViewDefinedFunctionRegister
Exemplo n.º 1
0
        // Add Upsize function version 2 with @dumb
        private void UpgradeFromV200ToV210(SqlTransaction transaction)
        {
            DropAssemblyAndMetaUdf(Version200MetaUdf, transaction);

            // Upgrade global udf and assembly
            const string assemblyName = GraphViewUdfAssemblyName;
            GraphViewDefinedFunctionRegister register = new MetaFunctionRegister(assemblyName);
            register.Register(Conn, transaction);

            // Update version number
            UpdateVersionNumber("2.10", transaction);
        }
Exemplo n.º 2
0
        //Add one udf ConvertNumberIntoBinaryForPath
        private void UpgradeFromV110ToV111(SqlTransaction transaction)
        {
            var tables = GetNodeTables(transaction);
            //DropAssemblyAndMetaUDFV110(transaction);
            DropAssemblyAndMetaUdf(Version110MetaUdf, transaction);
            const string assemblyName = GraphViewUdfAssemblyName;

            GraphViewDefinedFunctionRegister register = new MetaFunctionRegister(assemblyName);
            register.Register(Conn, transaction);

            //Update version number
            UpdateVersionNumber("1.11", transaction);
            //Upgrade global view
            foreach (var schema in tables.ToLookup(x => x.Item1.ToLower()))
            {
                UpdateGlobalNodeView(schema.Key, transaction);
            }
        }
Exemplo n.º 3
0
        // Add reversed edge support
        private void UpgradeFromV111ToV200(SqlTransaction transaction)
        {
            // Upgrade meta tables
            UpgradeMetaTableV111(transaction);

            var tables = GetNodeTables(transaction);

            // Drop table functions, assemblies and global udf
            foreach (var table in tables)
            {
                DropNodeTableFunctionAndAssembly(table.Item1, table.Item2, Version111TableUdf, transaction);
            }
            DropAssemblyAndMetaUdf(Version111MetaUdf, transaction);

            // Upgrade global udf and assembly
            const string assemblyName = GraphViewUdfAssemblyName;
            GraphViewDefinedFunctionRegister register = new MetaFunctionRegister(assemblyName);
            register.Register(Conn, transaction);

            // Upgrade table functions and assemblies
            UpgradeNodeTableFunction(null, transaction);

            // Update version number
            UpdateVersionNumber("2.00", transaction);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a graph database and creates meta-data, 
        /// including table ID, graph column and edge attribute information.
        /// </summary>
        internal void CreateMetadata(SqlTransaction transaction)
        {
            var tx = transaction;
            try
            {
                using (var command = new SqlCommand(null, Conn))
                {
                    command.Transaction = tx;
                    command.CommandText = string.Format(@"
                        CREATE TABLE [{0}] (
                            [ColumnId] [bigint] NOT NULL IDENTITY(0, 1),
                            [TableId] [bigint] NOT NULL,
                            [TableSchema] [nvarchar](128) NOT NULL,
                            [TableName] [nvarchar](128) NOT NULL,
                            [ColumnName] [nvarchar](128) NOT NULL,
                            [ColumnRole] [int] NOT NULL,
                            [Reference] [nvarchar](128) NULL,
                            [RefTableSchema] [nvarchar](128) NULL,
                            [HasReversedEdge] [bit] NOT NULL DEFAULT 0,
                            [IsReversedEdge] [bit] NOT NULL DEFAULT 0,
                            [EdgeUdfPrefix] [nvarchar](512) NULL,
                            PRIMARY KEY CLUSTERED ([ColumnId] ASC)
                        )", MetadataTables[1]);

                    command.ExecuteNonQuery();

                    command.CommandText = string.Format(@"
                        CREATE TABLE [{0}] (
                            [TableId] [bigint] NOT NULL IDENTITY(0, 1),
                            [TableSchema] [nvarchar](128) NOT NULL,
                            [TableName] [nvarchar](128) NOT NULL,
                            [TableRole] [int] NOT NULL DEFAULT 0,
                            PRIMARY KEY CLUSTERED ([TableId] ASC)
                        )", MetadataTables[0]);
                    command.ExecuteNonQuery();

                    command.CommandText = string.Format(@"
                        CREATE TABLE [{0}] (
                            [AttributeId] [bigint] NOT NULL IDENTITY(0, 1),
                            [ColumnId] [bigint] NOT NULL,
                            [TableSchema] [nvarchar](128) NOT NULL,
                            [TableName] [nvarchar](128) NOT NULL,
                            [ColumnName] [nvarchar](128) NOT NULL,
                            [AttributeName] [nvarchar](128) NOT NULL,
                            [AttributeType] [nvarchar](128) NOT NULL,
                            [AttributeEdgeId] [int],
                            PRIMARY KEY CLUSTERED ([AttributeId] ASC)
                        )", MetadataTables[2]);
                    command.ExecuteNonQuery();

                    command.CommandText = string.Format(@"
                        CREATE TABLE [{0}] (
                            [TableSchema] [nvarchar](128) NOT NULL,
                            [TableName] [nvarchar](128) NOT NULL,
                            [ColumnName] [nvarchar](128) NOT NULL,
                            [ColumnId] [bigint] NOT NULL,
                            [AverageDegree] [float] DEFAULT(5),
                            [SampleRowCount] [int] DEFAULT(1000)
                            PRIMARY KEY CLUSTERED ([TableName] ASC, [TableSchema] ASC, [ColumnName] ASC)
                        )", MetadataTables[3]);
                    command.ExecuteNonQuery();

                    command.CommandText = string.Format(@"
                        CREATE TABLE [{0}](
                            [ProcId] [bigint] NOT NULL IDENTITY(0, 1),
                            [ProcSchema] [nvarchar](128) NOT NULL,
                            [ProcName] [nvarchar](128) NOT NULL,
                            PRIMARY KEY CLUSTERED ([ProcId] ASC)
                        )", MetadataTables[4]);
                    command.ExecuteNonQuery();

                    command.CommandText = @"
                        CREATE TABLE " + MetadataTables[5] + @"(
                            [NodeViewColumnId] [bigint] NOT NULL,
                            [ColumnId] [bigint] NOT NULL
                            PRIMARY KEY CLUSTERED ([NodeViewColumnId] ASC, [ColumnId] ASC)
                        )";
                    command.ExecuteNonQuery();

                    //EdgeViewAttributeReference
                    command.CommandText = @"
                        CREATE TABLE " + MetadataTables[6] + @"(
                            [EdgeViewAttributeId] [bigint] NOT NULL,
                            [EdgeAttributeId] [bigint] NOT NULL
                            PRIMARY KEY CLUSTERED ([EdgeViewAttributeId] ASC, [EdgeAttributeId] ASC)
                        )";
                    command.ExecuteNonQuery();

                    //NodeViewCollection
                    command.CommandText = @"
                        CREATE TABLE " + MetadataTables[7] + @"(
                            [NodeViewTableId] [bigint] NOT NULL,
                            [TableId] [bigint] NOT NULL
                            PRIMARY KEY CLUSTERED ([NodeViewTableId] ASC, [TableId] ASC)
                        )";
                    command.ExecuteNonQuery();

                    //NodeViewColumnCollection
                    //command.CommandText = @"
                    //    CREATE TABLE " + MetadataTables[8] + @"(
                    //        [NodeViewColumnId] [bigint] NOT NULL,
                    //        [ColumnId] [bigint] NOT NULL
                    //        PRIMARY KEY CLUSTERED ([NodeViewColumnId] ASC, [ColumnId] ASC)
                    //    )";
                    //command.ExecuteNonQuery();

                    const string createVersionTable = @"
                        CREATE TABLE [{0}] (
                            [VERSION] [varchar](8) NOT NULL
                        )
                        INSERT INTO [{0}] (VERSION) VALUES({1})";
                    command.CommandText = string.Format(createVersionTable, VersionTable, version);
                    command.ExecuteNonQuery();
                    currentVersion = version;
                }
                const string assemblyName = GraphViewUdfAssemblyName;

                GraphViewDefinedFunctionRegister register =  new MetaFunctionRegister(assemblyName);
                register.Register(Conn, tx);
            }
            catch (SqlException e)
            {
                throw new SqlExecutionException("Failed to create necessary meta-data or system-reserved functions.", e);
            }
        }