-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
VSI plugins #1289
VSI plugins #1289
Conversation
@tbonfort possible to share some of that work so we can improve what is in GDAL core? |
@rcoup I'm not able to share more code, but there really is nothing special to it. I should have explained a bit more that the use case is to call back into scripted language (python, go in our case), so you can easily add your own logging semantics, error handling, authentication, etc... i.e. nothing really applicable to the core gdal implementation. Two take-backs that could be useful for vsicurl et. al. when dealing with COGs:
|
cc @sgillies , could this spark some interest for rasterio ? |
@tbonfort I'm interested! |
If anyone has concerns on the interface speak up. I'll merge this soon otherwise |
I'm wondering if it would make sense to add a way for the callbacks to explicitely return an error condition, without relying on it to correctly set errno and/or call CPLError. Something in the lines of: typedef struct {
int code;
char *message
} CallbackError;
typedef size_t (*VSIFilesystemPluginReadCallback) ( void *pFile,
void *pBuffer, size_t nSize, size_t nCount , error *CallbackError); |
What is the advantage of this compared to the callback implementation calling VSIError / CPLError ? |
I was thinking it could be easier for the e.g. python code to set an error message, but I'm fine if that is handled by the C callback function itself. |
Yes that's what I mentionned. In some rare circumstances it might help not to merge consecutive ranges, but this is not a good default
There's not so many places where that could be done, except in the VSIFReadMultiRangeL() function itself, that will be the one generally called by drivers. The VSICurlHandle::ReadMultiRange() implementation probably saves a buffer allocation/copy compared to your generic implementation though. |
Lets move the discussion about multi range requests to #1295 |
@tbonfort Are you happy with the PR as it ? |
@rouault ready for merge, can I let you squash this through the github interface to avoid re-running the CI? |
Done |
@mmomtchev there are no public implementations that I know of, and the only documentation available is the doxygen one. There is however a similar implementation that does not use this plugin but replicates its intent at https://github.com/airbusgeo/godal/blob/ee62c71eebf81d25ef07983ada2e4ba6ea7baaf7/godal.cpp#L1102 and is used to hand off vsi read-only access to a go function. |
@mmomtchev @tbonfort there's a recent example in rasterio/rasterio#2141. |
This PR allows to dynamically register a VSI handler at runtime by passing a select number of callback functions. Our principle use-case is to be able to bypass the vsicurl handler when accessing remote datasets, to provide observability, custom error handling, retrying, logging, fine-grained concurrency control, fine-grained caching, and better stability under heavily multi-threaded loads.