Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit b563f46

Browse files
committed
ARROW-6724: [C++] Allow simpler BufferOutputStream creation
Make the initial capacity argument optional.
1 parent 7ee6936 commit b563f46

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

cpp/src/arrow/dataset/file_ipc_test.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@
3434
namespace arrow {
3535
namespace dataset {
3636

37-
constexpr int64_t kDefaultOutputStreamSize = 1024;
3837
constexpr int64_t kBatchSize = 1UL << 12;
3938
constexpr int64_t kBatchRepetitions = 1 << 5;
4039
constexpr int64_t kNumRows = kBatchSize * kBatchRepetitions;
4140

4241
class ArrowIpcWriterMixin : public ::testing::Test {
4342
public:
4443
std::shared_ptr<Buffer> Write(std::vector<RecordBatchReader*> readers) {
45-
EXPECT_OK_AND_ASSIGN(auto sink, io::BufferOutputStream::Create(
46-
kDefaultOutputStreamSize, default_memory_pool()));
44+
EXPECT_OK_AND_ASSIGN(auto sink, io::BufferOutputStream::Create());
4745
auto writer_schema = readers[0]->schema();
4846

4947
EXPECT_OK_AND_ASSIGN(auto writer,
@@ -69,8 +67,7 @@ class ArrowIpcWriterMixin : public ::testing::Test {
6967
}
7068

7169
std::shared_ptr<Buffer> Write(const Table& table) {
72-
EXPECT_OK_AND_ASSIGN(auto sink, io::BufferOutputStream::Create(
73-
kDefaultOutputStreamSize, default_memory_pool()));
70+
EXPECT_OK_AND_ASSIGN(auto sink, io::BufferOutputStream::Create());
7471

7572
EXPECT_OK_AND_ASSIGN(auto writer,
7673
ipc::RecordBatchFileWriter::Open(sink.get(), table.schema()));

cpp/src/arrow/extension_type_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ TEST_F(TestExtensionType, ExtensionTypeTest) {
217217

218218
auto RoundtripBatch = [](const std::shared_ptr<RecordBatch>& batch,
219219
std::shared_ptr<RecordBatch>* out) {
220-
ASSERT_OK_AND_ASSIGN(auto out_stream, io::BufferOutputStream::Create(1024));
220+
ASSERT_OK_AND_ASSIGN(auto out_stream, io::BufferOutputStream::Create());
221221
ASSERT_OK(ipc::WriteRecordBatchStream({batch}, ipc::IpcOptions::Defaults(),
222222
out_stream.get()));
223223

@@ -255,7 +255,7 @@ TEST_F(TestExtensionType, UnrecognizedExtension) {
255255

256256
// Write full IPC stream including schema, then unregister type, then read
257257
// and ensure that a plain instance of the storage type is created
258-
ASSERT_OK_AND_ASSIGN(auto out_stream, io::BufferOutputStream::Create(1024));
258+
ASSERT_OK_AND_ASSIGN(auto out_stream, io::BufferOutputStream::Create());
259259
ASSERT_OK(ipc::WriteRecordBatchStream({batch}, ipc::IpcOptions::Defaults(),
260260
out_stream.get()));
261261

cpp/src/arrow/io/compressed_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void CheckCompressedInputStream(Codec* codec, const std::vector<uint8_t>& data)
127127
void CheckCompressedOutputStream(Codec* codec, const std::vector<uint8_t>& data,
128128
bool do_flush) {
129129
// Create compressed output stream
130-
ASSERT_OK_AND_ASSIGN(auto buffer_writer, BufferOutputStream::Create(1024));
130+
ASSERT_OK_AND_ASSIGN(auto buffer_writer, BufferOutputStream::Create());
131131
ASSERT_OK_AND_ASSIGN(auto stream, CompressedOutputStream::Make(codec, buffer_writer));
132132
ASSERT_OK_AND_EQ(0, stream->Tell());
133133

cpp/src/arrow/io/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ARROW_EXPORT BufferOutputStream : public OutputStream {
4646
/// \param[in,out] pool a MemoryPool to use for allocations
4747
/// \return the created stream
4848
static Result<std::shared_ptr<BufferOutputStream>> Create(
49-
int64_t initial_capacity, MemoryPool* pool = default_memory_pool());
49+
int64_t initial_capacity = 4096, MemoryPool* pool = default_memory_pool());
5050

5151
ARROW_DEPRECATED("Use Result-returning overload")
5252
static Status Create(int64_t initial_capacity, MemoryPool* pool,

cpp/src/arrow/ipc/feather_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void CheckBatches(const RecordBatch& expected, const RecordBatch& result) {
281281
class TestTableReader : public ::testing::Test {
282282
public:
283283
void SetUp() {
284-
ASSERT_OK_AND_ASSIGN(stream_, io::BufferOutputStream::Create(1024));
284+
ASSERT_OK_AND_ASSIGN(stream_, io::BufferOutputStream::Create());
285285
ASSERT_OK(TableWriter::Open(stream_, &writer_));
286286
}
287287

@@ -356,7 +356,7 @@ TEST_F(TestTableReader, ReadNames) {
356356
class TestTableWriter : public ::testing::Test {
357357
public:
358358
void SetUp() {
359-
ASSERT_OK_AND_ASSIGN(stream_, io::BufferOutputStream::Create(1024));
359+
ASSERT_OK_AND_ASSIGN(stream_, io::BufferOutputStream::Create());
360360
ASSERT_OK(TableWriter::Open(stream_, &writer_));
361361
}
362362

cpp/src/parquet/reader_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ TEST(TestFileReader, BufferedReads) {
412412
std::shared_ptr<WriterProperties> writer_props =
413413
WriterProperties::Builder().write_batch_size(64)->data_pagesize(128)->build();
414414

415-
ASSERT_OK_AND_ASSIGN(auto out_file, arrow::io::BufferOutputStream::Create(1024));
415+
ASSERT_OK_AND_ASSIGN(auto out_file, arrow::io::BufferOutputStream::Create());
416416
std::shared_ptr<ParquetFileWriter> file_writer =
417417
ParquetFileWriter::Open(out_file, schema, writer_props);
418418

0 commit comments

Comments
 (0)