Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCSP-34044: Add bitwise operators to aggregation pipeline #253

Merged
merged 23 commits into from
Oct 24, 2024

Conversation

mayaraman19
Copy link
Collaborator

@mayaraman19 mayaraman19 commented Oct 14, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-34044

Staging Links

  • fundamentals/linq
  • Self-Review Checklist

    • Is this free of any warnings or errors in the RST?
    • Did you run a spell-check?
    • Did you run a grammar-check?
    • Are all the links working?
    • Are the facets and meta keywords accurate?

    Copy link

    netlify bot commented Oct 14, 2024

    Deploy Preview for mongodb-docs-csharp ready!

    Name Link
    🔨 Latest commit b7855bb
    🔍 Latest deploy log https://app.netlify.com/sites/mongodb-docs-csharp/deploys/671965482f11a000089b81e9
    😎 Deploy Preview https://deploy-preview-253--mongodb-docs-csharp.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    @mayaraman19 mayaraman19 marked this pull request as ready for review October 15, 2024 18:50
    @mayaraman19 mayaraman19 changed the title Docsp 34044 bitwise DOCSP-34044: Add bitwise operators to aggregation pipeline Oct 15, 2024
    Copy link
    Collaborator

    @rustagir rustagir left a comment

    Choose a reason for hiding this comment

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

    Leaving a first batch of comments so that you can propagate these changes to the other sections. Please lmk if you have questions baout any of my feedback!

    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    Copy link
    Collaborator

    @rustagir rustagir left a comment

    Choose a reason for hiding this comment

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

    a few more small suggestions!

    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    Copy link
    Collaborator

    @rustagir rustagir left a comment

    Choose a reason for hiding this comment

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

    good job!! just a few nits

    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    source/fundamentals/linq.txt Outdated Show resolved Hide resolved
    @mayaraman19 mayaraman19 requested review from a team and sanych-sun and removed request for a team October 16, 2024 20:54
    // start-bitAnd-collection-example

    var query = queryableCollection
    .Select(i => i.Price & i.Count);
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    This is an odd example. There's no real reason to bit-and a Price and a Count.

    A better example would involve flags or something.

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Changed the example!

    .. note:: Missing or Undefined Operands

    If the operand list you pass to any bitwise operator contains a missing or
    undefined value, the entire expression evaluates to ``null``.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    This is true server-side, but in C# this isn't true unless you are using "nullable" integers.

    In these examples if either Price or Count is null the query will fail client-side while deserializing the results.

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    Clarified the note, please take a look!


    The ``null`` result comes from the document where the ``Name`` field
    has the value of ``"cheese"``. This document is missing a ``Count`` field, so
    the expression evaluates to ``null``.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Have you tried to execute this?

    I think it will throw an exception because the null can't be deserialized to an int client-side.

    Copy link
    Collaborator Author

    @mayaraman19 mayaraman19 Oct 23, 2024

    Choose a reason for hiding this comment

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

    All examples in this PR have been executed - although, the issue is that I was using nullable integers but did not add that in the example. They have now been added.

    { "_id": 3, "name": "eggs", "price": 5, "count": 12 },
    { "_id": 4, "name": "potatoes", "price": 3, "count": 0 },
    { "_id": 5, "name": "pasta", "price": 4, "count": 100 },
    { "_id": 6, "name": "cheese", "price": 4 }
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    This final document can't have been created using the Ingredient POCO because Count is an int and can't be null.

    Also, the element names in these sample documents don't match the field names in the POCO (the C# properties start with a capital letter).

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

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

    The data types used in the example have been changed to be nullable.

    As for the second point, for these examples we use a convention pack (see the bottom of the Overview section on this page) to convert snake case field names into Pascal case.

    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    It's hard to tell from looking at just this PR that there is a convention somewhere else that is mapping the property names. That's confusing.

    -13
    -5
    -101
    null
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    null is not a possible result. It should throw an exception when deserializing the results.

    Copy link
    Collaborator

    @rstam rstam left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @mayaraman19 mayaraman19 merged commit a1b1f4c into mongodb:master Oct 24, 2024
    6 checks passed
    @mayaraman19 mayaraman19 deleted the DOCSP-34044-bitwise branch October 24, 2024 15:45
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    mayaraman19 added a commit that referenced this pull request Oct 24, 2024
    * changing code + checkpint
    
    * very preliminary first draft
    
    * correct code block
    
    * code blocks
    
    * and and or
    
    * xor, not, and other small tweaks
    
    * changing variable type in linq.cs
    
    * never mind
    
    * back to double
    
    * addressing basic comments
    
    * move code to include
    
    * io code block
    
    * reworking first sentence
    
    * bullet list
    
    * bullet list pt 2
    
    * bullet list pt 3
    
    * feedback
    
    * nits
    
    * change example
    
    * correction
    
    * snake case
    
    * refining note
    
    * vale
    
    (cherry picked from commit a1b1f4c)
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants