Esempio n. 1
0
        public override Task <SqlObject> GetValueAsync(long row, int column)
        {
            int tableNum    = JoinedTableInfo.GetTableOffset(column);
            var parentTable = Tables[tableNum];
            var resolvedRow = ResolveTableRow(row, tableNum);

            return(parentTable.GetValueAsync(resolvedRow, JoinedTableInfo.GetColumnOffset(column)));
        }
Esempio n. 2
0
        protected override TableIndex GetColumnIndex(int column, int originalColumn, ITable ancestor)
        {
            // First check if the given SelectableScheme is in the column_scheme array
            var scheme = Indexes[column];

            if (scheme != null)
            {
                if (ancestor == this)
                {
                    return(scheme);
                }

                return(scheme.Subset(ancestor, originalColumn));
            }

            // If it isn't then we need to calculate it
            TableIndex index;

            // Optimization: The table may be naturally ordered by a column.  If it
            // is we don't try to generate an ordered set.
            if (SortColumn != -1 &&
                SortColumn == column)
            {
                var columnName = JoinedTableInfo.Columns[column].ColumnName;
                var indexInfo  = new IndexInfo($"#COLIDX[{column}]", TableInfo.TableName, columnName);
                index = new InsertSearchIndex(indexInfo, this, CalculateTableRows());

                Indexes[column] = index;
                if (ancestor != this)
                {
                    index = index.Subset(ancestor, originalColumn);
                }
            }
            else
            {
                // Otherwise we must generate the ordered set from the information in
                // a parent index.
                var parentTable = Tables[JoinedTableInfo.GetTableOffset(column)];
                index = parentTable.GetColumnIndex(JoinedTableInfo.GetColumnOffset(column), originalColumn, ancestor);
                if (ancestor == this)
                {
                    Indexes[column] = index;
                }
            }

            return(index);
        }
Esempio n. 3
0
        protected override IEnumerable <long> ResolveRows(int column, IEnumerable <long> rowSet, ITable ancestor)
        {
            if (ancestor == this)
            {
                return(new BigArray <long>(0));
            }

            int tableNum    = JoinedTableInfo.GetTableOffset(column);
            var parentTable = Tables[tableNum];

            if (!(parentTable is IVirtualTable))
            {
                throw new InvalidOperationException();
            }

            // Resolve the rows into the parents indices
            var rows = ResolveTableRows(rowSet, tableNum);

            return(parentTable.ResolveRows(JoinedTableInfo.GetColumnOffset(column), rows, ancestor));
        }
Esempio n. 4
0
        public override Task <SqlObject> GetValueAsync(long row, int column)
        {
            int tableNum    = JoinedTableInfo.GetTableOffset(column);
            var parentTable = Tables[tableNum];

            if (row >= outerRowCount)
            {
                row = Rows[tableNum][row - outerRowCount];

                return(parentTable.GetValueAsync(row, JoinedTableInfo.GetColumnOffset(column)));
            }

            if (outerRows[tableNum] == null)
            {
                // Special case, handling outer entries (NULL)
                return(Task.FromResult(new SqlObject(TableInfo.Columns[column].ColumnType, null)));
            }

            row = outerRows[tableNum][row];

            return(parentTable.GetValueAsync(row, JoinedTableInfo.GetColumnOffset(column)));
        }