Successfully reported this slideshow.
Your SlideShare is downloading. ×

JDBC Driver for Aerospike - Meetup Dec 2019

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Apache spark Intro
Apache spark Intro
Loading in …3
×

Check these out next

1 of 33 Ad

More Related Content

Slideshows for you (20)

Similar to JDBC Driver for Aerospike - Meetup Dec 2019 (20)

Advertisement

Recently uploaded (20)

Advertisement

JDBC Driver for Aerospike - Meetup Dec 2019

  1. 1. JDBC driver for Aerospike By Alexander Radzin 1
  2. 2. Aerospike clients 2
  3. 3. Popular no SQL bigdata databases and datastores 3
  4. 4. Why? ● SQL is for relational databases ● NoSQL is built differently ● NoSQL does not need SQL by definition 4
  5. 5. SQL advantages ● Standard ● Powerful ● Widely supported ● Allows codeless integration with other systems 5
  6. 6. What’s wrong with AQL? ● AQL is SQL-like but not SQL ● AQL implements only small subset of SQL ○ No complex where expressions, order by, join, group by, having , functions ● There is no JDBC driver for AQL dialect 6
  7. 7. SQL meets Java 7
  8. 8. SQL compliant driver allows codeless integration UI tools Reporting tools ETL tools 8
  9. 9. Aerospike JDBC driver JDBC driver 9
  10. 10. Project home ● The driver is available on github. ● Please refer to README.md for more information 10
  11. 11. Quick start Add driver to your classpath Copy aerospike-jdbc-driver-all.jar to your lib folder <dependency> <groupId>com.nosqldriver</groupId> <artifactId>aerospike-jdbc-driver</artifactId> <version>1.0-SNAPSHOT</version> </dependency> compile group: 'com.nosqldriver', name: 'aerospike-jdbc-driver', version: '1.0-SNAPSHOT' 11 The driver is still not available in public repository. If you want to use it via maven or gradle deploy it to your private repository.
  12. 12. Connect to UI tool Quick start 12
  13. 13. Write code Connection conn = DriverManager.getConnection("jdbc:aerospike:localhost/test"); ResultSet rs = conn.createStatement().executeQuery("select * from people"); while (rs.next()) { rs.getString(1); rs.getInt("year_of_birth"); } 13
  14. 14. SQL compliance: statements ● DDL ○ CREATE STRING INDEX ○ CREATE NUMERIC INDEX ○ DROP INDEX ○ USE ● DML ○ INSERT ○ SELECT ○ UPDATE ○ DELETE ○ UNION and UNION ALL List index is not supported right now 14
  15. 15. SQL compliance: namespace ● Namespace is treated as JDBC catalog ● Connection can include namespace. In this case namespace could be omitted in SQL queries ● If connection does not include namespace it must be written in query ● USE statement can be used to switch to other namespace Connection string SQL query jdbc:aerospike:localhost/ test select * from people jdbc:aerospike:localhost select * from test.people 15
  16. 16. SQL compliance: SELECT ● select * from TABLE ● select name1, name2 from TABLE ● LIMIT, OFFSET ● WHERE ● Calculations ○ select year_of_birth-1900 from people ○ select 1+2 16
  17. 17. SQL compliance: WHERE ● Comparison operators: =, !=, <>, <, >, <=, >=, between, in, like ● Transparent access to indexed and not indexed field ● Special keyword PK is used to refer to the primary key ● Any combination of and/or keywords and parentheses are supported ● In complex queries that include both indexed and non indexed fields the first indexed field will use filter API, all others will use predicate API ● PK supports = and != only 17
  18. 18. SQL compliance: INSERT, UPDATE, DELETE insert into people (PK, first_name, last_name, year_of_birth, kids_count) values (1, 'John', 'Lennon', 1940, 2) update people set band='Beatles' delete from people where PK=1 delete from people where year_of_birth=1940 18
  19. 19. Aggregation Functions ● count ● sum ● avg ● sumsqs ● min ● max ● Implemented using lua script ● Names are case sensitive 19
  20. 20. Data manipulation functions ● String functions ○ len ○ ascii ○ char ○ charindex ○ lower ○ upper ○ str ○ substr ○ space ○ concat ○ reverse ● Date/Time functions ○ now ○ year ○ month ○ dayofmonth ○ hour ○ minute ○ second ○ millisecond ○ date ○ epoch Please refer to README.md for more information ● Implemented using javascript ● Names are case sensitive ● Functions can be called using lower and upper case names only ○ LEN & len are OK ○ Len will not work 20
  21. 21. Group by select year_of_birth, count(*) from people group by year_of_birth having count(*) > 0 Group by is implemented in lua script 21
  22. 22. Having select year_of_birth, count(*) from people group by year_of_birth having count(*) > 0 select year_of_birth, count(*) as n from people group by year_of_birth having n = 4 - 2 22
  23. 23. Join select first_name, g.name as guitar, k.name as keyboards from people as p join guitars as g on p.id=g.person_id join keyboards as k on p.id=k.person_id Elements of joined table are requested one-by-one. 23
  24. 24. Nested select statements select first_name, year_of_birth from ( select year_of_birth, first_name from ( select first_name, last_name, year_of_birth from people ) ) 24
  25. 25. Schema Schema is discovered from data ● Schema is runtime information only. We do not store it anywhere like Spring Data for Aerospike 25
  26. 26. Data types ● String (varchar) ● Number ● Blob (mapped to byte array) ● Clob & NClob (mapped to string) ● SQL Date, Time, Timestamp (stored as serializable java objects) ● Array (mapped to Aerospike list). Supports all primitive types Geo location and map are not supported right now 26
  27. 27. API ● Statement ● Prepared statement Prepared statement can be used with select and insert only and not with update and delete right now. select first_name, last_name, kids from people where PK=? insert into people (PK, first_name, last_name, year_of_birth, kids_count) values (?, ?, ?, ?, ?) 27
  28. 28. Nearest future plans ● Respect fetch size > 1. ○ This will improve schema discovery ○ This should significantly improve performance of join ● Deploy artifact to public maven repository ● Add list index ● Add list operations: append, prepend, remove, filter ● Implement prepared statement for update and delete ● Improve using predicates and filters in where clause ● Validate integration with various tools (Pentaho, Tableau, Equalum etc) ● Write documentation ● Support SQL scripts 28
  29. 29. Further future plans ● Persistent data schema ● Comprehensive set of functions ● Configuration parameters ● Out-of-heap cache ● Licensing ● UDF ● Extendability 29
  30. 30. Project info ● GitHub: https://github.com/alexradzin/aerospike-jdbc-driver ● Gradle based project ○ ./gradle clean build ○ ./gradle clean build -x tests ○ Tests run against locally installed Aerospike ○ ./gradle fatJar ● Code: java, javascript, lua ○ Main: 12K lines ○ Test: 6K lines ● TDD ○ >600 tests ○ 87% test coverage 30
  31. 31. You are welcome to... Try to use driver Check out the source code Report bugs Comment on the code Pull requests are very welcome Suggest improvements, features, ideas based on needs of real users 31
  32. 32. Q&A 32
  33. 33. Thank you 33

×