Skip to content

Commit

Permalink
ogr2ogr: remove hack related to Parquet dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 4, 2024
1 parent 2ae4176 commit b0f0244
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
40 changes: 0 additions & 40 deletions apps/ogr2ogr_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5747,46 +5747,6 @@ bool LayerTranslator::TranslateArrow(

schema.release(&schema);

// Ugly hack to work around https://github.com/OSGeo/gdal/issues/9497
// Deleting a RecordBatchReader obtained from arrow::dataset::Scanner.ToRecordBatchReader()
// is a lengthy operation since all batches are read in its destructors.
// Here we ask to our custom I/O layer to return in error to short circuit
// that lengthy operation.
if (auto poDS = psInfo->m_poSrcLayer->GetDataset())
{
if (poDS->GetLayerCount() == 1 && poDS->GetDriver() &&
EQUAL(poDS->GetDriver()->GetDescription(), "PARQUET"))
{
bool bStopIO = false;
const char *pszArrowStopIO =
CPLGetConfigOption("OGR_ARROW_STOP_IO", nullptr);
if (pszArrowStopIO && CPLTestBool(pszArrowStopIO))
{
bStopIO = true;
}
else if (!pszArrowStopIO)
{
std::string osExePath;
osExePath.resize(1024);
if (CPLGetExecPath(osExePath.data(),
static_cast<int>(osExePath.size())))
{
osExePath.resize(strlen(osExePath.data()));
if (strcmp(CPLGetBasename(osExePath.data()), "ogr2ogr") ==
0)
{
bStopIO = true;
}
}
}
if (bStopIO)
{
CPLSetConfigOption("OGR_ARROW_STOP_IO", "YES");
CPLDebug("OGR2OGR", "Forcing interruption of Parquet I/O");
}
}
}

stream.release(&stream);
return bRet;
}
Expand Down
5 changes: 0 additions & 5 deletions ogr/ogrsf_frmts/arrow_common/ograrrowrandomaccessfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ class OGRArrowRandomAccessFile final : public arrow::io::RandomAccessFile
return arrow::Status::IOError("File requested to close");

// CPLDebug("ARROW", "Reading %d bytes", int(nbytes));
// Ugly hack for https://github.com/OSGeo/gdal/issues/9497
if (CPLGetConfigOption("OGR_ARROW_STOP_IO", nullptr))
{
return arrow::Result<std::shared_ptr<arrow::Buffer>>();
}
auto buffer = arrow::AllocateResizableBuffer(nbytes);
if (!buffer.ok())
{
Expand Down

0 comments on commit b0f0244

Please sign in to comment.