Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add SequenceReader<T>#33288

Merged
JeremyKuhne merged 10 commits into
dotnet:masterfrom
JeremyKuhne:sequencereader
Nov 10, 2018
Merged

Add SequenceReader<T>#33288
JeremyKuhne merged 10 commits into
dotnet:masterfrom
JeremyKuhne:sequencereader

Conversation

@JeremyKuhne
Copy link
Copy Markdown
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
Comment thread src/System.Memory/ref/System.Memory.cs Outdated
Comment thread src/System.Memory/ref/System.Memory.cs Outdated
Comment thread src/System.Memory/ref/System.Memory.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/ReadOnlySequence_helpers.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReader.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReaderExtensions_binary.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs Outdated
Copy link
Copy Markdown

@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.

Comment thread src/System.Memory/Directory.Build.props
Comment thread src/System.Memory/src/System.Memory.csproj Outdated
Comment thread src/System.Memory/ref/System.Memory.cs
Comment thread src/System.Memory/ref/System.Memory.cs Outdated
Comment thread src/System.Memory/ref/System.Memory.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs Outdated
Comment thread src/System.Memory/src/System.Memory.csproj Outdated
Comment thread pkg/Microsoft.Private.PackageBaseline/packageIndex.json
@ahsonkhan
Copy link
Copy Markdown

Update the package description?

"CommonTypes": [

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

Choose a reason for hiding this comment

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

Plz revert.

Comment thread src/System.Memory/ref/System.Memory.cs Outdated
}
public ref partial struct SequenceReader<T> where T : struct, System.IEquatable<T>
{
public SequenceReader(System.Buffers.ReadOnlySequence<T> buffer) { throw null; }
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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.

Comment thread src/System.Memory/src/System/Buffers/SequenceReader_search.cs Outdated
Comment thread src/System.Memory/tests/System.Memory.Tests.csproj Outdated
Comment thread src/System.Memory/tests/SequenceReader/BasicTests.cs Outdated
Comment thread src/System.Memory/src/System/Buffers/SequenceReader.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReader.cs
Comment thread src/System.Memory/src/System/Buffers/SequenceReaderExtensions_binary.cs Outdated
@JeremyKuhne
Copy link
Copy Markdown
Member Author

JeremyKuhne commented Nov 8, 2018 via email

@ahsonkhan
Copy link
Copy Markdown

It is never expected to throw.

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

@JeremyKuhne
Copy link
Copy Markdown
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.

Comment thread pkg/Microsoft.Private.PackageBaseline/packageIndex.json Outdated
Comment thread src/System.Memory/src/System.Memory.csproj Outdated
{
int escapeCount = 0;
for (int i = remaining.Length; i > 0 && remaining[i - 1].Equals(delimiterEscape); i--, escapeCount++)
;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

@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
Copy Markdown
Member

👍🏿

@joperezr
Copy link
Copy Markdown
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