db.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef DB_H
  2. #define DB_H
  3. #include "db_access.h"
  4. #include "cache.h"
  5. typedef struct
  6. {
  7. db_index_t index;
  8. cache_t* cache;
  9. } db_t;
  10. typedef db_data_interval_t db_data_set_t;
  11. typedef struct
  12. {
  13. db_time_t start;
  14. db_time_t end;
  15. } db_time_interval_t;
  16. typedef struct
  17. {
  18. int n;
  19. db_time_interval_t data[256];
  20. } db_time_interval_set_t;
  21. db_interval_t db_inter_get(db_t* db, db_date_t d);
  22. /**
  23. * Init (load) database (only metadata)
  24. * \param db An allocate db_t object (output)
  25. * \return Errno if errors occur else 0
  26. */
  27. int db_init(db_t* db);
  28. /**
  29. * Free the content of a db_t object
  30. * \param db The database
  31. */
  32. void db_free(db_t* db);
  33. db_data_set_t* db_get(db_t* db, db_time_t* start, db_time_t* end);
  34. /**
  35. * Load an entire data interval from databse
  36. * \param db The input database
  37. * \param ds The start date
  38. * \param dsm The start time (in microseconds)
  39. * \param de The end date
  40. * \param dem The end time (in microseconds)
  41. */
  42. db_data_interval_t* db_load_fault(db_t* db, db_date_t ds, uint32_t dsm,
  43. db_date_t de, uint32_t dem);
  44. int db_load_page(db_t* db, uint64_t page, db_data_t* buffer);
  45. #endif