Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add SequenceReader<T> #33288

Merged
merged 10 commits into from
Nov 10, 2018
Merged

Add SequenceReader<T> #33288

merged 10 commits into from
Nov 10, 2018

Conversation

JeremyKuhne
Copy link
Member

Initial add of ReadOnlySequence<T> reader. Includes search and binary read functionality.

Perf tests will be ported from CoreFXlab later. Text parsing functionality still being discussed and is not included in this change.

See https://github.com/dotnet/corefx/issues/32588.

cc: @joshfree, @danmosemsft, @davidfowl, @terrajobst, @ericstj (for packaging)

Initial add of ReadOnlySequence<T> reader. Includes search and binary read functionality.

Perf tests will be ported from CoreFXlab later. Parse functionality still being discussed.
@JeremyKuhne JeremyKuhne added this to the 3.0 milestone Nov 7, 2018
@JeremyKuhne JeremyKuhne self-assigned this Nov 7, 2018
Copy link
Member

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting some changes.

src/System.Memory/Directory.Build.props Show resolved Hide resolved
src/System.Memory/src/System.Memory.csproj Outdated Show resolved Hide resolved
src/System.Memory/ref/System.Memory.cs Show resolved Hide resolved
src/System.Memory/ref/System.Memory.cs Outdated Show resolved Hide resolved
src/System.Memory/ref/System.Memory.cs Outdated Show resolved Hide resolved
src/System.Memory/src/System.Memory.csproj Outdated Show resolved Hide resolved
@ahsonkhan
Copy link
Member

Update the package description?

"CommonTypes": [

@@ -97,14 +97,10 @@ public static partial class MemoryExtensions
private readonly object _dummy;
private readonly int _dummyPrimitive;
public SequencePosition(object @object, int integer) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this end up getting removed? I would revert this change, build the ref and src, and then run the generate command from within the ref directory. Please let me know if you are still seeing such side effects/unintended changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build target did it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually added them back for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz revert.

}
public ref partial struct SequenceReader<T> where T : struct, System.IEquatable<T>
{
public SequenceReader(System.Buffers.ReadOnlySequence<T> buffer) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regenerate based on new sources so that arg names match.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs fixing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, sorry, missed this comment. I'll fix shortly.

@JeremyKuhne
Copy link
Member Author

JeremyKuhne commented Nov 8, 2018 via email

@ahsonkhan
Copy link
Member

It is never expected to throw.

Then, why not add the debug.assert and/or comment?

@JeremyKuhne
Copy link
Member Author

Then, why not add the debug.assert and/or comment?

Because an assert here would give you no useful information. In any case, that code no longer exists as I removed Peek.

{
int escapeCount = 0;
for (int i = remaining.Length; i > 0 && remaining[i - 1].Equals(delimiterEscape); i--, escapeCount++)
;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: there seems to be some inconsistency as to whether loops with empty bodies just use ; or have empty braces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we've called out in our guidelines? I'll massage it either way.

/// Move the reader back the specified number of items.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Rewind(long count)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the right trade-off for Rewind to be forcibly inlined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We believe so. It is only the fast path and is expected to be used frequently in some scenarios. I'll look to push the count check to the slow path like I did for advance to make this a bit better.

@JeremyKuhne
Copy link
Member Author

@dotnet-bot test OSX x64 Debug Build

<Compile Include="SequenceReader\OwnedArray.cs" />
<Compile Include="SequenceReader\ReadTo.cs" />
<Compile Include="SequenceReader\Rewind.cs" />
<Compile Include="SequenceReader\SequenceSegment.cs" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: alphabetical ordering. swap SequenceSegment/SequenceFactory

Copy link
Member

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM!

@JeremyKuhne JeremyKuhne merged commit ab9570b into dotnet:master Nov 10, 2018
@JeremyKuhne JeremyKuhne deleted the sequencereader branch November 10, 2018 01:04
@davidfowl
Copy link
Member

👍🏿

@joperezr
Copy link
Member

Looks like this PR broke the packaging CI build. I'm taking a look. cc: @tarekgh @ericstj

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Add SequenceReader<T>

Initial add of ReadOnlySequence<T> reader. Includes search and binary read functionality.

Perf tests will be ported from CoreFXlab later. Parse functionality still being discussed.

* Address feedback, fix non coreapp test builds.

* Replace Peek() with TryCopyTo()

* Address more feedback. Removing TryReadTo without advancePastDelmiter as we don't have the same pattern yet for the other overloads.

* Rename files to not use underscore.

* Fix uap builds

* Move TryRead to SequenceMarshal and other feedback.

* Tweak file name casing (part1)

* Change casing pt 2.

* Change package common types


Commit migrated from dotnet/corefx@ab9570b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants