Skip to content

Commit

Permalink
RavenDB-17061 - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
grisha-kotler authored and ppekrol committed Aug 3, 2021
1 parent 98693d6 commit 9e4c8f8
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ protected Document GetProjection(Lucene.Net.Documents.Document input, Lucene.Net
return GetProjectionFromDocument(doc, input, scoreDoc, FieldsToFetch, _context, state);
}

var documentLoaded = false;

var result = new DynamicJsonValue();

Dictionary<string, FieldsToFetch.FieldToFetch> fields = null;
Expand Down Expand Up @@ -140,17 +138,18 @@ protected Document GetProjection(Lucene.Net.Documents.Document input, Lucene.Net
if (TryExtractValueFromIndex(fieldToFetch, input, result, state))
continue;

if (documentLoaded == false)
if (doc == null)
{
using (_projectionStorageScope = _projectionStorageScope?.Start() ?? _projectionScope?.For(nameof(QueryTimingsScope.Names.Storage)))
doc = DirectGet(input, lowerId, DocumentFields.All, state);

documentLoaded = true;
if (doc == null)
{
// we don't return partial results
return null;
}
}

if (doc == null)
continue;

if (TryGetValue(fieldToFetch, doc, input, state, FieldsToFetch.IndexFields, FieldsToFetch.AnyDynamicIndexFields, out var key, out var fieldVal))
{
if (FieldsToFetch.SingleBodyOrMethodWithNoAlias)
Expand All @@ -177,12 +176,6 @@ protected Document GetProjection(Lucene.Net.Documents.Document input, Lucene.Net

if (doc == null)
{
if (documentLoaded)
{
// we tried to load it but the document doesn't exist
return null;
}

// the fields were projected from the index
doc = new Document
{
Expand Down

0 comments on commit 9e4c8f8

Please sign in to comment.