public async Task <BlittableJsonReaderArray> ParseArrayToMemoryAsync(Stream stream, string debugTag,
                                                                             BlittableJsonDocumentBuilder.UsageMode mode)
        {
            var state  = new JsonParserState();
            var buffer = GetParsingBuffer();

            using (var parser = new UnmanagedJsonParser(this, state, debugTag))
            {
                var writer = new BlittableJsonDocumentBuilder(this, mode, debugTag, parser, state);
                try
                {
                    CachedProperties.NewDocument();
                    writer.ReadArray();
                    while (true)
                    {
                        var read = await stream.ReadAsync(buffer, 0, buffer.Length);

                        if (read == 0)
                        {
                            throw new EndOfStreamException("Stream ended without reaching end of json content");
                        }
                        parser.SetBuffer(buffer, read);
                        if (writer.Read())
                        {
                            break;
                        }
                    }
                    writer.FinalizeDocument();
                    _disposables.Add(writer);
                    return(writer.CreateArrayReader());
                }
                catch (Exception)
                {
                    writer.Dispose();
                    throw;
                }
            }
        }