Skip to content

[C++] arrow::UInt64Builder::Reset() doesn't affect the builder's length() #33341

@asfimport

Description

@asfimport

Git hash of Arrow version tested:
eb01350

Steps to reproduce:
Build Arrow statically, and install to a prefix directory, {}~/arrow/cpp/release/prefix{}:

cd
git clone https://github.com/apache/arrow.git
cd arrow/cpp/
mkdir release
cd release
cmake -DARROW_BUILD_SHARED=OFF -DARROW_BUILD_STATIC=ON -DCMAKE_CXX_STANDARD=17 -DARROW_DEPENDENCY_SOURCE=BUNDLED ..
make -j32
mkdir prefix
make DESTDIR=prefix install

Build the following main file:

#include <arrow/array/builder_primitive.h>
#include <cassert>

int main(int, char**) {
  arrow::UInt64Builder foo{};
  assert(foo.length() == 0);
  (void)foo.Append(123);
  assert(foo.length() == 1);
  foo.Reset();
  assert(foo.length() == 0);
}

Using the following CMakeLists.txt:

project("arrowresetbug")

set(ARROW_HOME "/home/enolan/arrow/cpp/release/prefix/usr/local")
find_package(Arrow CONFIG PATHS "/home/enolan/arrow/cpp/release/prefix/usr/local/lib/cmake/Arrow" NO_DEFAULT_PATH REQUIRED)

set(CMAKE_CXX_FLAGS "-std=c++17")

add_executable(main main.cpp)

target_link_libraries(main arrow_static)

Expected behavior:
No assertions fire because Reset() resets the length of the builder

Actual behavior:

main: /home/enolan/stuff/2022-10/arrowresetbug/main.cpp:10: int main(int, char**): Assertion `foo.length() == 0' failed.
Aborted (core dumped) 

Environment: OS: Ubuntu 22.04

Linux ed-ubuntu-pc 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Compiler: c++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Reporter: Edward Nolan

Note: This issue was originally created as ARROW-18146. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions