-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added DropCache to GDALDataset #8940
Conversation
DropCache() release cache blocks but does not write cache to disk. It is similar tp FlushCache(true) but does not assume that the dataset will be closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides my comments, looks good to me.
We'd need a test for that. Presumably in autotest/cpp/test_gdal.cpp (run by autotest/cpp/gdal_unit_test)
@@ -537,6 +537,7 @@ class CPL_DLL GDALDataset : public GDALMajorObject | |||
Bands GetBands(); | |||
|
|||
virtual CPLErr FlushCache(bool bAtClosing = false); | |||
virtual CPLErr DropCache(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that need to be virtual ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly it is just copy/paste from FlushCache().
I think virtual
is harmless and make it ready for future specific implementations (if any)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
gcore/gdal_priv.h
Outdated
@@ -1188,7 +1189,7 @@ class GDALAbstractBandBlockCache | |||
|
|||
int m_nInitialDirtyBlocksInFlushCache = 0; | |||
int m_nLastTick = -1; | |||
bool m_bWriteDirtyBlocks = true; | |||
size_t m_bWriteDirtyBlocksDisabled = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'b' is for boolean. So this should be "m_nWriteDirtyBlocksDisabled"
@@ -1412,6 +1417,7 @@ class CPL_DLL GDALRasterBand : public GDALMajorObject | |||
// New OpengIS CV_SampleDimension stuff. | |||
|
|||
virtual CPLErr FlushCache(bool bAtClosing = false); | |||
virtual CPLErr DropCache(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual needed ?
gcore/gdaldataset.cpp
Outdated
* @return CE_None in case of success | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return CE_None in case of success | |
*/ | |
* @return CE_None in case of success | |
* @since 3.9 | |
*/ |
* \brief Drop all write cached data | ||
* | ||
* @see GDALDataset::DropCache(). | ||
* @return CE_None in case of success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return CE_None in case of success | |
* @return CE_None in case of success | |
* @since 3.9 |
* | ||
* This method is the same as the C function GDALDropRasterCache(). | ||
* | ||
* @return CE_None on success. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return CE_None on success. | |
* @return CE_None on success. | |
* @since 3.9 |
/** | ||
* \brief Drop raster data cache. | ||
* | ||
* @see GDALRasterBand::DropCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @see GDALRasterBand::DropCache() | |
* @see GDALRasterBand::DropCache() | |
* @since 3.9 |
also removed a useless comment inherited from copy/paste
What kind of test should be written ? |
something along:
|
m_bWriteDirtyBlocks -> m_nWriteDirtyBlocksDisabled
I was not able to run the test, there's something broken with my gtests |
for correct code formatting, you need to install pre-commit. Cf https://gdal.org/development/dev_practices.html#commit-hooks for instructions |
Does |
yes, that mostly obsoletes it. That said there are a few drivers that use now the bAtClosing flag to save some work (cf frmts/rmf/rmfdataset.cpp) |
autotest/cpp/test_gdal.cpp
Outdated
@@ -3491,4 +3491,48 @@ TEST_F(test_gdal, open_shared_open_options) | |||
} | |||
} | |||
|
|||
// Test GDAL_OF_SHARED flag and open options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment should be updated or removed
@chacha21 are you done with this PR? |
As long as you have no more comments, I have nothing remaining to be committed. I ran the test code manually and it behaved as expected, though. (GDALChecksumImage returns 0) |
DropCache() release cache blocks but does not write cache to disk. It is similar to FlushCache(true) but does not assume that the dataset will be closed.
proposal for #8938