http://disa.fi.muni.cz/vlastislav-dohnal/teaching/nosql-databases-fall-2019/ ● ○ ● ○ ID primary key ○ DATA BLOB ● ○ value:= get(key) ○ put(key, value) ○ delete(key) ● ● ○ ● ○ ■ ■ ■ ● ○ ■ ● ○ ■ ○ ■ ● ○ ● ● ○ ■ ● ○ ■ ○ ■ ● ○ ● ● ○ ● ○ ● ○ ● ○ ■ ○ ● ○ ■ ■ ○ ■ ■ ○ ■ ■ ■ ● ○ ○ ● ● ● ● ● ● ● ● ● Log-structured Merge Tree (LSM Tree) ● data structure for indexed access to data files ○ can handle high write frequency ● writes applied to a sorted structure in memory ○ regularly synchronized to a sorted disk storage ● read ops merge data from memory & disk ● ● ● ● source: https://r.va.gg/presentations/nodejsdub/ ● ● ● ● source: https://r.va.gg/presentations/nodejsdub/ ↠ ↠ ↠ ↠ ↠ ↠ ↠ ↠ source: https://r.va.gg/presentations/nodejsdub/ ● ○ ○ ○ ○ ● ○ ■ ● ○ ■ ○ ■ ● ○ ● ● ○ ○ ● ● ● ○ basic info: http://db-engines.com/en/system/Riak website: http://basho.com/products/riak-overview ● ○ ● ○ ● ○ ● ○ source: http://basho.com/riak/ namespace of keys ● ○ … ○ ■ n_val ■ allow_mult ■ ● ○ … ○ http://localhost:8098/buckets/test/keys/mykey ● ● ○ ● curl -X method URL -d data ○ curl -X PUT http://localhost:8098/buckets/authors/keys/David -d '{"name": "David Novák", "affiliation": "MU"}' curl -X GET http://localhost:8098/buckets/authors/keys/David {"name": "David Novák", "affiliation": "MU"} curl -X DELETE http://localhost:8098/buckets/authors/keys/David ● ○ ○ ● ○ ○ ○ ● ○ ● ● curl -X PUT http://localhost:8098/buckets/books/keys/NoSQL -d '{"title": "Big Data a NoSQL databáze", "year": "2015"}' -H 'Link: ; riaktag="wrote"' ● ○ ● curl -i http://localhost:8098 /buckets/books/keys/NoSQL/authors,wrote,1 ○ ○ ○ ● ○ ● ● ● ○ ● ○ curl -X PUT http://localhost:8098/buckets/authors/keys/David -H 'x-riak-index-surname_bin: Novak' -H 'x-riak-index-phone_int: 5062' -d '{"name": "David", surname "Novák", "phone ext": 5062 }' ● ○ ○ ○ ● ○ ■ … ○ ○ ○ ● ○ ■ RiakClient client = RiakClient.newClient("168.0.0.1"); Namespace bucket = new Namespace("authors"); Location location = new Location(bucket, "David"); FetchValue fv = new FetchValue.Builder(location).build(); FetchValue.Response response = client.execute(fv); String obj = response.getValue(String.class); ● ○ ■ ○ ○ ○ ■ ○ ■ ○ ○ ○ ● ○ ○ vnode source: http://docs.basho.com/riak/latest/theory/concepts/ ● ○ ○ n_val ○ n_val ○ source: http://docs.basho.com/riak/latest/theory/concepts/ source: http://docs.basho.com/riak/latest/theory/concepts/ ● ● ● ○ ● curl http://localhost:8098/raw/plans/dinner -X PUT --data "Wednesday" curl -i http://localhost:8098/raw/plans/dinner HTTP/1.1 200 OK X-Riak-Vclock: a85hYGBgzGDKBVIsrLnh3BlMiYx5rAzLJpw7wpcFAA== Content-Type: text/plain Content-Length: 9 Wednesday source: http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/ ● ○ ○ ○ ● ○ ○ curl -X PUT -H "X-Riak-ClientId: Ben" -H "X-Riak-Vclock: a85hYGBgzGDKBVIsrLnh3BlMiYx5rAzLJpw7wpcFAA==" http://localhost:8098/raw/plans/dinner --data "Tuesday" ● ○ ○ ○ ● ○ ○ source: http://docs.basho.com/riak/latest/theory/concepts/Vector-Clocks/ ● ○ ● ○ ● vnode ○ vnode ○ vnodes ○ vnodes ○ ■ ○ ● ● ○ ■ ■ ■ ○ ■ ○ ■ ● ● ○ ● ○ ● ○ ● ● ● ○ ○ ○ public static void main(String args[]){ Cache store = new DefaultCacheManager().getCache(); store.put("key1", new MyClass("value1")); store.put("key2", "value2"); if (store.containsKey("key1")) { Object result = store.get("key2"); store.removeAsync("key2"); } store.replaceAsync("key2", "value3"); store.clear(); } ● ○ ■ ■ ○ ■ ● ○ ■ ○ ● ○ ■ ■ ○ ■ ■ ○ ■ ● ○ ■ ● ○ ○ ○ ○ ○ ● ○ ○ ● ○ ○ ○ ● ○ ■ ○ ■ ○ ■ ● ○ ○ ○ ● ○ source: http://infinispan.org/docs/7.0.x/user_guide/user_guide.html // A class to be indexed is annotated with @Indexed // then you pick which fields and how to index them @Indexed public class Book { @Field String title; @Field String description; @Field @DateBridge(resolution=YEAR) Date publicationYear; @IndexedEmbedded Set<> authors = new HashSet(); } public class Author { @Field String name; @Field String surname; } source: http://infinispan.org/docs/7.0.x/user_guide/user_guide.html#_simple_example SearchManager searchManager = Search.getSearchManager(store); // create a query via Lucene APIs or using builder QueryBuilder qBuilder = searchManager.buildQueryBuilderForClass(Book.class).get(); Query luceneQ = qBuilder.phrase() .onField("description").andField("title") .sentence("book on scalable query engines").createQuery(); CacheQuery res = searchManager.getQuery(luceneQ, Book.class); // and there are your results! List objectList = res.list(); source: http://infinispan.org/docs/7.0.x/user_guide/user_guide.html#_simple_example ● ○ ■ ● ○ ■ ○ ■ ● ○ ● ● ● ● ○ ○ ● ○ ○ ● ○ ○ ● ○ ○ ● ● ○ ● ● ● ○ ● ○ ○ ● ○ ● ● ○ ○ ○ ● ○ ○ ● ○ ■ ● ○ ■ ○ ■ ● ○ ● ● ○ ■ ○ ○ ● ● ○ ● ○ ○ ○ ● ● ○ ● ■ ■ … http://en.wikipedia.org/wiki/Protocol_Buffers // file: addressbook.proto message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; } repeated PhoneNumber phone = 4; } message AddressBook { repeated Person person = 1; } source: https://developers.google.com/protocol-buffers/ ● protoc --java_out=jdir addressbook.proto protoc --cpp_out=cppdir addressbook.proto protoc --python_out=pdir addressbook.proto ● ○ https://github.com/jgilfelt/android-protobuf-example/blob/master/src/com/exam ple/tutorial/AddressBookProtos.java source: https://developers.google.com/protocol-buffers/ ● ● ● ○ ○ ● https://thrift.apache.org/ http://en.wikipedia.org/wiki/Apache_Thrift enum PhoneType { HOME, WORK, MOBILE, OTHER } struct Phone { 1: i32 id, 2: string number, 3: PhoneType type } source: http://en.wikipedia.org/wiki/Apache_Thrift ● ● ● ● ● I. Holubová, J. Kosek, K. Minařík, D. Novák. Big Data a NoSQL databáze. Praha: Grada Publishing, 2015. 288 p. ● Sadalage, P. J., & Fowler, M. (2012). NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence. Addison-Wesley Professional, 192 p. ● RNDr. Irena Holubova, Ph.D. MMF UK course NDBI040: Big Data Management and NoSQL Databases ● http://www.slideshare.net/quipo/nosql-databases-why-wha t-and-when ● https://riak.com/products/riak-kv/ ● https://infinispan.org/docs/stable/index.html