MCPcopy Create free account
hub / github.com/apache/arrow / GetFileSource

Method GetFileSource

cpp/src/arrow/dataset/file_csv_test.cc:82–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 }
81
82 std::unique_ptr<FileSource> GetFileSource(std::string csv) {
83 if (GetCompression() == Compression::UNCOMPRESSED) {
84 return std::make_unique<FileSource>(Buffer::FromString(std::move(csv)));
85 }
86 std::string path = "test.csv";
87 switch (GetCompression()) {
88 case Compression::type::GZIP:
89 path += ".gz";
90 break;
91 case Compression::type::ZSTD:
92 path += ".zstd";
93 break;
94 case Compression::type::LZ4_FRAME:
95 path += ".lz4";
96 break;
97 case Compression::type::BZ2:
98 path += ".bz2";
99 break;
100 default:
101 // No known extension
102 break;
103 }
104 EXPECT_OK_AND_ASSIGN(auto fs, fs::internal::MockFileSystem::Make(fs::kNoTime, {}));
105 EXPECT_OK_AND_ASSIGN(auto codec, util::Codec::Create(GetCompression()));
106 EXPECT_OK_AND_ASSIGN(auto buffer_writer, fs->OpenOutputStream(path));
107 EXPECT_OK_AND_ASSIGN(auto stream,
108 io::CompressedOutputStream::Make(codec.get(), buffer_writer));
109 ARROW_EXPECT_OK(stream->Write(csv));
110 ARROW_EXPECT_OK(stream->Close());
111 EXPECT_OK_AND_ASSIGN(auto info, fs->GetFileInfo(path));
112 return std::make_unique<FileSource>(info, fs, GetCompression());
113 }
114
115 CsvFragmentScanOptions MakeDefaultFormatOptions() {
116 CsvFragmentScanOptions scan_opts;

Callers

nothing calls this directly

Calls 4

GetCompressionFunction · 0.85
FromStringFunction · 0.85
WriteMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected