コード例 #1
0
        private int GetPrefetchThreads(SFBaseResultSet resultSet)
        {
            Dictionary <SFSessionParameter, object> sessionParameters = resultSet.sfStatement.SfSession.ParameterMap;
            String val = (String)sessionParameters[SFSessionParameter.CLIENT_PREFETCH_THREADS];

            return(Int32.Parse(val));
        }
コード例 #2
0
        public SFBlockingChunkDownloaderV3(int colCount,
                                           List <ExecResponseChunk> chunkInfos, string qrmk,
                                           Dictionary <string, string> chunkHeaders,
                                           CancellationToken cancellationToken,
                                           SFBaseResultSet ResultSet)
        {
            this.qrmk                     = qrmk;
            this.chunkHeaders             = chunkHeaders;
            this.nextChunkToDownloadIndex = 0;
            this.ResultSet                = ResultSet;
            this.prefetchSlot             = Math.Min(chunkInfos.Count, GetPrefetchThreads(ResultSet));
            this.chunkInfos               = chunkInfos;
            this.nextChunkToConsumeIndex  = 0;
            this.taskQueues               = new List <Task <IResultChunk> >();

            for (int i = 0; i < prefetchSlot; i++)
            {
                SFReusableChunk reusableChunk = new SFReusableChunk(colCount);
                reusableChunk.Reset(chunkInfos[nextChunkToDownloadIndex], nextChunkToDownloadIndex);
                chunkDatas.Add(reusableChunk);

                taskQueues.Add(DownloadChunkAsync(new DownloadContextV3()
                {
                    chunk             = reusableChunk,
                    qrmk              = this.qrmk,
                    chunkHeaders      = this.chunkHeaders,
                    cancellationToken = this.externalCancellationToken
                }));

                nextChunkToDownloadIndex++;
            }
        }
コード例 #3
0
        internal static int CalculateUpdateCount(this SFBaseResultSet resultSet)
        {
            SFResultSetMetaData metaData      = resultSet.sfResultSetMetaData;
            SFStatementType     statementType = metaData.statementType;

            long updateCount = 0;

            switch (statementType)
            {
            case SFStatementType.INSERT:
            case SFStatementType.UPDATE:
            case SFStatementType.DELETE:
            case SFStatementType.MERGE:
            case SFStatementType.MULTI_INSERT:
                resultSet.Next();
                for (int i = 0; i < resultSet.columnCount; i++)
                {
                    updateCount += resultSet.GetValue <long>(i);
                }

                break;

            case SFStatementType.COPY:
                resultSet.Next();
                var index = resultSet.sfResultSetMetaData.getColumnIndexByName("rows_loaded");
                if (index >= 0)
                {
                    updateCount = resultSet.GetValue <long>(index);
                }
                break;

            case SFStatementType.SELECT:
                updateCount = -1;
                break;

            default:
                updateCount = 0;
                break;
            }

            if (updateCount > int.MaxValue)
            {
                return(-1);
            }

            return((int)updateCount);
        }
コード例 #4
0
 public static IChunkDownloader GetDownloader(QueryExecResponseData responseData,
                                              SFBaseResultSet resultSet,
                                              CancellationToken cancellationToken)
 {
     if (SFConfiguration.Instance().UseV2ChunkDownloader)
     {
         return(new SFChunkDownloaderV2(responseData.rowType.Count,
                                        responseData.chunks,
                                        responseData.qrmk,
                                        responseData.chunkHeaders,
                                        cancellationToken));
     }
     else
     {
         return(new SFBlockingChunkDownloader(responseData.rowType.Count,
                                              responseData.chunks,
                                              responseData.qrmk,
                                              responseData.chunkHeaders,
                                              cancellationToken,
                                              resultSet));
     }
 }
コード例 #5
0
        public static IChunkDownloader GetDownloader(QueryExecResponseData responseData,
                                                     SFBaseResultSet resultSet,
                                                     CancellationToken cancellationToken)
        {
            int ChunkDownloaderVersion = SFConfiguration.Instance().ChunkDownloaderVersion;

            if (SFConfiguration.Instance().UseV2ChunkDownloader)
            {
                ChunkDownloaderVersion = 2;
            }

            switch (ChunkDownloaderVersion)
            {
            case 1:
                return(new SFBlockingChunkDownloader(responseData.rowType.Count,
                                                     responseData.chunks,
                                                     responseData.qrmk,
                                                     responseData.chunkHeaders,
                                                     cancellationToken,
                                                     resultSet));

            case 2:
                return(new SFChunkDownloaderV2(responseData.rowType.Count,
                                               responseData.chunks,
                                               responseData.qrmk,
                                               responseData.chunkHeaders,
                                               cancellationToken,
                                               resultSet.sfStatement.SfSession.InsecureMode));

            default:
                return(new SFBlockingChunkDownloaderV3(responseData.rowType.Count,
                                                       responseData.chunks,
                                                       responseData.qrmk,
                                                       responseData.chunkHeaders,
                                                       cancellationToken,
                                                       resultSet));
            }
        }
コード例 #6
0
        public SFBlockingChunkDownloader(int colCount,
                                         List <ExecResponseChunk> chunkInfos, string qrmk,
                                         Dictionary <string, string> chunkHeaders,
                                         CancellationToken cancellationToken,
                                         SFBaseResultSet ResultSet)
        {
            this.qrmk                     = qrmk;
            this.chunkHeaders             = chunkHeaders;
            this.chunks                   = new List <SFResultChunk>();
            this.nextChunkToDownloadIndex = 0;
            this.ResultSet                = ResultSet;
            this.prefetchThreads          = GetPrefetchThreads(ResultSet);

            var idx = 0;

            foreach (ExecResponseChunk chunkInfo in chunkInfos)
            {
                this.chunks.Add(new SFResultChunk(chunkInfo.url, chunkInfo.rowCount, colCount, idx++));
            }
            logger.Info($"Total chunk number: {chunks.Count}");

            FillDownloads();
        }