Example #1
0
        private static async Task <BlittableJsonReaderArray> ReadJsonArray(
            JsonOperationContext ctx,
            Stream stream,
            UnmanagedJsonParser parser,
            JsonParserState state,
            JsonOperationContext.ManagedPinnedBuffer buffer,
            CancellationToken token)
        {
            BlittableJsonReaderArray reader;

            using (var builder = new BlittableJsonDocumentBuilder(
                       ctx,
                       BlittableJsonDocumentBuilder.UsageMode.ToDisk,
                       "json/array", parser, state))
            {
                ctx.CachedProperties.NewDocument();
                builder.ReadArrayDocument();
                while (true)
                {
                    if (builder.Read())
                    {
                        break;
                    }
                    await RefillParserBuffer(stream, buffer, parser, token);
                }

                builder.FinalizeDocument();
                reader = builder.CreateArrayReader(noCache: true);
            }

            return(reader);
        }