Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
|
Data that a user wishes to access can be potentially be stored on a variety of different systems e.g. local filesystems, http(s) locations, cloud-based storage systems, etc. Regardless of the storage mechanism, the actual operations that may be needed are the same e.g. read from a file, write to a file, create a file, etc. So the Grassroots system abstracts out these actions to an API, the Handlers API and has separate components for each of the storage mechanisms.
This allows developers to code to the Handlers API for doing file access and not need to worry where the underlying files are actually stored.
The currently available Handlers are:
Handlers work upon data files represented by the Resource datatype. For accessing via a Handler, the fields of interest in this datatype are re_protocol_s and re_value_s.
re_protocol_s is the value that declares the underlying storage mechanism e.g. http, file, etc. and re_value_s is the path to the file/directory of interest. For example, the uri http://earlham.ac.uk/data/wheat_assembly.fasta would have
and the file /opt/data/research.pdf would have
Within the handler_utils.h
file, there is a function GetResourceHandler
that determines the correct Handler for as given Resource
Once you have this Handler you can then perform common I/O tasks with routines analogous to those provided by the standard C library such as fread
, fwrite
, fseek
, etc. Further details are provided by the Handler API documentation.
We will now give some examples that show some standard C file I/O code and the equivalent using Handlers. The first is to open a file, seek 20 bytes in and read 16 characters into a buffer and return it. The first code section uses standard C library calls, and the code below use the Grassroots API equivalents.
Below is the equivalent code using the Handlers API
The complete list of Handler functions is shown below and clicking upon the function names will take you to the appropriate API documentation.