public DatabaseItemType GetNextType() { if (_currentType != null) { var currentType = _currentType.Value; _currentType = null; return(currentType); } var type = ReadType(); var dbItemType = GetType(type); while (dbItemType == DatabaseItemType.Unknown) { var msg = $"You are trying to import items of type '{type}' which is unknown or not supported in {RavenVersionAttribute.Instance.Version}. Ignoring items."; if (_log.IsOperationsEnabled) { _log.Operations(msg); } _result.AddWarning(msg); SkipArray(onSkipped: null, token: CancellationToken.None); type = ReadType(); dbItemType = GetType(type); } return(dbItemType); }
public DatabaseItemType GetNextType() { if (_currentType != null) { var currentType = _currentType.Value; _currentType = null; return(currentType); } var type = ReadType(); var dbItemType = GetType(type); while (dbItemType == DatabaseItemType.Unknown) { var msg = $"You are trying to import items of type '{type}' which is unknown or not supported in 4.0. Ignoring items."; if (_log.IsOperationsEnabled) { _log.Operations(msg); } _result.AddWarning(msg); SkipArray(); type = ReadType(); dbItemType = GetType(type); } return(dbItemType); }
public IEnumerable <IndexDefinitionAndType> GetIndexes() { foreach (var reader in ReadArray()) { using (reader) { IndexType type; object indexDefinition; try { indexDefinition = IndexProcessor.ReadIndexDefinition(reader, _buildVersionType, out type); } catch (Exception e) { _result.Indexes.ErroredCount++; _result.AddWarning($"Could not read index definition. Message: {e.Message}"); continue; } yield return(new IndexDefinitionAndType { Type = type, IndexDefinition = indexDefinition }); } } }
private IEnumerable <(string key, long index, BlittableJsonReaderObject value)> InternalGetCompareExchangeValues() { var state = new JsonParserState(); using (var parser = new UnmanagedJsonParser(_context, state, "Import/CompareExchange")) using (var builder = new BlittableJsonDocumentBuilder(_context, BlittableJsonDocumentBuilder.UsageMode.ToDisk, "Import/CompareExchange", parser, state)) { foreach (var reader in ReadArray()) { using (reader) { if (reader.TryGet("Key", out string key) == false || reader.TryGet("Value", out LazyStringValue value) == false) { _result.CompareExchange.ErroredCount++; _result.AddWarning("Could not read compare exchange entry."); continue; } builder.ReadNestedObject(); SetBuffer(parser, value); parser.Read(); builder.Read(); builder.FinalizeDocument(); yield return(key, 0, builder.CreateReader()); builder.Renew("import/cmpxchg", BlittableJsonDocumentBuilder.UsageMode.ToDisk); } } } }
public void Can_Build_Serializator_For_SmugglerResult() { using (var context = JsonOperationContext.ShortTermSingleUse()) { var result = new SmugglerResult(); result.AddError("MessageA"); result.AddInfo("MessageB"); result.AddWarning("MessageC"); result.AddMessage("MessageD"); var djv = result.ToJson(); var json = context.ReadObject(djv, "smuggler/result"); var result2 = JsonDeserializationClient.SmugglerResult(json); Assert.Equal(result.Messages, result2.Messages); var result3 = DocumentConventions.Default.Serialization.DefaultConverter.FromBlittable <SmugglerResult>(json); Assert.Equal(result.Messages, result3.Messages); } }