private IComparable GetAggregationValue(IStreamDataReader streamDataReader, AggregationProjection aggregationProjection) { object result = streamDataReader.GetValue(aggregationProjection.GetIndex()); ShardingAssert.Else(null == result || result is IComparable, "Aggregation value must implements Comparable"); return((IComparable)result); }
public MemoryQueryResultRow(IStreamDataReader streamDataReader) { _streamDataReader = streamDataReader; var(data, columns) = Load(streamDataReader); _data = data; _columns = columns; }
private IDictionary <string, int> GetColumnLabelIndexMap(IStreamDataReader queryResult) { IDictionary <string, int> result = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase); for (int i = queryResult.ColumnCount - 1; i >= 0; i--) { result.Add(SqlUtil.GetExactlyValue(queryResult.GetColumnLabel(i)), i); } return(result); }
private List <object> GetGroupByValues(IStreamDataReader streamDataReader, ICollection <OrderByItem> groupByItems) { List <object> result = new List <object>(groupByItems.Count); foreach (var groupByItem in groupByItems) { result.Add(streamDataReader.GetValue(groupByItem.GetIndex())); } return(result); }
private IStreamDataReader Decorate(IStreamDataReader streamDataReader, ISqlCommandContext <ISqlCommand> sqlCommandContext) { IStreamDataReader result = null; foreach (var engineEntry in _engines) { if (engineEntry.Value is IResultDecoratorEngine <IBaseRule> resultDecoratorEngine) { var resultDecorator = resultDecoratorEngine.NewInstance(_databaseType, _schemaMetaData, engineEntry.Key, _properties, sqlCommandContext); result = null == result?resultDecorator.Decorate(streamDataReader, sqlCommandContext, _schemaMetaData) : resultDecorator.Decorate(result, sqlCommandContext, _schemaMetaData); } } return(result ?? streamDataReader); }
private List <bool> GetValueCaseSensitive(IStreamDataReader streamDataReader, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData) { List <bool> result = new List <bool>(streamDataReader.ColumnCount + 1) { false }; for (int columnIndex = 0; columnIndex < streamDataReader.ColumnCount; columnIndex++) { result.Add(GetValueCaseSensitiveFromTables(streamDataReader, selectCommandContext, schemaMetaData, columnIndex)); } return(result); }
/** * Process query results. * * @param queryResults query results * @param sqlStatementContext SQL statement context * @return merged result * @throws SQLException SQL exception */ public IStreamDataReader Process(List <IStreamDataReader> streamDataReaders, ISqlCommandContext <ISqlCommand> sqlCommandContext) { var mergedResult = Merge(streamDataReaders, sqlCommandContext); IStreamDataReader result = null; if (mergedResult != null) { result = Decorate(mergedResult, sqlCommandContext); } else { result = Decorate(streamDataReaders[0], sqlCommandContext); } return(result ?? new TransparentMergedDataReader(streamDataReaders[0])); }
private (object[] data, Dictionary <string, int> columns) Load(IStreamDataReader streamDataReader) { int columnCount = streamDataReader.ColumnCount; object[] result = new object[columnCount]; var columns = new Dictionary <string, int>(columnCount); for (int i = 0; i < columnCount; i++) { result[i] = streamDataReader.GetValue(i); var columnName = streamDataReader.GetColumnName(i); columns[columnName] = i; } return(result, columns); }
private bool GetValueCaseSensitiveFromTables(IStreamDataReader streamDataReader, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData, int columnIndex) { foreach (var simpleTableSegment in selectCommandContext.GetAllTables()) { String tableName = simpleTableSegment.GetTableName().GetIdentifier().GetValue(); TableMetaData tableMetaData = schemaMetaData.Get(tableName); IDictionary <String, ColumnMetaData> columns = tableMetaData.GetColumns(); String columnName = streamDataReader.GetColumnName(columnIndex); if (columns.ContainsKey(columnName)) { return(columns[columnName].CaseSensitive); } } return(false); }
private void Aggregate(SelectCommandContext selectCommandContext, IStreamDataReader streamDataReader, GroupByValue groupByValue, IDictionary <GroupByValue, IDictionary <AggregationProjection, IAggregationUnit> > aggregationMap) { var aggregationProjections = selectCommandContext.GetProjectionsContext().GetAggregationProjections(); foreach (var aggregationProjection in aggregationProjections) { List <IComparable> values = new List <IComparable>(2); if (aggregationProjection.GetDerivedAggregationProjections().IsEmpty()) { values.Add(GetAggregationValue(streamDataReader, aggregationProjection)); } else { foreach (var derived in aggregationProjection.GetDerivedAggregationProjections()) { values.Add(GetAggregationValue(streamDataReader, derived)); } } aggregationMap.Get(groupByValue).Get(aggregationProjection).Merge(values); } }
//private readonly IDictionary<string, int> _columnLabelAndIndexMap; public ShardingDataReader(List <DbDataReader> dataReaders, IStreamDataReader streamDataReader, DbCommand command, ExecutionContext executionContext) : base(dataReaders, command, executionContext) { _streamDataReader = streamDataReader; //_columnLabelAndIndexMap = CreateColumnLabelAndIndexMap(dataReaders[0]); }
public OrderByValue(IStreamDataReader streamDataReader, ICollection <OrderByItem> orderByItems, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData) { this._streamDataReader = streamDataReader; this.orderByItems = orderByItems; this.orderValuesCaseSensitive = GetOrderValuesCaseSensitive(selectCommandContext, schemaMetaData); }
public LimitDecoratorStreamDataReader(IStreamDataReader streamDataReader, PaginationContext pagination) : base(streamDataReader) { this.pagination = pagination; skipAll = SkipOffset(); }
public IStreamDataReader Decorate(IStreamDataReader streamDataReader, ISqlCommandContext <ISqlCommand> sqlCommandContext, SchemaMetaData schemaMetaData) { return(new TransparentMergedDataReader(streamDataReader)); }
protected DecoratorStreamDataReader(IStreamDataReader streamDataReader) { StreamDataReader = streamDataReader; }
public TransparentMergedDataReader(IStreamDataReader streamDataReader) { this._streamDataReader = streamDataReader; }
public ZipParser(string zipFilePath, ICollection <string> extensionsToRead, IStreamDataReader dataReader) { this.archive = ZipFile.OpenRead(zipFilePath); this.dataReader = dataReader; this.extensionsToRead = extensionsToRead; }
private void InitForFirstGroupByValue(SelectCommandContext selectCommandContext, IStreamDataReader streamDataReader, GroupByValue groupByValue, IDictionary <GroupByValue, MemoryQueryResultRow> dataMap, IDictionary <GroupByValue, IDictionary <AggregationProjection, IAggregationUnit> > aggregationMap) { if (!dataMap.ContainsKey(groupByValue)) { dataMap.Add(groupByValue, new MemoryQueryResultRow(streamDataReader)); } if (!aggregationMap.ContainsKey(groupByValue)) { var map = selectCommandContext.GetProjectionsContext().GetAggregationProjections().ToDictionary(o => o, o => AggregationUnitFactory.Create(o.GetAggregationType(), o is AggregationDistinctProjection)); aggregationMap.Add(groupByValue, map); } }
public GroupByValue(IStreamDataReader streamDataReader, ICollection <OrderByItem> groupByItems) { _groupValues = GetGroupByValues(streamDataReader, groupByItems); }
public void SetCurrentStreamDataReader(IStreamDataReader streamDataReader) { _current = streamDataReader; }
public ZipParser(string zipFilePath, ICollection<string> extensionsToRead, IStreamDataReader dataReader) { this.archive = ZipFile.OpenRead(zipFilePath); this.dataReader = dataReader; this.extensionsToRead = extensionsToRead; }
private IStreamDataReader Decorate(List <IStreamDataReader> streamDataReaders, SelectCommandContext selectCommandContext, IStreamDataReader mergedStreamDataReader) { var paginationContext = selectCommandContext.GetPaginationContext(); if (!paginationContext.HasPagination() || 1 == streamDataReaders.Count) { return(mergedStreamDataReader); } String trunkDatabaseName = DatabaseTypes.GetTrunkDatabaseType(_databaseType.GetName()).GetName(); if ("MySql".Equals(trunkDatabaseName) || "PostgreSQL".Equals(trunkDatabaseName)) { return(new LimitDecoratorStreamDataReader(mergedStreamDataReader, paginationContext)); } if ("Oracle".Equals(trunkDatabaseName)) { return(new RowNumberDecoratorStreamDataReader(mergedStreamDataReader, paginationContext)); } if ("SQLServer".Equals(trunkDatabaseName)) { return(new TopAndRowNumberDecoratorStreamDataReader(mergedStreamDataReader, paginationContext)); } return(mergedStreamDataReader); }