Skip to content

Commit c0ac8f0

Browse files
committed
fix windows ci
1 parent e5b15dc commit c0ac8f0

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/iceberg/arrow/arrow_io.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,12 @@ Result<std::shared_ptr<::arrow::io::OutputStream>> OpenArrowOutputStream(
530530
}
531531

532532
ICEBERG_ASSIGN_OR_RAISE(auto output_file, io->NewOutputFile(path));
533-
ICEBERG_ASSIGN_OR_RAISE(
534-
auto output, overwrite ? output_file->CreateOrOverwrite() : output_file->Create());
533+
std::unique_ptr<PositionOutputStream> output;
534+
if (overwrite) {
535+
ICEBERG_ASSIGN_OR_RAISE(output, output_file->CreateOrOverwrite());
536+
} else {
537+
ICEBERG_ASSIGN_OR_RAISE(output, output_file->Create());
538+
}
535539
return std::make_shared<OutputStreamAdapter>(std::move(output));
536540
}
537541

src/iceberg/file_io.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class ICEBERG_EXPORT SeekableInputStream {
4848

4949
/// \brief Read exactly out.size() bytes from an absolute position.
5050
///
51-
/// Fails if fewer than out.size() bytes are available. The current stream position is
52-
/// unchanged after this call.
51+
/// Fails if fewer than out.size() bytes are available. The current stream position
52+
/// after this call is unspecified; callers should Seek before subsequent
53+
/// position-dependent reads.
5354
virtual Status ReadFully(int64_t position, std::span<std::byte> out) = 0;
5455

5556
/// \brief Close the stream. Implementations should allow repeated Close calls.

src/iceberg/test/arrow_io_test.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ TEST_F(LocalFileIOTest, DeleteFile) {
341341
EXPECT_THAT(del_res, HasErrorMessage("Cannot delete file"));
342342
}
343343

344-
void VerifyReadFullyPreservesPosition(const std::shared_ptr<FileIO>& file_io,
345-
const std::string& path) {
344+
void VerifyReadFullyReadsFromAbsolutePosition(const std::shared_ptr<FileIO>& file_io,
345+
const std::string& path) {
346346
ASSERT_THAT(file_io->WriteFile(path, "abcdef"), IsOk());
347347

348348
ICEBERG_UNWRAP_OR_FAIL(auto input_file, file_io->NewInputFile(path));
@@ -354,16 +354,23 @@ void VerifyReadFullyPreservesPosition(const std::shared_ptr<FileIO>& file_io,
354354

355355
std::string data(reinterpret_cast<const char*>(buffer.data()), buffer.size());
356356
EXPECT_EQ(data, "bc");
357-
EXPECT_THAT(stream->Position(), HasValue(::testing::Eq(5)));
357+
358+
ASSERT_THAT(stream->Seek(5), IsOk());
359+
std::array<std::byte, 1> next;
360+
ICEBERG_UNWRAP_OR_FAIL(auto bytes_read, stream->Read(next));
361+
ASSERT_EQ(bytes_read, 1);
362+
EXPECT_EQ(next[0], std::byte{'f'});
358363
}
359364

360-
TEST_F(LocalFileIOTest, ReadFullyPreservesPosition) {
361-
ASSERT_NO_FATAL_FAILURE(VerifyReadFullyPreservesPosition(file_io_, temp_filepath_));
365+
TEST_F(LocalFileIOTest, ReadFullyReadsFromAbsolutePosition) {
366+
ASSERT_NO_FATAL_FAILURE(
367+
VerifyReadFullyReadsFromAbsolutePosition(file_io_, temp_filepath_));
362368
}
363369

364-
TEST_F(LocalFileIOTest, StdReadFullyPreservesPosition) {
370+
TEST_F(LocalFileIOTest, StdReadFullyReadsFromAbsolutePosition) {
365371
auto file_io = std::make_shared<test::StdFileIO>();
366-
ASSERT_NO_FATAL_FAILURE(VerifyReadFullyPreservesPosition(file_io, temp_filepath_));
372+
ASSERT_NO_FATAL_FAILURE(
373+
VerifyReadFullyReadsFromAbsolutePosition(file_io, temp_filepath_));
367374
}
368375

369376
TEST_F(LocalFileIOTest, StdReadKeepsPositionAvailableAtEof) {

0 commit comments

Comments
 (0)