public DocumentDataContainerEnumerator_IndexScan(
            int untrimmedCount,
            DriverRowData rowData,
            DocumentDataContainer dataContainer,
            IReadOnlyList<FieldMetadata> fields,
            int countOfMainFields,
            SortIndex sortIndex,
            bool descending)
            : base(untrimmedCount, rowData, dataContainer, fields, countOfMainFields)
        {
            if (sortIndex == null)
            {
                throw new ArgumentNullException("sortIndex");
            }

            // note that we ignore value of sortIndex.IsValid here
            // that's because invalidation of index only happens when the data is stale
            // we only check state of an index and optionally update it in the beginning of processing pipeline
            if (sortIndex.OrderData == null || sortIndex.OrderData.Length > untrimmedCount)
            {
                throw new ArgumentException("Index on column is in invalid state", "sortIndex");
            }

            m_sortIndex = sortIndex;
            m_descending = descending;
            PositionInIndex = descending ? m_sortIndex.ValidDocCount : -1;

            ReadStructureAndTakeLocks();
        }
コード例 #2
0
 /// <summary>
 /// Ctr.
 /// </summary>
 public DriverChangeBuffer(int targetEntity, int ordinalOfPrimaryKey, FieldMetadata[] fields)
 {
     Fields = fields;
     TargetEntity = targetEntity;
     Data = new DriverRowData(fields.Select(x => x.DbType).ToArray());
     OrdinalOfPrimaryKey = ordinalOfPrimaryKey;
 }
 public DocumentDataContainerEnumerator_FullScan(
     int untrimmedCount,
     DriverRowData rowData,
     DocumentDataContainer dataContainer,
     IReadOnlyList<FieldMetadata> fields,
     int countOfMainFields)
     : base(untrimmedCount, rowData, dataContainer, fields, countOfMainFields)
 {
     ReadStructureAndTakeLocks();
 }
        public DocumentDataContainerEnumerator_BulkPkScan(
            int untrimmedCount, DriverRowData rowData, DocumentDataContainer dataContainer, List<FieldMetadata> fields, IDriverDataEnumerator inputDataEnumerator)
            : base(untrimmedCount, rowData, dataContainer, fields, fields.Count - 1)
        {
            if (inputDataEnumerator == null)
            {
                throw new ArgumentNullException("inputDataEnumerator");
            }

            m_inputEnumerator = inputDataEnumerator;

            ReadStructureAndTakeLocks();
        }
コード例 #5
0
        /// <summary>
        /// Ctr.
        /// </summary>
        /// <param name="countToRead">Number of <see cref="RowData"/> items to read, can be zero</param>
        /// <param name="fieldTypes">Expected field types</param>
        /// <param name="stream">Incoming data stream</param>
        /// <param name="driverRowData">Buffer to put field values into, after each call to <see cref="MoveNext"/></param>
        public InputDataStreamEnumerator(int countToRead, DbType[] fieldTypes, Stream stream, DriverRowData driverRowData)
        {
            if (countToRead < 0)
            {
                throw new ArgumentOutOfRangeException("countToRead", countToRead, "Count may not be negative");
            }

            if (fieldTypes == null)
            {
                throw new ArgumentNullException("fieldTypes");
            }

            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (driverRowData == null)
            {
                throw new ArgumentNullException("driverRowData");
            }

            if (fieldTypes.Length == 0)
            {
                throw new ArgumentException("Count of fields in client row buffer must be greater than zero, first column must contain primary key value");
            }

            if (driverRowData.FieldTypes.Length != fieldTypes.Length)
            {
                throw new ArgumentException(string.Format("Count of fields in client row buffer ({0}) must be equal to count of fields in driver buffer ({1})"
                    , fieldTypes.Length, driverRowData.FieldTypes.Length));
            }

            for (var ordinal = 0; ordinal < driverRowData.FieldTypes.Length; ordinal++)
            {
                if (driverRowData.FieldTypes[ordinal] != fieldTypes[ordinal])
                {
                    throw new ArgumentException(string.Format("Field type mismatch at ordinal {0}. Client type: {1}, driver type: {2}",
                        ordinal, fieldTypes[ordinal], m_driverRowData.FieldTypes[ordinal]));
                }
            }

            m_countToRead = countToRead;
            m_driverRowData = driverRowData;
            m_reader = new BinaryReader(stream, Encoding.UTF8, true);
            m_readerBuffer = new RowData(fieldTypes);
            m_pkFieldType = m_readerBuffer.FieldRepresentationTypes[0];
        }
コード例 #6
0
        public void AttachDriverOutputBufferAndInputParameters(DriverRowData driverOutputBuffer, ParsedRequest parsedRequest)
        {
            if (driverOutputBuffer == null)
            {
                throw new ArgumentNullException("driverOutputBuffer");
            }

            if (DriverOutputBuffer != null)
            {
                throw new InvalidOperationException("Cannot reassign driver output buffer");
            }

            DriverOutputBuffer = driverOutputBuffer;
            ClauseEvaluationContext.InputRow                   = driverOutputBuffer;
            ClauseEvaluationContext.InputParametersRow         = parsedRequest.Params.InputValues;
            ClauseEvaluationContext.InputParametersCollections = parsedRequest.Params.InputCollections;
        }
コード例 #7
0
        protected DocumentDataContainerEnumeratorBase(
            int untrimmedCount,
            DriverRowData rowData,
            DocumentDataContainer dataContainer,
            IReadOnlyList<FieldMetadata> fields,
            int countOfMainFields)
        {
            if (untrimmedCount < 0)
            {
                throw new ArgumentOutOfRangeException("untrimmedCount", untrimmedCount, "Untrimmed count cannot be negative");
            }

            if (rowData == null)
            {
                throw new ArgumentNullException("rowData");
            }

            if (dataContainer == null)
            {
                throw new ArgumentNullException("dataContainer");
            }

            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }

            if (CountOfMainFields < 0 || CountOfMainFields > fields.Count)
            {
                throw new ArgumentOutOfRangeException("countOfMainFields", countOfMainFields, "Invalid number of first-priority fetching fields");
            }

            Position = -1;
            UntrimmedCount = untrimmedCount;
            RowData = rowData;
            DataContainer = dataContainer;
            Fields = fields;
            CountOfMainFields = countOfMainFields;

            RowDataOrdinalToColumnStoreIndex = new int[RowData.FieldTypes.Length];

            // ancestors must also invoke ReadStructureAndTakeLocks in their constructor
        }
コード例 #8
0
        private void ReadPrimitiveValue(DriverRowData rowData, int ordinal, BinaryReader reader, StringBuilder stringBuilder)
        {
            var indexInArray = rowData.FieldArrayIndexes[ordinal];

            switch (rowData.FieldTypes[ordinal])
            {
                //case DbType.VarNumeric:
                //    break;
                case DbType.AnsiString:
                case DbType.String:
                case DbType.AnsiStringFixedLength:
                case DbType.StringFixedLength:
                case DbType.Xml:
                    {
                        var len = RowData.Read7BitEncodedInt(reader);
                        if (len > 0)
                        {
                            stringBuilder.Clear();
                            stringBuilder.EnsureCapacity(len);
                            for (var i = 0; i < len; i++)
                            {
                                stringBuilder.Append((char) RowData.Read7BitEncodedInt(reader));
                            }
                            rowData.StringData[indexInArray] = stringBuilder.ToString();
                        }
                        else
                        {
                            rowData.StringData[indexInArray] = string.Empty;
                        }
                    }
                    break;

                case DbType.Binary:
                case DbType.Object:
                    {
                        var data = rowData.BinaryData[indexInArray];
                        data.SetLength(RowData.Read7BitEncodedInt(reader));
                        var bytesRead = 0;
                        while (bytesRead < data.Length)
                        {
                            var count = reader.Read(data.Data, bytesRead, data.Length - bytesRead);
                            if (count == 0)
                            {
                                throw new DataException("Unexpected end of stream");
                            }
                            bytesRead += count;
                        }
                    }
                    break;

                case DbType.SByte:
                case DbType.Byte:
                    rowData.ValueData8Bytes[indexInArray].AsByte = reader.ReadByte();
                    break;
                case DbType.Boolean:
                    rowData.ValueData8Bytes[indexInArray].AsBoolean = reader.ReadBoolean();
                    break;
                case DbType.Decimal:
                case DbType.Currency:
                case DbType.Guid:
                case DbType.DateTimeOffset:
                    rowData.ValueData16Bytes[indexInArray].Lo = reader.ReadInt64();
                    rowData.ValueData16Bytes[indexInArray].Hi = reader.ReadInt64();
                    break;
                case DbType.Int16:
                case DbType.UInt16:
                    rowData.ValueData8Bytes[indexInArray].AsInt16 = reader.ReadInt16();
                    break;
                case DbType.Int32:
                case DbType.UInt32:
                case DbType.Single:
                    rowData.ValueData8Bytes[indexInArray].AsInt32 = reader.ReadInt32();
                    break;
                case DbType.Date:
                case DbType.DateTime:
                case DbType.DateTime2:
                case DbType.Time:
                case DbType.Int64:
                case DbType.UInt64:
                case DbType.Double:
                    rowData.ValueData8Bytes[indexInArray].AsInt64 = reader.ReadInt64();
                    break;

                default:
                    throw new DataException("Invalid DbType: " + rowData.FieldTypes[ordinal]);
            }
        }
コード例 #9
0
        public IDriverDataEnumerator GetUnorderedEnumerator(
            IReadOnlyList<FieldMetadata> fields, int countOfMainFields, DriverRowData driverRow)
        {
            var untrimmedCount = m_untrimmedDocumentCount;
            if (untrimmedCount == 0)
            {
                return null;
            }

            return new DocumentDataContainerEnumerator_FullScan(untrimmedCount, driverRow, this, fields, countOfMainFields);
        }
コード例 #10
0
        public IDriverDataEnumerator GetOrderedEnumerator(
            IReadOnlyList<FieldMetadata> fields, int countOfMainFields, DriverRowData driverRow, int orderFieldId, bool descending)
        {
            var untrimmedCount = m_untrimmedDocumentCount;
            if (untrimmedCount == 0)
            {
                return null;
            }

            var index = SortIndexManager.GetIndex(orderFieldId, m_untrimmedDocumentCount);
            return new DocumentDataContainerEnumerator_IndexScan(untrimmedCount, driverRow, this, fields, countOfMainFields, index, descending);
        }
コード例 #11
0
        public IDriverDataEnumerator GetBulkUpdateEnumerator(List<FieldMetadata> fields, DriverRowData driverRow, IDriverDataEnumerator inputDataEnumerator)
        {
            var untrimmedCount = m_untrimmedDocumentCount;
            if (untrimmedCount == 0)
            {
                return null;
            }

            return new DocumentDataContainerEnumerator_BulkPkScan(untrimmedCount, driverRow, this, fields, inputDataEnumerator);
        }
コード例 #12
0
        public void AttachDriverOutputBufferAndInputParameters(DriverRowData driverOutputBuffer, ParsedRequest parsedRequest)
        {
            if (driverOutputBuffer == null)
            {
                throw new ArgumentNullException("driverOutputBuffer");
            }

            if (DriverOutputBuffer != null)
            {
                throw new InvalidOperationException("Cannot reassign driver output buffer");
            }

            DriverOutputBuffer = driverOutputBuffer;
            ClauseEvaluationContext.InputRow = driverOutputBuffer;
            ClauseEvaluationContext.InputParametersRow = parsedRequest.Params.InputValues;
            ClauseEvaluationContext.InputParametersCollections = parsedRequest.Params.InputCollections;
        }
コード例 #13
0
 public SourcedEnumerator(DriverRowData.DataTypeRepresentation pkFieldType)
 {
     m_pkFieldType = pkFieldType;
 }