MCPcopy Create free account
hub / github.com/PDAL/PDAL / initialize

Method initialize

plugins/arrow/io/ArrowReader.cpp:229–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229void ArrowReader::initialize()
230{
231 if (Utils::iequals(FileUtils::extension(m_filename), ".feather"))
232 {
233 m_formatType = arrowsupport::Feather;
234 }
235 else if (Utils::iequals(FileUtils::extension(m_filename), ".parquet"))
236 {
237 m_formatType = arrowsupport::Parquet;
238 }
239 if (m_formatTypeString.size())
240 {
241
242 if (Utils::iequals(m_formatTypeString, "geoarrow"))
243 m_formatType = arrowsupport::Feather;
244 else if (Utils::iequals(m_formatTypeString, "geoparquet"))
245 m_formatType = arrowsupport::Parquet;
246 else
247 throwError("Unknown format type " + m_formatTypeString);
248
249 }
250
251 auto result = arrow::io::ReadableFile::Open(m_filename);
252 if (result.ok())
253 m_file = result.ValueOrDie();
254 else
255 {
256 std::stringstream msg;
257 msg << "Unable to open '" << m_filename << "' for to read data with message '"
258 << result.status().ToString() <<"'";
259 throwError(msg.str());
260 }
261
262 if (m_formatType == arrowsupport::Feather)
263 {
264 auto status = arrow::ipc::RecordBatchFileReader::Open(m_file);
265 if (!status.ok())
266 {
267 std::stringstream msg;
268 msg << "Unable to create RecordBatchFileReader for file '" << m_filename << "' with message '"
269 << result.status().ToString() <<"'";
270 throwError(msg.str());
271 }
272
273 m_ipcReader = status.ValueOrDie();
274 m_batchCount = m_ipcReader->num_record_batches();
275
276 const auto fields = m_ipcReader->schema()->fields();
277
278 for (const auto& field: fields)
279 {
280 auto metadata = field->metadata();
281 if (metadata)
282 if (metadata->Contains("ARROW:extension:metadata"))
283 loadArrowGeoMetadata(metadata);
284 }
285
286 m_currentBatchIndex = 0;

Callers

nothing calls this directly

Calls 6

iequalsFunction · 0.85
extensionFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45
CloseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected