Skip to content

Commit 44432ba

Browse files
committed
more nul fixes
1 parent 81192d8 commit 44432ba

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/RESPite/Messages/RespReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ private readonly bool AggregateLengthIsSlow(int expected)
261261
/// </summary>
262262
public readonly bool IsAggregate => (_flags & RespFlags.IsAggregate) != 0;
263263

264+
internal readonly bool IsNonNullAggregate
265+
=> (_flags & (RespFlags.IsAggregate | RespFlags.IsNull)) == RespFlags.IsAggregate;
266+
264267
/// <summary>
265268
/// Indicates whether this is a null value; this could be an explicit <see cref="RespPrefix.Null"/>,
266269
/// or a scalar or aggregate a negative reported length.
@@ -299,6 +302,7 @@ private readonly bool AggregateLengthIsSlow(int expected)
299302
internal int Delta() =>
300303
(_flags & (RespFlags.IsScalar | RespFlags.IsAggregate | RespFlags.IsStreaming | RespFlags.IsAttribute)) switch
301304
{
305+
RespFlags.IsScalar | RespFlags.IsAggregate=> -1, // null has this
302306
RespFlags.IsScalar => -1,
303307
RespFlags.IsAggregate => _length - 1,
304308
RespFlags.IsAggregate | RespFlags.IsAttribute => _length,

src/RESPite/Messages/RespScanState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ no offsets are applied until we get back out of the outermost streaming aggregat
3333
private int _elementCount;
3434

3535
/// <inheritdoc/>
36-
public override string ToString() => $"{_prefix}, consumed: {_totalBytes} bytes, {_elementCount} nodes, complete: {IsComplete}";
36+
public override string ToString() => $"{_prefix}, consumed: {_totalBytes} bytes, {_elementCount} nodes, complete: {IsComplete} ({_delta + 1} outstanding)";
3737
#else
3838
/// <inheritdoc/>
3939
public override string ToString() => _prefix.ToString();
@@ -132,7 +132,7 @@ private long ReadCore(ref RespReader reader, long startOffset = 0)
132132
_prefix = reader.Prefix;
133133
}
134134

135-
if (reader.IsAggregate) ApplyAggregateRules(ref reader);
135+
if (reader.IsNonNullAggregate) ApplyAggregateRules(ref reader);
136136

137137
if (_streamingAggregateDepth == 0) _delta += reader.Delta();
138138
}

0 commit comments

Comments
 (0)