Beispiel #1
0
        public static TreeDictionary <int, Page> DeepCopy(this TreeDictionary <int, Page> item)
        {
            var result = new TreeDictionary <int, Page>();

            item.ForEach(i => result.Add(i.Key, i.Value));
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Returns all rows from this tree in this container
        /// </summary>
        /// <param name="schema">The table schema to convert the rows to</param>
        /// <param name="dirtyRead">true if unprotected read, otherwise false</param>
        /// <returns>A list of rows</returns>
        public RowStruct[] GetAllRows(TableSchema2 schema, bool dirtyRead)
        {
            RowStruct[] result;
            int         totalRows = 0;

            lock (_treeLock)
            {
                _tree.ForEach(item =>
                {
                    totalRows += item.Value.TotalRows;
                });
            }

            result = new RowStruct[totalRows];
            var resultSpan = new Span <RowStruct>(result);

            int i = 0;

            if (dirtyRead)
            {
                TreeDictionary <int, Page> item = _tree.DeepCopy();

                foreach (var x in item)
                {
                    RowStruct[] rows = x.Value.GetRows(schema);
                    i += rows.Length;
                    Array.Copy(rows, 0, result, i, rows.Length);
                }
            }
            else
            {
                lock (_treeLock)
                {
                    foreach (var item in _tree)
                    {
                        RowStruct[] rows = item.Value.GetRows(schema);
                        i += rows.Length;
                        Array.Copy(rows, 0, result, i, rows.Length);
                    }
                }
            }

            return(result);
        }