Skip to content

Commit

Permalink
Merge pull request #2014 from lijun99/vrt_mmap
Browse files Browse the repository at this point in the history
VRTRawRasterBand: add GetVirtualMemAuto interface to enable mmap io
  • Loading branch information
rouault committed Nov 13, 2019
2 parents 54536a3 + c035018 commit b8ece9b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gdal/frmts/vrt/vrtdataset.h
Expand Up @@ -817,6 +817,11 @@ class CPL_DLL VRTRawRasterBand CPL_NON_FINAL: public VRTRasterBand

void ClearRawLink();

CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
int *pnPixelSpace,
GIntBig *pnLineSpace,
char **papszOptions ) override;

virtual void GetFileList( char*** ppapszFileList, int *pnSize,
int *pnMaxSize, CPLHashSet* hSetFiles ) override;
};
Expand Down Expand Up @@ -1357,7 +1362,7 @@ class VRTDimension final: public GDALDimension
const CPLXMLNode* psNode);

std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;

bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable) override;

void Serialize(CPLXMLNode* psParent) const;
Expand Down
21 changes: 21 additions & 0 deletions gdal/frmts/vrt/vrtrawrasterband.cpp
Expand Up @@ -322,6 +322,27 @@ void VRTRawRasterBand::ClearRawLink()
m_pszSourceFilename = nullptr;
}

/************************************************************************/
/* GetVirtualMemAuto() */
/************************************************************************/

CPLVirtualMem * VRTRawRasterBand::GetVirtualMemAuto( GDALRWFlag eRWFlag,
int *pnPixelSpace,
GIntBig *pnLineSpace,
char **papszOptions )

{
// check the pointer to RawRasterBand
if( m_poRawRaster == nullptr )
{
// use the super class method
return VRTRasterBand::GetVirtualMemAuto(eRWFlag, pnPixelSpace, pnLineSpace, papszOptions);
}
// if available, use the RawRasterBand method (use mmap if available)
return m_poRawRaster->GetVirtualMemAuto(eRWFlag, pnPixelSpace, pnLineSpace, papszOptions);
}


/************************************************************************/
/* XMLInit() */
/************************************************************************/
Expand Down

0 comments on commit b8ece9b

Please sign in to comment.