HailDB: A NoSQL API Direct to InnoDB

Embed Size (px)

DESCRIPTION

HailDB is a project that maintains InnoDB as a shared library (forked from embedded_innodb). It provides an API direct to InnoDB without any pesky SQL in front of it. This session is an introduction to HailDB, followed by an introduction to programming it.- Overview of InnoDB/HailDB- Overview of what HailDB provides- use cases- Examples of usage- API examples

Citation preview

  • 1. HailDB A NoSQL API direct to InnoDB Stewart Smith

2. What is HailDB? 3. What is InnoDB? 4. ACID database enigne 5. Commonly found in MySQL 6. Originally was separate 7. Been in MySQL forever 8. HailDB and InnoDB have... 9. Features you'd expect 10. Exposed through SQL 11. Really an interface to an InnoDB API 12. InnoDB internal API 13. Complex and sometimes MySQL specific 14. HailDB history 15. Embedded InnoDB 16. A couple of releases... 17. Abandoned? 18. Enter HailDB 19. Completely free and open source project 20. http://www.haildb.com 21. Launchpad 22. $ bzr branch lp:haildb 23. Tarball releases 24. Packaged in Ubuntu Natty 25. Packaged in drizzle-developers PPA 26. Also RPMs 27. (Currently) no Win32 release 28. Source compatible with embedded_innodb 29. libhaildb.so 30. haildb.h 31. Pandora-build provides autoconf foo 32. What HailDB Provides 33. Cursor based API 34. Transactions 35. Key lookups 36. Index scans 37. DIY Joins 38. Updates 39. Inserts 40. Deletes 41. Use cases 42. Embedded, fast, concurrent,relational database 43. Not arbitrary queries 44. Not SQL 45. High-Performance Storage Services Using HailDB and Java Ballroom E, 2:50pm Thursday 46. Engine for SQL DB 47. Using the API 48. ib_init() 49. ib_cfg_set_int() 50. ib_cfg_set_bool_on|off() 51. ib_cfg_set_text() 52. Set callbacks 53. ib_startup(barracuda) 54. ib_shutdown(flag) 55. DDL 56. ib_database_create() ib_database_drop() 57. ib_table_create() 58. ib_table_drop() 59. ib_table_truncate() 60. Transactions 61. ib_trx_begin() 62. ib_trx_commit() ib_trx_rollback() 63. ib_savepoint_take() ib_savepoint_release() ib_savepoint_rollback() 64. Cursors 65. ib_cursor_open_table() 66. ib_cursor_close() 67. ib_cursor_reset() 68. Position a cursor, perform row operations 69. Tuples 70. Represents columns from table record or secondary index 71. ib_tpl_t tpl = ib_clust_read_tuple_create(cursor) 72. ib_col_set_value() 73. ib_col_get_value() 74. Examples 75. Full Table Scan 76. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 77. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 78. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 79. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 80. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors */ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 81. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 82. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 83. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 84. ib_tpl_t tpl= ib_clust_read_tuple_create(crsr); err= ib_cursor_first(crsr); while (err == DB_SUCCESS) { err= ib_cursor_read_row(crsr, tpl); /* Handle locking and timeout errors*/ ib_tuple_read...(); err= ib_cursor_next(crsr); /* Handle locking and timeout errors */ tpl= ib_tuple_clear(tpl); } ib_tuple_delete(tpl); 85. Insert a row 86. ib_err_t err; ib_tpl_t tpl; tpl= ib_clust_read_tuple_create(crsr); /* INSERT VALUES (a, b, 100); */ ib_col_set_value(tpl, 0, a, strlen(a)); ib_col_set_value(tpl, 1, b, strlen(b)); ib_tuple_write_i32(tpl, 2, 100); err= ib_cursor_insert_row(crsr, tpl); /* Handle errors. e.g. duplicate key */ ib_tuple_delete(tpl); 87. ib_err_t err; ib_tpl_t tpl; tpl= ib_clust_read_tuple_create(crsr); /* INSERT VALUES (a, b, 100); */ ib_col_set_value(tpl, 0, a, strlen(a)); ib_col_set_value(tpl, 1, b, strlen(b)); ib_tuple_write_i32(tpl, 2, 100); err= ib_cursor_insert_row(crsr, tpl); /* Handle errors. e.g. duplicate key */ ib_tuple_delete(tpl); 88. ib_err_t err; ib_tpl_t tpl; tpl= ib_clust_read_tuple_create(crsr); /* INSERT VALUES (a, b, 100); */ ib_col_set_value(tpl, 0, a, strlen(a)); ib_col_set_value(tpl, 1, b, strlen(b)); ib_tuple_write_i32(tpl, 2, 100); err= ib_cursor_insert_row(crsr, tpl); /* Handle errors. e.g. duplicate key */ ib_tuple_delete(tpl); 89. ib_err_t err; ib_tpl_t tpl; tpl= ib_clust_read_tuple_create(crsr); /* INSERT VALUES (a, b, 100); */ ib_col_set_value(tpl, 0, a, strlen(a)); ib_col_set_value(tpl, 1, b, strlen(b)); ib_tuple_write_i32(tpl, 2, 100); err= ib_cursor_insert_row(crsr, tpl); /* Handle errors. e.g. duplicate key */ ib_tuple_delete(tpl); 90. ib_err_t err; ib_tpl_t tpl; tpl= ib_clust_read_tuple_create(crsr); /* INSERT VALUES (a, b, 100); */ ib_col_set_value(tpl, 0, a, strlen(a)); ib_col_set_value(tpl, 1, b, strlen(b)); ib_tuple_write_i32(tpl, 2, 100); err= ib_cursor_insert_row(crsr, tpl); /* Handle errors. e.g. duplicate key */ ib_tuple_delete(tpl); 91. ib_err_t err; ib_tpl_t tpl; tpl= ib_clust_read_tuple_create(crsr); /* INSERT VALUES (a, b, 100); */ ib_col_set_value(tpl, 0, a, strlen(a)); ib_col_set_value(tpl, 1, b, strlen(b)); ib_tuple_write_i32(tpl, 2, 100); err= ib_cursor_insert_row(crsr, tpl); /* Handle errors. e.g. duplicate key */ ib_tuple_delete(tpl); 92. Updating a row 93. Delete 94. ib_tuple_delete() 95. WHERE clause 96. Table statistics 97. HailDB 98. Questions?