예제 #1
0
        protected override RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
        {
            var rows = this.Select(x => x.RowId.RowNumber).ToArray();

            rootInfo.Add(this, rows);
            return(rootInfo);
        }
예제 #2
0
        private RawTableInfo GetRawTableInfo(RawTableInfo info, IEnumerable <int> rows)
        {
            if (this is IRootTable)
            {
                info.Add((IRootTable)this, CalculateRowReferenceList());
            }
            else
            {
                for (int i = 0; i < referenceList.Length; ++i)
                {
                    IEnumerable <int> newRowSet = new List <int>(rows);

                    // Resolve the rows into the parents indices.
                    newRowSet = ResolveRowsForTable(newRowSet, i);

                    var table = referenceList[i];
                    if (table is IRootTable)
                    {
                        info.Add((IRootTable)table, newRowSet.ToArray());
                    }
                    else if (table is JoinedTable)
                    {
                        ((JoinedTable)table).GetRawTableInfo(info, newRowSet);
                    }
                }
            }

            return(info);
        }
예제 #3
0
        protected override RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
        {
            var rows = this.Select(row => row.RowId.RowNumber).ToList();

            rootInfo.Add(this, rows);
            return(rootInfo);
        }
예제 #4
0
        protected override RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
        {
            var tableRows = rows.Select((item, index) => (long)index).ToBigList();

            rootInfo.Add(this, tableRows);

            return(rootInfo);
        }
예제 #5
0
        internal static RawTableInfo GetRawTableInfo(this IRootTable table, RawTableInfo rootInfo)
        {
            var rows = table.Select(x => x.Number).ToBigList();

            rootInfo.Add(table, rows);

            return(rootInfo);
        }
예제 #6
0
        internal static RawTableInfo GetRawTableInfo(this ITable table, RawTableInfo info)
        {
            if (table is IQueryTable)
            {
                return(((IQueryTable)table).GetRawTableInfo(info));
            }

            throw new NotSupportedException();
        }
예제 #7
0
        protected override RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
        {
            var allList = new List <int>();
            int size    = RowCount;

            for (int i = 0; i < size; ++i)
            {
                allList.Add(i);
            }

            return(GetRawTableInfo(rootInfo, allList));
        }
예제 #8
0
        internal static RawTableInfo GetRawTableInfo(this ITable table, RawTableInfo rootInfo)
        {
            if (table is IVirtualTable)
            {
                return(((IVirtualTable)table).GetRawTableInfo(rootInfo));
            }
            if (table is IRootTable)
            {
                return(((IRootTable)table).GetRawTableInfo(rootInfo));
            }

            throw new NotSupportedException();
        }
예제 #9
0
 protected override RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
 {
     return(Parent.GetRawTableInfo(rootInfo));
 }
예제 #10
0
파일: Table.cs 프로젝트: meikeric/deveeldb
 RawTableInfo IQueryTable.GetRawTableInfo(RawTableInfo rootInfo)
 {
     return(GetRawTableInfo(rootInfo));
 }
예제 #11
0
파일: Table.cs 프로젝트: meikeric/deveeldb
 protected abstract RawTableInfo GetRawTableInfo(RawTableInfo rootInfo);
예제 #12
0
        public RawTableInfo Union(RawTableInfo info)
        {
            // Number of Table 'columns'

            int colCount = tableItems.Count;

            var merge1 = GetSortedItems();
            var merge2 = info.GetSortedItems();

            int size1 = -1;
            int size2 = -1;

            // First check number of tables in each merge is correct.

            if (merge1.Length != merge2.Length)
            {
                throw new InvalidOperationException("Incorrect format in table union");
            }

            // Check each table in the merge1 set has identical length row_sets

            for (int i = 0; i < merge1.Length; ++i)
            {
                if (size1 == -1)
                {
                    size1 = merge1[i].Rows.Count;
                }
                else
                {
                    if (size1 != merge1[i].Rows.Count)
                    {
                        throw new InvalidOperationException("Incorrect format in table union");
                    }
                }
            }

            // Check each table in the merge2 set has identical length row_sets

            for (int i = 0; i < merge2.Length; ++i)
            {
                // Check the tables in merge2 are identical to the tables in merge1
                if (!merge2[i].Table.TypeEquals(merge1[i].Table))
                {
                    throw new InvalidOperationException("Incorrect format in table union");
                }

                if (size2 == -1)
                {
                    size2 = merge2[i].Rows.Count;
                }
                else
                {
                    if (size2 != merge2[i].Rows.Count)
                    {
                        throw new InvalidOperationException("Incorrect format in table union");
                    }
                }
            }

            // If size1 or size2 are -1 then we have a corrupt table.  (It will be
            // 0 for an empty table).

            if (size1 == -1 || size2 == -1)
            {
                throw new InvalidOperationException("Incorrect format in table union");
            }

            // We don't need information in 'raw_info' vector anymore so clear it.
            // This may help garbage collection.

            var resultItems = new List <RawTableItem>();

            // Merge the two together into a new list of RawRowElement[]

            int mergeSize  = size1 + size2;
            var elems      = new RawRowItem[mergeSize];
            int elemsIndex = 0;

            for (int i = 0; i < size1; ++i)
            {
                var itemRows = new int[colCount];

                for (int n = 0; n < colCount; ++n)
                {
                    itemRows[n] = merge1[n].Rows[i];
                }

                elems[elemsIndex] = new RawRowItem(itemRows);
                ++elemsIndex;
            }

            for (int i = 0; i < size2; ++i)
            {
                var itemRows = new int[colCount];

                for (int n = 0; n < colCount; ++n)
                {
                    itemRows[n] = merge2[n].Rows[i];
                }

                elems[elemsIndex] = new RawRowItem(itemRows);
                ++elemsIndex;
            }

            // Now sort the row elements into order.

            Array.Sort(elems);

            // Remove any duplicate rows.

            for (int i = 0; i < colCount; ++i)
            {
                merge1[i].Rows.Clear();
            }

            RawRowItem previous = null;

            for (int n = 0; n < mergeSize; ++n)
            {
                var current = elems[n];

                // Check that the current element in the set is not a duplicate of the
                // previous.

                if (previous == null || previous.CompareTo(current) != 0)
                {
                    for (int i = 0; i < colCount; ++i)
                    {
                        merge1[i].Rows.Add(current.RowValues[i]);
                    }
                    previous = current;
                }
            }

            for (int i = 0; i < colCount; ++i)
            {
                resultItems.Add(merge1[i]);
            }

            return(new RawTableInfo(resultItems.ToArray()));
        }