protected override void PersistFields(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { var builder = IndexDefinition.ToJson(); using (var json = context.ReadObject(builder, nameof(IndexDefinition), BlittableJsonDocumentBuilder.UsageMode.ToDisk)) { writer.WritePropertyName(nameof(IndexDefinition)); writer.WriteObject(json); } }
internal static void WritePeriodicBackups(DocumentDatabase db, AbstractBlittableJsonTextWriter writer, JsonOperationContext context, out int count) { count = 0; var first = true; foreach (var periodicBackup in db.PeriodicBackupRunner.PeriodicBackups) { if (first == false) { writer.WriteComma(); } first = false; writer.WriteStartObject(); writer.WritePropertyName("DatabaseName"); writer.WriteString(db.Name); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.TaskId)); writer.WriteInteger(periodicBackup.Configuration.TaskId); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.Name)); writer.WriteString(periodicBackup.Configuration.Name); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.FullBackupFrequency)); writer.WriteString(periodicBackup.Configuration.FullBackupFrequency); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.IncrementalBackupFrequency)); writer.WriteString(periodicBackup.Configuration.IncrementalBackupFrequency); writer.WriteComma(); writer.WritePropertyName(nameof(NextBackup)); using (var nextBackup = context.ReadObject(periodicBackup.GetNextBackup().ToJson(), "nextBackup")) writer.WriteObject(nextBackup); writer.WriteComma(); writer.WritePropertyName(nameof(PeriodicBackup.BackupTimer.CreatedAt)); var createdAt = periodicBackup.GetCreatedAt(); if (createdAt.HasValue == false) { writer.WriteNull(); } else { writer.WriteDateTime(createdAt.Value, isUtc: true); } writer.WriteComma(); writer.WritePropertyName(nameof(PeriodicBackup.Disposed)); writer.WriteBool(periodicBackup.Disposed); writer.WriteEndObject(); count++; } }
protected override void PersistMapFields(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { writer.WritePropertyName(nameof(MapFields)); writer.WriteStartArray(); var first = true; foreach (var field in MapFields.Values.Select(x => x.As <AutoIndexField>())) { if (first == false) { writer.WriteComma(); } writer.WriteStartObject(); writer.WritePropertyName(nameof(field.Name)); writer.WriteString(field.Name); writer.WriteComma(); writer.WritePropertyName(nameof(field.Indexing)); writer.WriteString(field.Indexing.ToString()); writer.WriteComma(); writer.WritePropertyName(nameof(field.Aggregation)); writer.WriteInteger((int)field.Aggregation); writer.WriteComma(); writer.WritePropertyName(nameof(field.Spatial)); if (field.Spatial == null) { writer.WriteNull(); } else { writer.WriteObject(DocumentConventions.DefaultForServer.Serialization.DefaultConverter.ToBlittable(field.Spatial, context)); } writer.WriteComma(); writer.WritePropertyName(nameof(field.HasSuggestions)); writer.WriteBool(field.HasSuggestions); writer.WriteEndObject(); first = false; } writer.WriteEndArray(); }
private static void WriteRange(AbstractBlittableJsonTextWriter writer, TimeSeriesRangeResult rangeResult, long?totalCount) { writer.WriteStartObject(); { writer.WritePropertyName(nameof(TimeSeriesRangeResult.From)); if (rangeResult.From == DateTime.MinValue) { writer.WriteNull(); } else { writer.WriteDateTime(rangeResult.From, true); } writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.To)); if (rangeResult.To == DateTime.MaxValue) { writer.WriteNull(); } else { writer.WriteDateTime(rangeResult.To, true); } writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.Entries)); WriteEntries(writer, rangeResult.Entries); if (totalCount.HasValue) { // add total entries count to the response writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.TotalResults)); writer.WriteInteger(totalCount.Value); } if (rangeResult.Includes != null) { // add included documents to the response writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.Includes)); writer.WriteObject(rangeResult.Includes); } } writer.WriteEndObject(); }
public static void WriteIndexQuery(this AbstractBlittableJsonTextWriter writer, DocumentConventions conventions, JsonOperationContext context, IndexQuery query) { writer.WriteStartObject(); writer.WritePropertyName(nameof(query.Query)); writer.WriteString(query.Query); writer.WriteComma(); #pragma warning disable 618 if (query.PageSizeSet && query.PageSize >= 0) { writer.WritePropertyName(nameof(query.PageSize)); writer.WriteInteger(query.PageSize); writer.WriteComma(); } #pragma warning restore 618 if (query.WaitForNonStaleResults) { writer.WritePropertyName(nameof(query.WaitForNonStaleResults)); writer.WriteBool(query.WaitForNonStaleResults); writer.WriteComma(); } #pragma warning disable 618 if (query.Start > 0) { writer.WritePropertyName(nameof(query.Start)); writer.WriteInteger(query.Start); writer.WriteComma(); } #pragma warning restore 618 if (query.WaitForNonStaleResultsTimeout.HasValue) { writer.WritePropertyName(nameof(query.WaitForNonStaleResultsTimeout)); writer.WriteString(query.WaitForNonStaleResultsTimeout.Value.ToInvariantString()); writer.WriteComma(); } if (query.DisableCaching) { writer.WritePropertyName(nameof(query.DisableCaching)); writer.WriteBool(query.DisableCaching); writer.WriteComma(); } if (query.SkipDuplicateChecking) { writer.WritePropertyName(nameof(query.SkipDuplicateChecking)); writer.WriteBool(query.SkipDuplicateChecking); writer.WriteComma(); } writer.WritePropertyName(nameof(query.QueryParameters)); if (query.QueryParameters != null) { writer.WriteObject(conventions.Serialization.DefaultConverter.ToBlittable(query.QueryParameters, context)); } else { writer.WriteNull(); } if (query.ProjectionBehavior.HasValue && query.ProjectionBehavior.Value != ProjectionBehavior.Default) { writer.WriteComma(); writer.WritePropertyName(nameof(query.ProjectionBehavior)); writer.WriteString(query.ProjectionBehavior.ToString()); } writer.WriteEndObject(); }