Example #1
0
        public object Clone()
        {
            RecordRow row = new RecordRow(this._columns);

            row._objects = (ClusteredArray <object>) this._objects.Clone();
            return(row);
        }
Example #2
0
 public bool MoveNext()
 {
     if (_recordSet != null)
     {
         if (_recordSet.ContainsRow(++_rowId))
         {
             _current = _recordSet.GetRow(_rowId);
             _recordSet.RemoveRow(_rowId);
             return(true);
         }
     }
     return(false);
 }
Example #3
0
        private void SetCurrentEnumerator() //for each move next,call pick one of partition record set.
        {
            if (_partitionRecordSets.Count == 0)
            {
                return;
            }
            bool hasNext = false;

            do
            {
                try
                {
                    if (_partitionRecordSets.Count <= _counter)
                    {
                        throw new InvalidReaderException("Data reader has lost its state");
                    }

                    _currentRecordSet = _partitionRecordSets[_counter];

                    hasNext = _currentRecordSet.MoveNext();
                }
                catch (InvalidReaderException e)
                {
                    this.Dispose();
                    throw;
                }
                catch (Exception e)
                {
                    throw;
                }

                if (hasNext)
                {
                    _current = _currentRecordSet.Current;
                }
                else
                {
                    _partitionRecordSets.Remove(_currentRecordSet);
                    RemoveFromValidReaders(_currentRecordSet);
                }
                _counter++;
                if (_counter >= _partitionRecordSets.Count)
                {
                    _counter = 0;
                }
            } while (!hasNext && _partitionRecordSets.Count > 0);
            _next = hasNext;
        }
Example #4
0
        public void Merge(RecordRow row)
        {
            for (int i = 0; i < this._columns.Count; i++)
            {
                if (this._columns[i].ColumnType == ColumnType.AggregateResultColumn)
                {
                    switch (this._columns[i].AggregateFunctionType)
                    {
                    case AggregateFunctionType.SUM:
                        decimal a;
                        decimal b;

                        object thisVal  = this._objects[i];
                        object otherVal = row._objects[i];

                        decimal?sum = null;

                        if (thisVal == null && otherVal != null)
                        {
                            sum = (decimal)otherVal;
                        }
                        else if (thisVal != null && otherVal == null)
                        {
                            sum = (decimal)thisVal;
                        }
                        else if (thisVal != null && otherVal != null)
                        {
                            a   = (decimal)thisVal;
                            b   = (decimal)otherVal;
                            sum = a + b;
                        }

                        if (sum != null)
                        {
                            this._objects[i] = sum;
                        }
                        else
                        {
                            this._objects[i] = null;
                        }
                        break;

                    case AggregateFunctionType.COUNT:
                        a = (decimal)this._objects[i];
                        b = (decimal)row._objects[i];
                        decimal count = a + b;

                        this._objects[i] = count;
                        break;

                    case AggregateFunctionType.MIN:
                        IComparable thisValue  = (IComparable)this._objects[i];
                        IComparable otherValue = (IComparable)row._objects[i];
                        IComparable min        = thisValue;

                        if (thisValue == null && otherValue != null)
                        {
                            min = otherValue;
                        }
                        else if (thisValue != null && otherValue == null)
                        {
                            min = thisValue;
                        }
                        else if (thisValue == null && otherValue == null)
                        {
                            min = null;
                        }
                        else if (otherValue.CompareTo(thisValue) < 0)
                        {
                            min = otherValue;
                        }

                        //this.AggregateFunctionResult = min;
                        this._objects[i] = min;
                        break;

                    case AggregateFunctionType.MAX:
                        thisValue  = (IComparable)this._objects[i];
                        otherValue = (IComparable)row._objects[i];
                        IComparable max = thisValue;

                        if (thisValue == null && otherValue != null)
                        {
                            max = otherValue;
                        }
                        else if (thisValue != null && otherValue == null)
                        {
                            max = thisValue;
                        }
                        else if (thisValue == null && otherValue == null)
                        {
                            max = null;
                        }
                        else if (otherValue.CompareTo(thisValue) > 0)
                        {
                            max = otherValue;
                        }

                        //this.AggregateFunctionResult = max;
                        this._objects[i] = max;
                        break;

                    case AggregateFunctionType.AVG:
                        thisVal  = this._objects[i];
                        otherVal = row._objects[i];

                        AverageResult avg = null;
                        if (thisVal == null && otherVal != null)
                        {
                            avg = (AverageResult)otherVal;
                        }
                        else if (thisVal != null && otherVal == null)
                        {
                            avg = (AverageResult)thisVal;
                        }
                        else if (thisVal != null && otherVal != null)
                        {
                            AverageResult thisResult  = (AverageResult)thisVal;
                            AverageResult otherResult = (AverageResult)otherVal;

                            avg       = new AverageResult();
                            avg.Sum   = thisResult.Sum + otherResult.Sum;
                            avg.Count = thisResult.Count + otherResult.Count;
                        }

                        if (avg != null)
                        {
                            this._objects[i] = avg;
                        }
                        else
                        {
                            this._objects[i] = null;
                        }
                        break;
                    }
                }
            }
        }
Example #5
0
        public int CompareOrder(RecordRow row, List <OrderByArgument> orderBy)
        {
            int result = 0;

            foreach (OrderByArgument oba in orderBy)
            {
                switch (_columns[oba.AttributeName].DataType)
                {
                case ColumnDataType.Bool:
                    result = ((bool)this.GetColumnValue(oba.AttributeName)).CompareTo(((bool)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Byte:
                    result = ((byte)this.GetColumnValue(oba.AttributeName)).CompareTo(((byte)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Char:
                    result = ((char)this.GetColumnValue(oba.AttributeName)).CompareTo(((char)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.DateTime:
                    result = ((DateTime)this.GetColumnValue(oba.AttributeName)).CompareTo(((DateTime)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Decimal:
                    result = ((decimal)this.GetColumnValue(oba.AttributeName)).CompareTo(((decimal)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Double:
                    result = ((double)this.GetColumnValue(oba.AttributeName)).CompareTo(((double)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Float:
                    result = ((float)this.GetColumnValue(oba.AttributeName)).CompareTo(((float)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Int16:
                    result = ((Int16)this.GetColumnValue(oba.AttributeName)).CompareTo(((Int16)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Int32:
                    result = ((Int32)this.GetColumnValue(oba.AttributeName)).CompareTo(((Int32)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.Int64:
                    result = ((Int64)this.GetColumnValue(oba.AttributeName)).CompareTo(((Int64)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.SByte:
                    result = ((sbyte)this.GetColumnValue(oba.AttributeName)).CompareTo(((sbyte)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.String:
                    result = ((string)this.GetColumnValue(oba.AttributeName)).CompareTo(((string)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.UInt16:
                    result = ((UInt16)this.GetColumnValue(oba.AttributeName)).CompareTo(((UInt16)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.UInt32:
                    result = ((UInt32)this.GetColumnValue(oba.AttributeName)).CompareTo(((UInt32)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.UInt64:
                    result = ((UInt64)this.GetColumnValue(oba.AttributeName)).CompareTo(((UInt64)row.GetColumnValue(oba.AttributeName)));
                    break;

                case ColumnDataType.CompressedValueEntry:
                case ColumnDataType.Object:
                    break;
                }

                if (result != 0)
                {
                    if (oba.Order == Order.DESC)
                    {
                        result = -result;
                    }
                    break;
                }
            }
            return(result);
        }
Example #6
0
 public void Add(RecordRow row)
 {
     _rows.Add(++_lastRow, row);
 }
Example #7
0
 public void Dispose()
 {
     _recordSet = null;
     _current   = null;
 }
Example #8
0
 /// <summary>
 /// Adds row to current <see cref="Alachisoft.NCache.Common.DataStructures.RecorSet"/>
 /// </summary>
 /// <param name="row"><see cref="Alachisoft.NCache.Common.DataStructures.RecordRow"/> to be added in current <see cref="Alachisoft.NCache.Common.DataStructures.RecorSet"/></param>
 public void AddRow(RecordRow row)
 {
     _rows.Add(row);
 }
Example #9
0
        /// <summary>
        /// Returns new <see cref="Alachisoft.NCache.Common.DataStructures.RecordRow"/> with column matadata of current <see cref="Alachisoft.NCache.Common.DataStructures.RecordSet"/>
        /// </summary>
        /// <returns>Newly created <see cref="Alachisoft.NCache.Common.DataStructures.RecordRow"/></returns>
        public RecordRow CreateRow()
        {
            RecordRow row = new RecordRow(_columns);

            return(row);
        }