コード例 #1
0
        public async IAsyncEnumerable <SyncTable> GetTableAsync(string tableName, string schemaName, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null)
        {
            if (this.SanitizedSchema == null)
            {
                throw new NullReferenceException("Batch info schema should not be null");
            }

            var tableInfo = new BatchPartTableInfo(tableName, schemaName);

            if (InMemory)
            {
                this.SerializerFactoryKey = null;

                if (this.InMemoryData != null && this.InMemoryData.HasTables)
                {
                    yield return(this.InMemoryData.Tables[tableName, schemaName]);
                }
            }
            else
            {
                this.SerializerFactoryKey = serializerFactory.Key;

                var bpiTables = BatchPartsInfo.Where(bpi => bpi.RowsCount > 0 && bpi.Tables.Any(t => t.EqualsByName(tableInfo))).OrderBy(t => t.Index);

                if (bpiTables != null)
                {
                    foreach (var batchPartinInfo in bpiTables)
                    {
                        // load only if not already loaded in memory
                        if (batchPartinInfo.Data == null)
                        {
                            await batchPartinInfo.LoadBatchAsync(this.SanitizedSchema, GetDirectoryFullPath(), serializerFactory, orchestrator).ConfigureAwait(false);
                        }

                        // Get the table from the batchPartInfo
                        // generate a tmp SyncTable for
                        var batchTable = batchPartinInfo.Data.Tables.FirstOrDefault(bt => bt.EqualsByName(new SyncTable(tableName, schemaName)));

                        if (batchTable != null)
                        {
                            yield return(batchTable);

                            // We may need this same BatchPartInfo for another table,
                            // but we dispose it anyway, because memory can be quickly a bottleneck
                            // if batchpartinfos are resident in memory
                            batchPartinInfo.Data.Dispose();
                            batchPartinInfo.Data = null;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public async IAsyncEnumerable <SyncTable> GetTableAsync(string tableName, string schemaName, BaseOrchestrator orchestrator = null)
        {
            if (this.SanitizedSchema == null)
            {
                throw new NullReferenceException("Batch info schema should not be null");
            }

            var tableInfo = new BatchPartTableInfo(tableName, schemaName);

            if (InMemory)
            {
                if (this.InMemoryData != null && this.InMemoryData.HasTables)
                {
                    yield return(this.InMemoryData.Tables[tableName, schemaName]);
                }
            }
            else
            {
                var bpiTables = BatchPartsInfo.Where(bpi => bpi.RowsCount > 0 && bpi.Tables.Any(t => t.EqualsByName(tableInfo))).OrderBy(t => t.Index);

                if (bpiTables != null)
                {
                    foreach (var batchPartinInfo in bpiTables)
                    {
                        // load only if not already loaded in memory
                        if (batchPartinInfo.Data == null)
                        {
                            await batchPartinInfo.LoadBatchAsync(this.SanitizedSchema, GetDirectoryFullPath(), orchestrator).ConfigureAwait(false);
                        }

                        // Get the table from the batchPartInfo
                        // generate a tmp SyncTable for
                        var batchTable = batchPartinInfo.Data.Tables.FirstOrDefault(bt => bt.EqualsByName(new SyncTable(tableName, schemaName)));

                        if (batchTable != null)
                        {
                            yield return(batchTable);

                            // once loaded and yield, can dispose
                            batchPartinInfo.Data.Dispose();
                            batchPartinInfo.Data = null;
                        }
                    }
                }
            }
        }