Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ public Cursor AddRows(int delta)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Cursor WithRow(int row) => From(Chunk, row);

public int Index
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => (Chunk * RowsPerChunk) + Row;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int ToIndex() => (Chunk * RowsPerChunk) + Row;
public int ToIndex() => Index;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int ToTotalBytes() => (Chunk * ChunkBytes) + ByteOffset;
Expand Down
14 changes: 14 additions & 0 deletions src/HotChocolate/Core/src/Types/Text/Json/ResultDocument.MetaDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ internal DbRow Get(Cursor cursor)
return MemoryMarshal.Read<DbRow>(span);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal DbRow GetValue(ref Cursor cursor)
{
var row = Get(cursor);

if (row.TokenType is ElementTokenType.Reference)
{
cursor = Cursor.FromIndex(row.Location);
row = Get(cursor);
}

return row;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal (Cursor, ElementTokenType) GetStartCursor(Cursor cursor)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ internal bool TryGetNamedPropertyValue(
{
ObjectDisposedException.ThrowIf(_disposed, this);

(startCursor, var tokenType) = _metaDb.GetStartCursor(startCursor);
CheckExpectedType(ElementTokenType.StartObject, tokenType);
var row = _metaDb.GetValue(ref startCursor);
CheckExpectedType(ElementTokenType.StartObject, row.TokenType);

var numberOfRows = _metaDb.GetNumberOfRows(startCursor);
var numberOfRows = row.NumberOfRows;

// Only one row means it was EndObject.
if (numberOfRows == 1)
Expand All @@ -24,7 +24,6 @@ internal bool TryGetNamedPropertyValue(
return false;
}

var row = _metaDb.Get(startCursor);
if (row.OperationReferenceType is OperationReferenceType.SelectionSet)
{
var selectionSet = _operation.GetSelectionSetById(row.OperationReferenceId);
Expand Down Expand Up @@ -120,10 +119,10 @@ internal bool TryGetNamedPropertyValue(
{
ObjectDisposedException.ThrowIf(_disposed, this);

(startCursor, var tokenType) = _metaDb.GetStartCursor(startCursor);
CheckExpectedType(ElementTokenType.StartObject, tokenType);
var row = _metaDb.GetValue(ref startCursor);
CheckExpectedType(ElementTokenType.StartObject, row.TokenType);

var numberOfRows = _metaDb.GetNumberOfRows(startCursor);
var numberOfRows = row.NumberOfRows;

// Only one row means it was EndObject.
if (numberOfRows == 1)
Expand All @@ -132,7 +131,6 @@ internal bool TryGetNamedPropertyValue(
return false;
}

var row = _metaDb.Get(startCursor);
if (row.OperationReferenceType is OperationReferenceType.SelectionSet)
{
var selectionSet = _operation.GetSelectionSetById(row.OperationReferenceId);
Expand Down
Loading
Loading