Exemple #1
0
 public YieldStreamResults(InMemoryDocumentSessionOperations session, StreamResult stream, bool isQueryStream, StreamQueryStatistics streamQueryStatistics)
 {
     _response              = stream;
     _peepingTomStream      = new PeepingTomStream(_response.Stream, session.Context);
     _session               = session;
     _isQueryStream         = isQueryStream;
     _streamQueryStatistics = streamQueryStatistics;
 }
 public YieldStreamResults(InMemoryDocumentSessionOperations session, StreamResult response, bool isQueryStream, bool isTimeSeriesStream, bool isAsync, StreamQueryStatistics streamQueryStatistics, CancellationToken token = default)
 {
     _response                         = response ?? throw new InvalidOperationException("The index does not exists, failed to stream results");
     _peepingTomStream                 = new PeepingTomStream(_response.Stream, session.Context);
     _session                          = session;
     _isQueryStream                    = isQueryStream;
     _isAsync                          = isAsync;
     _streamQueryStatistics            = streamQueryStatistics;
     _maxDocsCountOnCachedRenewSession = session._maxDocsCountOnCachedRenewSession;
     _token = token;
     _isTimeSeriesStream = isTimeSeriesStream;
 }
        public TimeSeriesStreamOperation(InMemoryDocumentSessionOperations session, StreamQueryStatistics statistics, string docId, string name, DateTime? from = null, DateTime? to = null, TimeSpan? offset = null) : base(session, statistics)
        {
            if (string.IsNullOrEmpty(docId))
                throw new ArgumentNullException(nameof(docId));
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException(nameof(name));

            _docId = docId;
            _name = name;
            _from = from;
            _to = to;
            _offset = offset;
        }
Exemple #4
0
            public YieldStreamResults(InMemoryDocumentSessionOperations session, StreamResult response, bool isQueryStream, bool isAsync, StreamQueryStatistics streamQueryStatistics)
            {
                if (response == null)
                {
                    throw new InvalidOperationException("The index does not exists, failed to stream results");
                }

                _response              = response;
                _peepingTomStream      = new PeepingTomStream(_response.Stream, session.Context);
                _session               = session;
                _isQueryStream         = isQueryStream;
                _isAsync               = isAsync;
                _streamQueryStatistics = streamQueryStatistics;
            }
Exemple #5
0
 public StreamOperation(InMemoryDocumentSessionOperations session, StreamQueryStatistics statistics)
 {
     _session    = session;
     _statistics = statistics;
 }
Exemple #6
0
        private static void HandleStreamQueryStats(JsonOperationContext context, StreamResult response, UnmanagedJsonParser parser, JsonParserState state, JsonOperationContext.ManagedPinnedBuffer buffer, StreamQueryStatistics streamQueryStatistics = null)
        {
            using (var peepingTomStream = new PeepingTomStream(response.Stream, context))
            {
                var property = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);
                if (string.Equals(property, nameof(StreamQueryStatistics.ResultEtag)) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }
                var resultEtag = UnmanagedJsonParserHelper.ReadLong(context, peepingTomStream, parser, state, buffer);

                property = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);
                if (string.Equals(property, nameof(StreamQueryStatistics.IsStale)) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }

                if (UnmanagedJsonParserHelper.Read(peepingTomStream, parser, state, buffer) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }

                if (state.CurrentTokenType != JsonParserToken.False && state.CurrentTokenType != JsonParserToken.True)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }
                var isStale = state.CurrentTokenType != JsonParserToken.False;

                property = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);
                if (string.Equals(property, nameof(StreamQueryStatistics.IndexName)) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }
                var indexName = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);

                property = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);
                if (string.Equals(property, nameof(StreamQueryStatistics.TotalResults)) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }
                var totalResults = (int)UnmanagedJsonParserHelper.ReadLong(context, peepingTomStream, parser, state, buffer);

                property = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);
                if (string.Equals(property, nameof(StreamQueryStatistics.IndexTimestamp)) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }
                var indexTimestamp = UnmanagedJsonParserHelper.ReadString(context, peepingTomStream, parser, state, buffer);

                if (streamQueryStatistics == null)
                {
                    return;
                }

                streamQueryStatistics.IndexName    = indexName;
                streamQueryStatistics.IsStale      = isStale;
                streamQueryStatistics.TotalResults = totalResults;
                streamQueryStatistics.ResultEtag   = resultEtag;

                DateTime timeStamp;
                if (DateTime.TryParseExact(indexTimestamp, "o", CultureInfo.InvariantCulture,
                                           DateTimeStyles.RoundtripKind, out timeStamp) == false)
                {
                    UnmanagedJsonParserHelper.ThrowInvalidJson(peepingTomStream);
                }
                streamQueryStatistics.IndexTimestamp = timeStamp;
            }
        }