private void CopyMembers(DestinationTableParameters old)
 {
     this.table = old.table;
     this.operation = old.operation;
     this.bulkInsertBatchSize = old.bulkInsertBatchSize;
     this.bulkInsertTimeout = old.bulkInsertTimeout;
 }
Exemplo n.º 2
0
        public QueryImporter(SourceQueryParameters source, DestinationTableParameters destination)
            : base(destination)
        {
            InitializeMembers();

            this.source = source;
        }
Exemplo n.º 3
0
        private IQueryImporter GetQueryImporter(string tableName, bool remote)
        {
            var d = new DestinationTableParameters();
            d.Table = new Jhu.Graywulf.Schema.Table()
            {
                Dataset = new Jhu.Graywulf.Schema.SqlServer.SqlServerDataset("", Test.Constants.TestConnectionString),
                SchemaName = "dbo",
                TableName = tableName
            };
            d.Operation = DestinationTableOperation.Create;

            var s = new SourceQueryParameters();
            s.Dataset = new Jhu.Graywulf.Schema.SqlServer.SqlServerDataset("TEST", Test.Constants.TestConnectionString);
            s.Query = "SELECT 1 AS one, 2 AS two, 3 AS three";

            IQueryImporter q = null;
            if (remote)
            {
                q = RemoteServiceHelper.CreateObject<IQueryImporter>(Test.Constants.Localhost);
            }
            else
            {
                q = new QueryImporter();
            }

            q.Source = s;
            q.Destination = d;

            return q;
        }
Exemplo n.º 4
0
        public DataFileImporter(DataFileBase source, DestinationTableParameters destination)
            : base(destination)
        {
            InitializeMembers();

            this.source = source;
        }
Exemplo n.º 5
0
        private void InitializeMembers(StreamingContext context)
        {
            this.queryTimeout = 60; // TODO ***

            this.destination = new DestinationTableParameters();
            this.isDestinationTableInitialized = false;

            this.sourceDatabaseVersionName = String.Empty;
            this.statDatabaseVersionName = String.Empty;

            this.tableStatistics = new List<TableReference>();
            this.partitions = new List<QueryPartitionBase>();

            this.destinationDatabaseInstance = new EntityProperty<DatabaseInstance>();

            this.partitioningTable = null;
            this.partitioningKey = null;
        }
Exemplo n.º 6
0
        private void CopyMembers(QueryBase old)
        {
            this.queryTimeout = old.queryTimeout;

            this.destination = old.destination;
            this.isDestinationTableInitialized = old.isDestinationTableInitialized;

            this.sourceDatabaseVersionName = old.sourceDatabaseVersionName;
            this.statDatabaseVersionName = old.statDatabaseVersionName;

            this.tableStatistics = new List<TableReference>();  // ***
            this.partitions = new List<QueryPartitionBase>(old.partitions.Select(p => (QueryPartitionBase)p.Clone()));

            this.destinationDatabaseInstance = new EntityProperty<DatabaseInstance>(old.destinationDatabaseInstance);

            this.partitioningTable = old.partitioningTable;
            this.partitioningKey = old.partitioningKey;
        }
Exemplo n.º 7
0
        public void ExecuteQuery()
        {
            DestinationTableParameters destination;

            SourceQueryParameters source = new SourceQueryParameters()
            {
                Query = GetOutputSelectQuery(),
                Timeout = Query.QueryTimeout,
            };

            switch (Query.ExecutionMode)
            {
                case ExecutionMode.SingleServer:
                    // In single-server mode results are directly written into destination table
                    source.Dataset = Query.Destination.Table.Dataset;
                    destination = Query.Destination;
                    break;
                case ExecutionMode.Graywulf:
                    // In graywulf mode results are written into a temporary table first
                    var temptable = GetOutputTable();
                    TemporaryTables.TryAdd(temptable.TableName, temptable);
                    DropTableOrView(temptable);     // TODO: not needed

                    source.Dataset = AssignedServerInstance.GetDataset();

                    destination = new DestinationTableParameters()
                    {
                        Operation = DestinationTableOperation.Append,       // TODO: change to drop
                        Table = temptable
                    };
                    break;
                default:
                    throw new NotImplementedException();
            }

            ExecuteSelectInto(source, destination);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Copies resultset from the output temporary table to the destination database (MYDB)
        /// </summary>
        public void CopyResultset()
        {
            switch (Query.ExecutionMode)
            {
                case ExecutionMode.SingleServer:
                    // Do nothing as execute writes results directly into destination table
                    break;
                case ExecutionMode.Graywulf:
                    {
                        var sql = "SELECT tablealias.* FROM [{0}].[{1}].[{2}] AS tablealias";
                        var temptable = GetOutputTable();

                        sql = String.Format(sql, temptable.DatabaseName, temptable.SchemaName, temptable.TableName);

                        var source = new SourceQueryParameters()
                        {
                            Dataset = temptable.Dataset,
                            Query = sql,
                            Timeout = Query.QueryTimeout,
                        };

                        // Change destination to Append, output table has already been created,
                        // partitions only append to it
                        var destination = new DestinationTableParameters(Query.Destination);
                        destination.Operation = DestinationTableOperation.Append;

                        ExecuteBulkCopy(source, destination, false, Query.QueryTimeout);
                    }
                    break;
                default:
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 9
0
        public void CopyRemoteTable(TableReference table, SourceQueryParameters source)
        {
            // Temp table name
            var temptable = GetTemporaryTable(table.EscapedUniqueName);
            TemporaryTables.TryAdd(table.UniqueName, temptable);

            var destination = new DestinationTableParameters()
            {
                Table = temptable,
                Operation = DestinationTableOperation.Drop | DestinationTableOperation.Create,
            };

            var bcp = CreateQueryImporter(source, destination, false);
            bcp.Source = source;
            bcp.Destination = destination;

            bcp.CreateDestinationTable();

            var guid = Guid.NewGuid();
            RegisterCancelable(guid, bcp);

            bcp.Execute();

            UnregisterCancelable(guid);
        }
Exemplo n.º 10
0
        protected void CreateTableForBulkCopy(SourceQueryParameters source, DestinationTableParameters destination, bool local)
        {
            #if !SKIPQUERIES

            var bcp = CreateQueryImporter(source, destination, local);
            bcp.CreateDestinationTable();

            #endif
        }
 public DestinationTableParameters(DestinationTableParameters old)
 {
     CopyMembers(old);
 }
Exemplo n.º 12
0
        private DestinationTableParameters CreateDestination(string schemaName, string tableName)
        {
            GetUniqueTableName(schemaName, ref tableName);

            var destination = new DestinationTableParameters();
            destination.Table = new Graywulf.Schema.Table()
            {
                Dataset = MyDBDatabaseInstance.GetDataset(),
                SchemaName = schemaName,
                TableName = tableName
            };
            destination.Operation = DestinationTableOperation.Create;

            return destination;
        }
Exemplo n.º 13
0
        protected void ExecuteSelectInto(SourceQueryParameters source, DestinationTableParameters destination)
        {
            string sql = String.Format(
                "SELECT __tablealias.* INTO [{0}].[{1}].[{2}] FROM ({3}) AS __tablealias",
                !String.IsNullOrWhiteSpace(destination.Table.DatabaseName) ? destination.Table.DatabaseName : destination.Table.Dataset.DatabaseName,
                destination.Table.SchemaName,
                destination.Table.TableName,
                source.Query);

            ExecuteLongCommandNonQuery(sql, source.Dataset.ConnectionString, source.Timeout);
        }
Exemplo n.º 14
0
        protected void ExecuteBulkCopy(SourceQueryParameters source, DestinationTableParameters destination, bool local, int timeout)
        {
            var bcp = CreateQueryImporter(source, destination, local);
            bcp.Destination.BulkInsertTimeout = timeout;

            var guid = Guid.NewGuid();
            RegisterCancelable(guid, bcp);

            #if !SKIPQUERIES
            bcp.Execute();
            #endif

            UnregisterCancelable(guid);
        }
Exemplo n.º 15
0
 private void InitializeMembers()
 {
     this.destination = null;
     this.rowsAffected = -1;
 }
Exemplo n.º 16
0
        public TableImporterBase(DestinationTableParameters destination)
        {
            InitializeMembers();

            this.destination = destination;
        }
Exemplo n.º 17
0
        protected IQueryImporter CreateQueryImporter(SourceQueryParameters source, DestinationTableParameters destination, bool local)
        {
            var desthost = GetHostnameFromSqlConnectionString(destination.Table.Dataset.ConnectionString);

            IQueryImporter qi;

            if (local)
            {
                qi = new QueryImporter();
            }
            else
            {
                qi = RemoteServiceHelper.CreateObject<IQueryImporter>(desthost);
            }

            qi.Source = source;
            qi.Destination = destination;

            return qi;
        }