Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Add AQL driver (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshankly committed Apr 5, 2021
1 parent 838df8f commit 654d321
Show file tree
Hide file tree
Showing 11 changed files with 1,035 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -29,13 +29,15 @@ ct:
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/redis_cluster_non_nested_data_model.config --cover --cover_export_name=core_redis_cluster_non_nested_opt
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/redis_crdb_non_nested_data_model.config --cover --cover_export_name=core_redis_crdb_non_nested_opt
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/riak_non_nested_data_model.config --cover --cover_export_name=core_riak_non_nested_opt
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/aql_non_nested_data_model.config --cover --cover_export_name=core_aql_non_nested_opt
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/antidote_non_nested_data_model.config --cover --cover_export_name=http_antidote_non_nested_opt
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/cassandra_non_nested_data_model.config --cover --cover_export_name=http_cassandra_non_nested_opt
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/ets_nested_data_model.config --cover --cover_export_name=http_ets_nested
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/ets_non_nested_data_model.config --cover --cover_export_name=http_ets_non_nested
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/redis_cluster_non_nested_data_model.config --cover --cover_export_name=http_redis_cluster_non_nested_opt
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/redis_crdb_non_nested_data_model.config --cover --cover_export_name=http_redis_crdb_non_nested_opt
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/riak_non_nested_data_model.config --cover --cover_export_name=http_riak_non_nested_opt
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/aql_non_nested_data_model.config --cover --cover_export_name=http_aql_non_nested_opt

ct-antidote:
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/antidote_non_nested_data_model.config
Expand Down Expand Up @@ -63,6 +65,10 @@ ct-riak:
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/riak_non_nested_data_model.config
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/riak_non_nested_data_model.config

ct-aql:
${REBAR} ct --suite fmke_core_unit_test_SUITE.erl --config test/fmke_configs/aql_non_nested_data_model.config
${REBAR} ct --suite fmke_http_api_SUITE.erl --config test/fmke_configs/aql_non_nested_data_model.config

dialyzer:
${REBAR} dialyzer

Expand Down
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -37,11 +37,15 @@ Firstly, separating the application server from the workload generation componen
We have a generic interface for key-value stores (implemented as an Erlang behaviour) that is well specified, which makes supporting a new database as simple as writing a driver for it. Furthermore, pull requests with new drivers or optimizations for existing ones are accepted and welcomed.

## Supported data stores
- AntidoteDB
- AntidoteDB (the SQL-like interface offered by [AQL][11] is also supported)
- Cassandra
- Redis
- Riak KV

### Note about AQL schema:

When running the benchmark to evaluate the performance of AQL you have two options regarding the database schema. The file [priv/build_schema.aql](priv/build_schema.aql) creates the tables without foreign keys, and thus, the referential integrity mechanism of AQL is not used. To use the referential integrity mechanism, use the file [priv/build_schema_fk.aql](priv/build_schema_fk.aql), this version creates the tables with foreign keys.

## How the benchmark is deployed
By default FMKe keeps a connection pool to a single database node, and the workload generation is performed by [Lasp Bench][4].
To benchmark clustered databases with _n_ nodes, _n_ FMKe instances can be deployed, or alternatively one FMKe node can connect to multiple nodes (the exact number is dependent on the connection pool size).
Expand All @@ -67,3 +71,4 @@ Please check [the wiki](https://github.com/goncalotomas/FMKe/wiki) for detailed
[8]: https://github.com/goncalotomas/FMKe/blob/master/doc/FMK_DataModel.pdf
[9]: http://www.erlang.org/downloads
[10]: http://www.rebar3.org/
[11]: https://github.com/mrshankly/secure-aql
71 changes: 71 additions & 0 deletions priv/build_schema.aql
@@ -0,0 +1,71 @@
---------------------------------------------------------------
-- Database schema used when benchmarking AQL. Based on the
-- schema used for cassandra, see build_schema.cql.
--
-- AQL is an SQL-like interface for the AntidoteDB data store.
-- For more information and documentation see AQL's repository:
-- https://github.com/mrshankly/secure-aql
---------------------------------------------------------------

CREATE UPDATE-WINS TABLE FmkePatients (
ID int PRIMARY KEY,
Name varchar,
Address varchar
);

CREATE UPDATE-WINS TABLE FmkePharmacies (
ID int PRIMARY KEY,
Name varchar,
Address varchar
);

CREATE UPDATE-WINS TABLE FmkeMedicalStaff (
ID int PRIMARY KEY,
Name varchar,
Address varchar,
Speciality varchar
);

CREATE UPDATE-WINS TABLE FmkeTreatmentFacilities (
ID int PRIMARY KEY,
Name varchar,
Address varchar,
Type varchar
);

CREATE UPDATE-WINS TABLE FmkePrescriptions (
ID int PRIMARY KEY,
PatID int,
DocID int,
PharmID int,
DatePrescribed varchar,
DateProcessed varchar
);

CREATE UPDATE-WINS TABLE FmkePatientPrescriptions (
ID int PRIMARY KEY,
PatientID int,
PrescriptionID int
);
CREATE INDEX FmkePatientPrescriptionsPatientIdx ON FmkePatientPrescriptions (PatientID);

CREATE UPDATE-WINS TABLE FmkePharmacyPrescriptions (
ID int PRIMARY KEY,
PharmacyID int,
PrescriptionID int
);
CREATE INDEX FmkePharmacyPrescriptionsPharmacyIdx ON FmkePharmacyPrescriptions (PharmacyID);

CREATE UPDATE-WINS TABLE FmkeStaffPrescriptions (
ID int PRIMARY KEY,
StaffID int,
PrescriptionID int
);
CREATE INDEX FmkeStaffPrescriptionsStaffIdx ON FmkeStaffPrescriptions (StaffID);

CREATE UPDATE-WINS TABLE FmkePrescriptionDrugs (
ID int PRIMARY KEY,
PrescriptionID int,
Drug varchar
);
CREATE INDEX FmkePrescriptionDrugsPrescriptionIdx ON FmkePrescriptionDrugs (PrescriptionID);
74 changes: 74 additions & 0 deletions priv/build_schema_fk.aql
@@ -0,0 +1,74 @@
---------------------------------------------------------------
-- Database schema used when benchmarking AQL. Based on the
-- schema used for cassandra, see build_schema.cql.
--
-- This schema version uses foreign keys and the referential
-- integrity mechanism of AQL.
--
-- AQL is an SQL-like interface for the AntidoteDB data store.
-- For more information and documentation see AQL's repository:
-- https://github.com/mrshankly/secure-aql
---------------------------------------------------------------

CREATE UPDATE-WINS TABLE FmkePatients (
ID int PRIMARY KEY,
Name varchar,
Address varchar
);

CREATE UPDATE-WINS TABLE FmkePharmacies (
ID int PRIMARY KEY,
Name varchar,
Address varchar
);

CREATE UPDATE-WINS TABLE FmkeMedicalStaff (
ID int PRIMARY KEY,
Name varchar,
Address varchar,
Speciality varchar
);

CREATE UPDATE-WINS TABLE FmkeTreatmentFacilities (
ID int PRIMARY KEY,
Name varchar,
Address varchar,
Type varchar
);

CREATE UPDATE-WINS TABLE FmkePrescriptions (
ID int PRIMARY KEY,
PatID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePatients(ID),
DocID int FOREIGN KEY UPDATE-WINS REFERENCES FmkeMedicalStaff(ID),
PharmID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePharmacies(ID),
DatePrescribed varchar,
DateProcessed varchar
);

CREATE UPDATE-WINS TABLE FmkePatientPrescriptions (
ID int PRIMARY KEY,
PatientID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePatients(ID),
PrescriptionID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePrescriptions(ID)
);
CREATE INDEX FmkePatientPrescriptionsPatientIdx ON FmkePatientPrescriptions (PatientID);

CREATE UPDATE-WINS TABLE FmkePharmacyPrescriptions (
ID int PRIMARY KEY,
PharmacyID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePharmacies(ID),
PrescriptionID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePrescriptions(ID)
);
CREATE INDEX FmkePharmacyPrescriptionsPharmacyIdx ON FmkePharmacyPrescriptions (PharmacyID);

CREATE UPDATE-WINS TABLE FmkeStaffPrescriptions (
ID int PRIMARY KEY,
StaffID int FOREIGN KEY UPDATE-WINS REFERENCES FmkeMedicalStaff(ID),
PrescriptionID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePrescriptions(ID)
);
CREATE INDEX FmkeStaffPrescriptionsStaffIdx ON FmkeStaffPrescriptions (StaffID);

CREATE UPDATE-WINS TABLE FmkePrescriptionDrugs (
ID int PRIMARY KEY,
PrescriptionID int FOREIGN KEY UPDATE-WINS REFERENCES FmkePrescriptions(ID),
Drug varchar
);
CREATE INDEX FmkePrescriptionDrugsPrescriptionIdx ON FmkePrescriptionDrugs (PrescriptionID);
4 changes: 3 additions & 1 deletion rebar.config
Expand Up @@ -10,7 +10,9 @@
%% Redis Cluster
{eredis_cluster, {git, "https://github.com/adrienmo/eredis_cluster", {tag, "0.5.12"}}},
%% Riak KV
{riak_client, "~>2.5"}
{riak_client, "~>2.5"},
%% AQL client
{aqlc, "~>1.0"}
]}.


Expand Down
25 changes: 23 additions & 2 deletions rebar.lock
@@ -1,6 +1,7 @@
{"1.1.0",
{"1.2.0",
[{<<"antidote_pb_codec">>,{pkg,<<"antidote_pb_codec">>,<<"0.1.1">>},1},
{<<"antidotec_pb">>,{pkg,<<"antidotec_pb">>,<<"0.2.8">>},0},
{<<"aqlc">>,{pkg,<<"aqlc">>,<<"1.0.2">>},0},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.6.3">>},0},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.7.3">>},1},
{<<"eredis">>,{pkg,<<"eredis">>,<<"1.2.0">>},1},
Expand All @@ -13,6 +14,7 @@
{<<"hamcrest">>,{pkg,<<"basho_hamcrest">>,<<"0.4.1">>},2},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.10.0">>},0},
{<<"lager">>,{pkg,<<"lager">>,<<"3.7.0">>},0},
{<<"paillier">>,{pkg,<<"paillier">>,<<"1.0.0">>},1},
{<<"poolboy">>,{pkg,<<"poolboy">>,<<"1.5.2">>},0},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},1},
{<<"riak_client">>,{pkg,<<"riak_client">>,<<"2.5.3">>},0},
Expand All @@ -21,6 +23,7 @@
{pkg_hash,[
{<<"antidote_pb_codec">>, <<"29891F77FB5DC8240495C425160EA152E9CA5753B7137E1866D9BA279F0F997B">>},
{<<"antidotec_pb">>, <<"70350652AE269BC561DA6DCC54DB6A1CFF203E01686E735C1341EFD925DEE598">>},
{<<"aqlc">>, <<"65299AB2878126EBE582DC52D6FE6044C03B24141ED0A89079DEADF71F114B81">>},
{<<"cowboy">>, <<"99AA50E94E685557CAD82E704457336A453D4ABCB77839AD22DBE71F311FCC06">>},
{<<"cowlib">>, <<"A7FFCD0917E6D50B4D5FB28E9E2085A0CEB3C97DEA310505F7460FF5ED764CE9">>},
{<<"eredis">>, <<"0B8E9CFC2C00FA1374CD107EA63B49BE08D933DF2CF175E6A89B73DD9C380DE4">>},
Expand All @@ -29,8 +32,26 @@
{<<"hamcrest">>, <<"FB7B2C92D252A1E9DB936750B86089ADDAEBEB8F87967FB4BBDDA61E8863338E">>},
{<<"jsx">>, <<"77760560D6AC2B8C51FD4C980E9E19B784016AA70BE354CE746472C33BEB0B1C">>},
{<<"lager">>, <<"563AB17CD32134A3DD17EC3B3622E6D8F827506AA4F8C489158879BED87D980B">>},
{<<"paillier">>, <<"65295A561BD3379961563B4F1E1EC41096139EF6E701AB61BF0D117B009C7DE4">>},
{<<"poolboy">>, <<"392B007A1693A64540CEAD79830443ABF5762F5D30CF50BC95CB2C1AAAFA006B">>},
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>},
{<<"riak_client">>, <<"6B78373E576D80C7020BCBDA3B2C102221D32863580404F59D8791E5CDC19E79">>},
{<<"riak_pb">>, <<"48FFBF66DBB3F136AB9A7134BAC4E496754BAA5EF58C4F50A61326736D996390">>}]}
{<<"riak_pb">>, <<"48FFBF66DBB3F136AB9A7134BAC4E496754BAA5EF58C4F50A61326736D996390">>}]},
{pkg_hash_ext,[
{<<"antidote_pb_codec">>, <<"F5FE77DBBDFDAD0B01613C72EF1AE96B49BE8AA15F0A4F3B5B6B01727FFD677C">>},
{<<"antidotec_pb">>, <<"1EE55D1187EC37A7840845F11C2AA349AA82C998E301A9EC8744774D0D57909B">>},
{<<"aqlc">>, <<"8FBF65EB08A6A584D547437723F61D8A3BB62E00DC70681828680467EB95A929">>},
{<<"cowboy">>, <<"E5580029080F3F1AD17436FB97B0D5ED2ED4E4815A96BAC36B5A992E20F58DB6">>},
{<<"cowlib">>, <<"1E1A3D176D52DAEBBECBBCDFD27C27726076567905C2A9D7398C54DA9D225761">>},
{<<"eredis">>, <<"D9B5ABEF2C2C8ABA8F32AA018203E0B3DC8B1157773B254AB1D4C2002317F1E1">>},
{<<"erlcass">>, <<"E9F16196872FB6E46AD829FFB365E0EADE67B3D4E6D05B78D9A002BFC53654D9">>},
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
{<<"hamcrest">>, <<"26974025BC61BC09EF5B13BE5DCE5035CA11BF37BF4A865E9D86C455C942298F">>},
{<<"jsx">>, <<"9A83E3704807298016968DB506F9FAD0F027DE37546EB838B3AE1064C3A0AD62">>},
{<<"lager">>, <<"97DC7E1C9E7289C3167F417E71FFE1DF28218537967E076800ECEDB1C28C9E48">>},
{<<"paillier">>, <<"C4C91422E4EE60152717D0EC0D30E77EE3502F4ED73CDB01A24ACE6650F2333D">>},
{<<"poolboy">>, <<"DAD79704CE5440F3D5A3681C8590B9DC25D1A561E8F5A9C995281012860901E3">>},
{<<"ranch">>, <<"451D8527787DF716D99DC36162FCA05934915DB0B6141BBDAC2EA8D3C7AFC7D7">>},
{<<"riak_client">>, <<"B792DB3CF207BE19778EE1E3F1DC37EA14A55DF8F9B148D19E9A095661A5DACC">>},
{<<"riak_pb">>, <<"7C0644BCBA8A423DD9C1AB85B6E7FF4DF0712D8A350F9698647CFF1996F0348C">>}]}
].
1 change: 1 addition & 0 deletions src/fmke.app.src
Expand Up @@ -14,6 +14,7 @@
jsx
]},
{included_applications, [
aqlc,
antidotec_pb,
riak_client,
eredis_cluster,
Expand Down
4 changes: 4 additions & 0 deletions src/fmke_driver_config.erl
Expand Up @@ -23,6 +23,7 @@
%% Stores the default drivers for each database.
%% These typically only get updated once a new database is supported.
-define(DEFAULT_DRIVER, #{
aql => fmke_driver_opt_aql,
antidote => fmke_driver_opt_antidote,
cassandra => fmke_driver_opt_cassandra,
ets => fmke_driver_ets,
Expand All @@ -34,6 +35,7 @@

%% Add your driver to this list if you wish to use FMKe's connection manager
-define(REQUIRE_CONN_MANAGER, [
fmke_driver_opt_aql,
fmke_driver_opt_antidote,
fmke_driver_opt_redis_crdb,
fmke_driver_opt_riak_kv
Expand Down Expand Up @@ -81,6 +83,7 @@ requires_ets_table(Driver) ->
lists:member(Driver, ?REQUIRE_ETS).

-spec get_client_lib(Driver::module()) -> atom().
get_client_lib(fmke_driver_opt_aql) -> aqlc_tcp;
get_client_lib(fmke_driver_opt_antidote) -> antidotec_pb_socket;
get_client_lib(fmke_driver_opt_redis_crdb) -> eredis;
get_client_lib(fmke_driver_opt_riak_kv) -> riakc_pb_socket.
Expand All @@ -95,6 +98,7 @@ driver_adapter(Driver) ->
end.

db_from_driver(fmke_driver_ets) -> ets;
db_from_driver(fmke_driver_opt_aql) -> aql;
db_from_driver(fmke_driver_opt_antidote) -> antidote;
db_from_driver(fmke_driver_opt_riak_kv) -> riak;
db_from_driver(fmke_driver_opt_cassandra) -> cassandra;
Expand Down

0 comments on commit 654d321

Please sign in to comment.