public override QueryId?ReadJson(JsonReader reader, Type objectType, QueryId?existingValue, bool hasExistingValue,
                                         JsonSerializer serializer)
        {
            var value = serializer.Deserialize <string>(reader);

            if (value == null)
            {
                return(null);
            }

            return(QueryId.From(value));
        }
        public void WhenDataIsNotNullThenShouldSerializeWithExpectedValueNonGeneric()
        {
            var serializer = new JsonQueryDeserializer();

            var result = (FakeQuery)serializer.Deserialize(_json, typeof(FakeQuery));

            result.Should().NotBeNull();
            result.Id.Should().Be(QueryId.From(Guid.Empty.ToString()));
            result.CorrelationId.Should().Be(CorrelationId.From(Guid.Empty.ToString()));
            result.Timestamp.Should().Be(DateTimeOffset.MaxValue);
            result.Actor.Should().Be(Actor.From("User"));
        }
Beispiel #3
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Flags.ToBytes(),
                QueryId.ToBytes(),
                ToBytes(NextOffset, Flags, (int)BotResultsFlags.NextOffset),
                ToBytes(SwitchPM, Flags, (int)BotResultsFlags.SwitchPM),
                Results.ToBytes(),
                CacheTime.ToBytes(),
                Users.ToBytes()));
 }
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + SessionId.GetHashCode();
                hashcode = (hashcode * 397) + Statement.GetHashCode();
                hashcode = (hashcode * 397) + FetchSize.GetHashCode();
                hashcode = (hashcode * 397) + QueryId.GetHashCode();
                hashcode = (hashcode * 397) + IsAlign.GetHashCode();
            }
            return(hashcode);
        }
Beispiel #5
0
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + Path.GetHashCode();
                hashcode = (hashcode * 397) + DataTypeOrdinal.GetHashCode();
                hashcode = (hashcode * 397) + QueryId.GetHashCode();
                hashcode = (hashcode * 397) + TCollections.GetHashCode(DeviceMeasurements);
                hashcode = (hashcode * 397) + Header.GetHashCode();
                hashcode = (hashcode * 397) + Requestor.GetHashCode();
            }
            return(hashcode);
        }
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + SessionId.GetHashCode();
                if (__isset.queryId)
                {
                    hashcode = (hashcode * 397) + QueryId.GetHashCode();
                }
                if (__isset.statementId)
                {
                    hashcode = (hashcode * 397) + StatementId.GetHashCode();
                }
            }
            return(hashcode);
        }
Beispiel #7
0
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + Path.GetHashCode();
                hashcode = (hashcode * 397) + TCollections.GetHashCode(Aggregations);
                hashcode = (hashcode * 397) + DataTypeOrdinal.GetHashCode();
                if (__isset.timeFilterBytes)
                {
                    hashcode = (hashcode * 397) + TimeFilterBytes.GetHashCode();
                }
                hashcode = (hashcode * 397) + Header.GetHashCode();
                hashcode = (hashcode * 397) + QueryId.GetHashCode();
                hashcode = (hashcode * 397) + Requestor.GetHashCode();
                hashcode = (hashcode * 397) + TCollections.GetHashCode(DeviceMeasurements);
            }
            return(hashcode);
        }
Beispiel #8
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is QueryId))
            {
                return(false);
            }

            QueryId queryId = (QueryId)o;

            if (id != queryId.id)
            {
                return(false);
            }

            return(true);
        }
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + Status.GetHashCode();
                if (__isset.queryId)
                {
                    hashcode = (hashcode * 397) + QueryId.GetHashCode();
                }
                if (__isset.columns)
                {
                    hashcode = (hashcode * 397) + TCollections.GetHashCode(Columns);
                }
                if (__isset.operationType)
                {
                    hashcode = (hashcode * 397) + OperationType.GetHashCode();
                }
                if (__isset.ignoreTimeStamp)
                {
                    hashcode = (hashcode * 397) + IgnoreTimeStamp.GetHashCode();
                }
                if (__isset.dataTypeList)
                {
                    hashcode = (hashcode * 397) + TCollections.GetHashCode(DataTypeList);
                }
                if (__isset.queryDataSet)
                {
                    hashcode = (hashcode * 397) + QueryDataSet.GetHashCode();
                }
                if (__isset.nonAlignQueryDataSet)
                {
                    hashcode = (hashcode * 397) + NonAlignQueryDataSet.GetHashCode();
                }
                if (__isset.columnNameIndexMap)
                {
                    hashcode = (hashcode * 397) + TCollections.GetHashCode(ColumnNameIndexMap);
                }
            }
            return(hashcode);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (RequestorDesc != null)
         {
             hashCode = hashCode * 59 + RequestorDesc.GetHashCode();
         }
         if (QueryId != null)
         {
             hashCode = hashCode * 59 + QueryId.GetHashCode();
         }
         if (QueriedProps != null)
         {
             hashCode = hashCode * 59 + QueriedProps.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #11
0
        /// <summary>
        /// TODO: documentation
        /// </summary>
        /// <param name="shardedQuery">the ShardedQuery for which this Shard should create an actual <see cref="IQuery"/> object.</param>
        /// <returns>Query for the given ShardedQuery</returns>
        public IQuery EstablishQuery(IShardedQuery shardedQuery)
        {
            QueryId queryId = shardedQuery.QueryId;
            IQuery  query;

            queryMap.TryGetValue(queryId, out query);
            if (query == null)
            {
                query = shardedQuery.QueryFactory.CreateQuery(EstablishSession());
                queryMap.Add(queryId, query);
                LinkedList <IQueryEvent> queryEvents;
                queryEventMap.TryGetValue(queryId, out queryEvents);
                if (queryEvents != null)
                {
                    foreach (IQueryEvent queryEvent in queryEvents)
                    {
                        queryEvent.OnEvent(query);
                    }
                    queryEvents.Clear();
                }
            }
            return(query);
        }
Beispiel #12
0
 public void QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, string path, QueryId queryId) => throw new NotSupportedException();
Beispiel #13
0
 protected override Result QueryEntryImpl(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId, string path)
 {
     return(ResultFs.UnsupportedOperation.Log());
 }
 public FakeQuery()
 {
     Id            = QueryId.From(Guid.Empty.ToString());
     Timestamp     = DateTimeOffset.MinValue;
     CorrelationId = OpenEventSourcing.CorrelationId.From(Guid.Empty.ToString());
 }
Beispiel #15
0
 protected override Result DoQueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId,
                                        U8Span path)
 {
     return(ConvertResult(BaseFileSystem.Target.QueryEntry(outBuffer, inBuffer, queryId, path)));
 }
Beispiel #16
0
 public StageId(QueryId queryId, int id)
 {
     this.QueryId = queryId ?? throw new ArgumentNullException("queryId", "Query id cannot be null.");
     this.Id      = id;
 }
Beispiel #17
0
        public Result QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId, string path)
        {
            if (IsDisposed)
            {
                return(ResultFs.PreconditionViolation.Log());
            }

            return(QueryEntryImpl(outBuffer, inBuffer, queryId, path));
        }
Beispiel #18
0
        protected override Result DoQueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId,
                                               U8Span path)
        {
            foreach (IFileSystem fs in Sources)
            {
                Result getEntryResult = fs.GetEntryType(out _, path);

                if (getEntryResult.IsSuccess())
                {
                    return(fs.QueryEntry(outBuffer, inBuffer, queryId, path));
                }
            }

            return(ResultFs.PathNotFound.Log());
        }
Beispiel #19
0
        protected override Result QueryEntryImpl(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId, string path)
        {
            string fullPath = ResolveFullPath(PathTools.Normalize(path));

            return(ParentFileSystem.QueryEntry(outBuffer, inBuffer, queryId, fullPath));
        }
Beispiel #20
0
 protected virtual Result QueryEntryImpl(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId, string path)
 {
     return(ResultFs.NotImplemented.Log());
 }
Beispiel #21
0
 public void QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, string path, QueryId queryId) =>
 ThrowHelper.ThrowResult(ResultFs.UnsupportedOperation);
Beispiel #22
0
 public void QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, string path, QueryId queryId)
 {
     throw new NotImplementedException();
 }
 protected override Result QueryEntryImpl(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId,
                                          U8Span path)
 {
     return(BaseFileSystem.QueryEntry(outBuffer, inBuffer, queryId, path));
 }
Beispiel #24
0
        public void QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, string path, QueryId queryId)
        {
            if (queryId != QueryId.MakeConcatFile)
            {
                ThrowHelper.ThrowResult(ResultFs.UnsupportedOperationInConcatFsQueryEntry);
            }

            SetConcatenationFileAttribute(path);
        }
Beispiel #25
0
 /// <summary>
 /// If you are looking to gather very detailed statistics about a
 /// query, this is the service you would call.
 /// </summary>
 /// <param name="queryId">The id of the query to retrieve details about.</param>
 /// <returns>Information about the specified query.</returns>
 public async Task <GetQueryV1Response> GetQuery(QueryId queryId)
 {
     return(await this.GetQuery(queryId.ToString()));
 }
        protected override Result DoQueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId,
                                               U8Span path)
        {
            if (queryId != QueryId.MakeConcatFile)
            {
                return(ResultFs.UnsupportedQueryEntryForConcatenationFileSystem.Log());
            }

            return(SetConcatenationFileAttribute(path));
        }
Beispiel #27
0
 public Result QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, U8Span path, QueryId queryId)
 {
     return(FileSystem.QueryEntry(outBuffer, inBuffer, queryId, path));
 }
        protected override Result DoQueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId,
                                               U8Span path)
        {
            Span <byte> fullPath = stackalloc byte[PathTools.MaxPathLength + 1];
            Result      rc       = ResolveFullPath(fullPath, path);

            if (rc.IsFailure())
            {
                return(rc);
            }

            return(BaseFileSystem.QueryEntry(outBuffer, inBuffer, queryId, new U8Span(fullPath)));
        }
Beispiel #29
0
        protected override Result QueryEntryImpl(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, QueryId queryId, string path)
        {
            if (queryId != QueryId.MakeConcatFile)
            {
                return(ResultFs.UnsupportedOperationInConcatFsQueryEntry.Log());
            }

            return(SetConcatenationFileAttribute(path));
        }
Beispiel #30
0
 public void QueryEntry(Span <byte> outBuffer, ReadOnlySpan <byte> inBuffer, string path, QueryId queryId)
 {
     BaseFs.QueryEntry(outBuffer, inBuffer, path, queryId);
 }