Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-8367

[C++] Deprecate Buffer::FromString(..., pool)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 0.16.0
    • 0.17.0
    • C++

    Description

      From https://github.com/apache/arrow/pull/6863#discussion_r404913683

      There are currently two overloads of Buffer::FromString, one which takes an rvalue reference to string and another which takes a const reference and a MemoryPool. In the former case the string is simply moved into a Buffer subclass while in the latter the MemoryPool is used to allocate space into which the string's contents are copied, which necessitates bubbling the potential allocation failure. This seems gratuitous given we don't use std::string to store large quantities so it should be fine to provide only

        static std::unique_ptr<Buffer> FromString(std::string data); 
      

      and rely on std::string's copy constructor when the argument is not an rvalue.

      In the case of a std::string which may/does contain large data and must be copied, tracking the copied memory with a MemoryPool does not require a great deal of boilerplate:

      ARROW_ASSIGN_OR_RAISE(auto buffer,
                            Buffer(large).CopySlice(0, large.size(), pool));
      

      Attachments

        Issue Links

          Activity

            People

              apitrou Antoine Pitrou
              bkietz Ben Kietzman
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h