Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool BulkCopy(MonetBulkCopyModel model)
        {
            try
            {
                var connectionString = model.ToString();
                var stopWatch        = new Stopwatch();
                var data             = model.Rows.Lz4Decompress().ToStrings();
                var fileName         = IoHelper.GetTmpRandomFileName(_serverConfiguration.TempDir);

                stopWatch.Start();

                MonetDbHelper.DumpBinary(data, fileName);

                if (IoHelper.IsNotEmpty(fileName))
                {
                    MonetDbHelper.BinaryCopy(connectionString, model.SchemaName, model.TableName, data.Length, fileName);
                }

                IoHelper.RemoveFile(fileName);

                stopWatch.Stop();

                LoggerHelper.Write(LoggerOption.Info, "Client#{0} -> Loaded '{1}.{2}.{3}'-{4} rows({5} ms)", CurrentClient.ClientId, model.Database, model.SchemaName, model.TableName, data.Length, stopWatch.ElapsedMilliseconds);

                return(true);
            }
            catch (Exception exception)
            {
                LoggerHelper.Write(LoggerOption.Error, exception.Message);

                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        /// <param name="monetCredentialsModel"></param>
        /// <param name="schemaName"></param>
        /// <param name="tableName"></param>
        /// <param name="columns"></param>
        /// <param name="rows"></param>
        /// <param name="batchSize"></param>
        public static bool BulkCopy(MonetDbConnectionInfo monetCredentialsModel, string schemaName, string tableName, TableColumnInfo[] columns, string[] rows, int batchSize)
        {
            var serviceClient = GetFactory(monetCredentialsModel.Host);
            var model         = new MonetBulkCopyModel(monetCredentialsModel)
            {
                SchemaName = schemaName,
                TableName  = tableName,
                Columns    = columns,
                BatchSize  = batchSize
            };
            var rowsBytes = rows.ToBytes();

            model.Rows = rowsBytes.Lz4Compress();

            return(serviceClient.ServiceProxy.BulkCopy(model));
        }