Exemplo n.º 1
0
 public void AddItemsToStream <T>(ManualBlittableJsonDocumentBuilder <T> writer) where T : struct, IUnmanagedWriteBuffer
 {
     for (var i = 0; i < _count; i++)
     {
         var tuple = GetValueTokenTupleByIndex(i);
         writer.WriteValue(tuple.Item2, tuple.Item1);
     }
 }
Exemplo n.º 2
0
 public void AddItemsToStream <T>(ManualBlittableJsonDocumentBuilder <T> writer) where T : struct, IUnmanagedWriteBuffer
 {
     for (var i = 0; i < _count; i++)
     {
         var(value, token) = GetValueTokenTupleByIndex(i);
         writer.WriteValue(ProcessTokenTypeFlags(token), value);
     }
 }
Exemplo n.º 3
0
 public void AddItemsToStream <T>(ManualBlittableJsonDocumentBuilder <T> writer)
     where T : struct, IUnmanagedWriteBuffer
 {
     for (var i = 0; i < Count; i++)
     {
         var prop = new PropertyDetails();
         GetPropertyByIndex(i, ref prop);
         writer.WritePropertyName(prop.Name);
         writer.WriteValue(ProcessTokenTypeFlags(prop.Token), prop.Value);
     }
 }
Exemplo n.º 4
0
        //Todo Fixing the clone implementation to support this situation or throw clear error
        public BlittableJsonReaderArray Clone(JsonOperationContext context, BlittableJsonDocumentBuilder.UsageMode usageMode = BlittableJsonDocumentBuilder.UsageMode.None)
        {
            AssertContextNotDisposed();
            using (var builder = new ManualBlittableJsonDocumentBuilder <UnmanagedWriteBuffer>(context))
            {
                builder.Reset(usageMode);
                builder.StartArrayDocument();
                builder.StartWriteArray();
                using (var itr = new BlittableJsonArrayEnumerator(this))
                {
                    while (itr.MoveNext())
                    {
                        switch (itr.Current)
                        {
                        case BlittableJsonReaderObject item:
                            var clone = item.CloneOnTheSameContext();
                            builder.WriteEmbeddedBlittableDocument(clone.BasePointer, clone.Size);
                            break;

                        case LazyStringValue item:
                            builder.WriteValue(item);
                            break;

                        case long item:
                            builder.WriteValue(item);
                            break;

                        case LazyNumberValue item:
                            builder.WriteValue(item);
                            break;

                        case LazyCompressedStringValue item:
                            builder.WriteValue(item);
                            break;

                        default:
                            throw new InvalidDataException($"Actual value type is {itr.Current.GetType()}. Should be known serialized type and should not happen. ");
                        }
                    }
                }
                builder.WriteArrayEnd();
                builder.FinalizeDocument();

                return(builder.CreateArrayReader());
            }
        }