130
Oracle's Take On NoSQL Alexander Shopov <[email protected]>

Oracle's Take On NoSQL

Embed Size (px)

DESCRIPTION

History of NoSQL, architecture of Oralce's NoSQL database, examples for using it in Java

Citation preview

Page 1: Oracle's Take On NoSQL

Oracle's Take On NoSQL

Alexander Shopov <[email protected]>

Page 2: Oracle's Take On NoSQL

By day: Software Engineer at CiscoBy night: OSS contributorCoordinator of Bulgarian Gnome TP Contacts:

E-mail: [email protected] Jabber: [email protected] LinkedIn: http://www.linkedin.com/in/alshopov SlideShare: http://www.slideshare.net/al_shopovWeb: Just search “al_shopov”

[ash@edge ~]$ whoami

Page 3: Oracle's Take On NoSQL

Please Learn And Share

License: CC-BY v4.0

Page 4: Oracle's Take On NoSQL

Contents

● What is NoSQL?● Has it beaten SQL?● What is Oracle's take on it?● Do these have any foothold with us?

Page 5: Oracle's Take On NoSQL

The NoSQL Story

Page 6: Oracle's Take On NoSQL

What is NoSQL

● Hardest question we will have to answer today● Simplest definition is that NoSQL databases are

a set (not even a family) of mechanisms for storage and retrieval of data that try to be: – highly available

– able to scale horizontally

Page 7: Oracle's Take On NoSQL

Simple, yet true?

● Simple answers may be simple, though they are not necessarily correct

● Especially with NoSQL because:

Page 8: Oracle's Take On NoSQL

● NoSQL isn't (something)

Page 9: Oracle's Take On NoSQL

● NoSQL isn't (something)

● NoSQL is (NOT something)

Page 10: Oracle's Take On NoSQL

In particular

● NoSQL are data stores that are NOT relational databases

● They are something else● Thus it follows that they are not relational● And some say they are not even true

databases

Page 11: Oracle's Take On NoSQL

NoSQL = Without SQL?

● Perhaps a datastore without a SQL dialect of its own?

● Well no – some NoSQL solutions do have SQL or SQL- ish dialects

● So NoSQL is not even NO to SQL

Page 12: Oracle's Take On NoSQL

Not Only SQL

● Which is fair enough, but a subtle point● Not in terms of black and white, cool – not cool,

works – sucks binary viewpoints● And then it should be NOSQL, but it is NoSQL● But this still does not explain things

Page 13: Oracle's Take On NoSQL

How did the term NoSQL caught on then?

● You should know the answer – many people hate SQL

● And SQL is easy to hate!● It is large, Large, LARGE, LARGE – Oracle

SQL Language reference for 12.1 is 1826 pages.

● Have you actually seen the whole rail-road diagram for Oracle's SELECT anywhere?

Page 14: Oracle's Take On NoSQL

SQL – Love or Hate?

● It is not a single language, rather it is a family of dialects by competing companies

● Have you seen the standard (9 parts, 10th under way, more than 4000 pages)?

● Do you even care about the standard?

Page 15: Oracle's Take On NoSQL

As Academic As You Can Get

● SQL is not even relational● It is a language of bags, rather than sets

Page 16: Oracle's Take On NoSQL

If you can make the last point – you do not hate SQL, you have

grown used to it

Page 17: Oracle's Take On NoSQL

What else NoSQL is not?

● Martin Folwer says NoSQL should be called NoDBA because developers use NoSQL to run around traditional databases with their DBAs and bureaucracies.

Page 18: Oracle's Take On NoSQL

Dear DBAs,Do your developers love you?

Do they hate you?

Page 19: Oracle's Take On NoSQL

The term NoSQL

● Was coined in 1998 by Carlo Strozzi

● Lightweight relational database that lacks SQL dialect – NoSQL

● NoSQL should be NoREL

Page 20: Oracle's Take On NoSQL

The current usage of the term is a #tag

● Started in 2009 when Eric Evans who worked at Rackspace

● He proposed NoSQL as a Twitter #tag for a conference for the existing distributed databases

● The term stayed and gained popularity

Page 21: Oracle's Take On NoSQL

NoSQL stems from needs that are

● Hard● Impossible● Or even worse – prohibitively expensive to fulfil

with a traditional relational databases

Page 22: Oracle's Take On NoSQL

Examples

● Not-structured data or hard to model in a relational way

● Big data - generated by interuser interaction (Facebook), imported from external sources (WWW)

● Bringing structure to otherwise unstructured data – what we usually model as LOBs or BLOBs in RDBMS

● Graphs – Hierarchies in RDBMS (even bi-directional). Storing

vertices and edges in a table and then modeling paths with joins – like the Entity Attribute Value anti-pattern

Page 23: Oracle's Take On NoSQL

NoSQL comes from the need to scale out cheaply

Page 24: Oracle's Take On NoSQL

NoSQL comes from the need to scale out cheaply

Page 25: Oracle's Take On NoSQL

NoSQL comes from the need to scale out cheaply

Page 26: Oracle's Take On NoSQL

Origins of Scale

● Towards Robust Distributed Systems – Symposium on Principles of Distributed Computing - 2000

● Eric Brewer then at Inktomi

● Called his conjecture – the CAP theorem

Page 27: Oracle's Take On NoSQL

Proven as theorem in 2002 by Nancy Lynch and Seth Gilbert

Page 28: Oracle's Take On NoSQL

The Fall Of the Triad2 Out of 3

`

Consistency Availability

Tolerance to network partitions

Page 29: Oracle's Take On NoSQL

The Fall Of the Triad2 Out of 3

`

Consistency Availability

Tolerance to network partitions

You cannot have full availability – all operations can proceed,even writes

Page 30: Oracle's Take On NoSQL

The Fall Of the Triad2 Out of 3

`

Consistency Availability

Tolerance to network partitions

You cannot have full availability – all operations can proceed,even writes

While keeping consistency - all nodes have the same data(not the same as C in ACID)

Page 31: Oracle's Take On NoSQL

The Fall Of the Triad2 Out of 3

`

Consistency Availability

Tolerance to network partitions

You cannot have full availability – all operations can proceed,even writes

When you havepartitions –machines that cannotcommunicate

While keeping consistency - all nodes have the same data(not the same as C in ACID)

Page 32: Oracle's Take On NoSQL

A Somewhat Better Representation100% consistency

100% availability

100% partition tolerance

Impossible to achieve

Page 33: Oracle's Take On NoSQL

A Somewhat Better Representation100% consistency

100% availability

100% partition tolerance

Impossible to achieve

The Whole Volume Is Interesting

Page 34: Oracle's Take On NoSQL

Do Not Forget100% consistency

100% availability

100% partition tolerance

Impossible to achieve

These are actuallymultidimensional

Page 35: Oracle's Take On NoSQL

A Single System Can Wander In The Space

100% consistency

100% availability

100% partition tolerance

Impossible to achieve

Page 36: Oracle's Take On NoSQL

Or Have Data Operations In Different Points At The Same Time

100% consistency

100% availability

100% partition tolerance

Impossible to achieve

Page 37: Oracle's Take On NoSQL

CAP is easy to prove

● Think of two nodes on opposite sides of a partition● Allowing at least one node to update state will cause

the nodes to become inconsistent, thus forfeiting C.● If we preserve consistency, one side of the partition

must act as if it is unavailable, thus forfeiting A.● Only when nodes communicate is it possible to

preserve both consistency and availability, thereby forfeiting P.

Page 38: Oracle's Take On NoSQL

ACID vs. BASE

● Brewer called these BASE: Basically Available, Soft state, Eventually consistent to pun the pun of Jim Gray

● But NoSQL caught on

Page 39: Oracle's Take On NoSQL

A Typical NoSQL Taxonomy

● Key-value stores

Page 40: Oracle's Take On NoSQL

A Typical NoSQL Taxonomy

● Key-value stores

● Document databases

Page 41: Oracle's Take On NoSQL

A Typical NoSQL Taxonomy

● Key-value stores ● Column family stores

● Document databases

Page 42: Oracle's Take On NoSQL

A Typical NoSQL Taxonomy

● Key-value stores ● Column family stores

● Graph databases● Document databases

Page 43: Oracle's Take On NoSQL

A Typical NoSQL Taxonomy

● Key-value stores ● Column family stores

● Graph databases● Document databases

Page 44: Oracle's Take On NoSQL

Not True Taxonomy

● These are folk taxonomies● What happens to exist currently● No family relations – no speciation● Even putting them in four corners is visually

lying – some key-value stores are very close to some document databases, while graph databases look like the odd man out and stand on their own

Page 45: Oracle's Take On NoSQL

How do you use these NoSQLs?

● Get one or few values out of the store● Either modify and store● Or go on looking for other values● It is like pointer chasing● p->p1->p2->p3...

Page 46: Oracle's Take On NoSQL

The Other Way to Use Is Map-Reduce

● Similar to the way we process garbage for recycling

● Make heaps of garbage, make many teams sort each out (map)

● Aggregate iron, plastics, paper, glass from each team (reduce)

● Very efficient batch processing● But it is batch processing

Page 47: Oracle's Take On NoSQL

NoSQL are Less Capable than RDBMS

● Do not expect similar behavior or even capabilities – even when you have seen so on first glance in the documentation

● The maturity of RDBMS ecosystem and your expectations may be a bad service for the wild west of NoSQL

● Do not assume – double check

Page 48: Oracle's Take On NoSQL

Less Sophisticated Than RDBMS

● Less to learn● Less to administer● Easy to start using● Similar to pointer and reference programming

models● Programmers like them

Page 49: Oracle's Take On NoSQL

Loved By Developers? What About Admins And Operations?

● Ad Hoc Data Fixing – how?● Ad Hoc Data Querying – how?● Data Export – how?

Page 50: Oracle's Take On NoSQL

So will NoSQL beat SQL?

● First – why do we ask this? Hype and fanboyism, tradition and rut all have their answer

● For some NoSQL has already beaten SQL (no matter what NoSQL and SQL mean)

● For others NoSQL is way too young and not providing even a part of what SQL does (similarly - no matter what NoSQL and SQL mean)

Page 51: Oracle's Take On NoSQL

NoSQL is changing, so does SQL

● Champions of NoSQL like Google are moving closer to SQL and RDBMS– Declarativeness of SQL is fine and actually

developers like it

– Transactions help developers reason about what is happening, developers also like it

– No ACID in DB means it is maddengly hard to ACID on application level

– Speed is not everythg – it is just part of the equasion

● Move from batch to online processing

Page 52: Oracle's Take On NoSQL

O, champion of NoSQL – Where Art Thou Now?

● Google– Spanner – ACID, SQL, schematized tables,

PAXOS, descendant of Megastore rather than BigTable

– F1 – General transactions, Paxos, relational schema + extensions hierarchy, rich data types,

● Facebook– Presto – standard SQL, window functions, ad hoc

queries

Page 53: Oracle's Take On NoSQL

Michael Stonebraker

● Ingres● Postgres● Informix● Vertica● VoltDB● Next 5 slides –

quoting him

Page 54: Oracle's Take On NoSQL

SQL is so last millenium, there is NewSQL

● The variety in NoSQL and competition among RDBMS are pushing traditional SQL engnes to differentiate more strongly

● No more – One size fits all

Page 55: Oracle's Take On NoSQL

OLAP/DW

● Moving to column stores rather than traditional row oriented stores – 50-100 faster– No row per header

– Better compression

– IO much better for sparsely filled wide tables when running aggregates on several columns

● IBM DB2 (10.5, June 2013), Oracle (some in 11g2 2009 Exadata, more in 12c), MS SQL Server (some in 2012/2014 CTP1, June 2013), SAP HANA, MySQL

Page 56: Oracle's Take On NoSQL

Current OLTP

2424

24 24

4

Buffer pool ≈ 24%

Locking ≈ 24%

Latching ≈ 24%

Recovery ≈ 24%

Useful work ≈ 4%

Page 57: Oracle's Take On NoSQL

Ideal OLTP

100

Buffer pool ≈ 0%

Locking ≈ 0%

Latching ≈ 0%

Recovery ≈ 0%

Useful work ≈ 100%

Page 58: Oracle's Take On NoSQL

How to get this ideal OLTP?

● Latching – due to multithreadness. Go single threaded, each core – like a single thread, divide memory or remove all shared data

● Buffer pool – go into main memory, use anticaching● Row level locking – MVCC, timestamp ordering,

lightweight locking● Recovery – replication rather than rely on Aries,

replicate via command logging– Algorithms for Recovery and Isolation Exploiting Semantics

Page 59: Oracle's Take On NoSQL

The Oracle Story

Page 60: Oracle's Take On NoSQL

Who Is This Guy?

Page 61: Oracle's Take On NoSQL

Who Is This Guy?

● Designed and implemented Unix

Page 62: Oracle's Take On NoSQL

Who Is This Guy?

● Designed and implemented Unix

● UTF-8

Page 63: Oracle's Take On NoSQL

Who Is This Guy?

● Designed and implemented Unix

● UTF-8● B – the direct

predecessor of C● Go, Plan 9● Early Regex● Turing Award

Page 65: Oracle's Take On NoSQL

Back in 1979

● As part of Unix he also wrote DBM (database manager)

● Basically a hashtable backed by disk storage

Page 66: Oracle's Take On NoSQL

1971 197319701972 19701974 1975 19701976 1977 19701978 1979 19701980 19811970

To Put Tings Into Perspective

Page 71: Oracle's Take On NoSQL
Page 72: Oracle's Take On NoSQL

EdwardOates

Page 73: Oracle's Take On NoSQL

Bruce Scott, 1st employee

EdwardOates

Page 74: Oracle's Take On NoSQL

Bruce Scott, 1st employee

EdwardOates

RobertMiner

Page 75: Oracle's Take On NoSQL

Bruce Scott, 1st employee

EdwardOates

RobertMiner

LawrenceJoseph

Page 77: Oracle's Take On NoSQL

But this was yet to comeBack to the past

Page 78: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

Page 79: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Page 80: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Lawsuit – in 1992, ended

in 1994. Effort to rewrite AT&T copyrighted

utilities.

Page 81: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Lawsuit – in 1992, ended

in 1994. Effort to rewrite AT&T copyrighted

utilities.

LinusTorvaldsStartedLinux

Page 82: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Lawsuit – in 1992, ended

in 1994. Effort to rewrite AT&T copyrighted

utilities.

LinusTorvaldsStartedLinux

KeithBostic

Designedthe API

Page 83: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Lawsuit – in 1992, ended

in 1994. Effort to rewrite AT&T copyrighted

utilities.

LinusTorvaldsStartedLinux

KeithBostic

Designedthe API

MichaelOlson

Btreeimpl.

Page 84: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Lawsuit – in 1992, ended

in 1994. Effort to rewrite AT&T copyrighted

utilities.

LinusTorvaldsStartedLinux

KeithBostic

Designedthe API

MichaelOlson

Btreeimpl.

Db 1.85 -part of 4.4 BSD

Page 85: Oracle's Take On NoSQL

Unix Went To College – Berkeley

19701986 1987 19701988 1989 19701990 1991 19701992 1993 19701994 1995 19701996 1997

DBM becamendbm –

new databasemanager

Lawsuit – in 1992, ended

in 1994. Effort to rewrite AT&T copyrighted

utilities.

LinusTorvaldsStartedLinux

KeithBostic

Designedthe API

MichaelOlson

Btreeimpl.

Db 1.85 -part of 4.4 BSD

MargoSeltzer

Paperon TXvariant

Page 86: Oracle's Take On NoSQL

Berkeley DB by Sleepycat Software

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

Page 87: Oracle's Take On NoSQL

Berkeley DB by Sleepycat Software

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

SleepycatSoftware

Page 88: Oracle's Take On NoSQL

Berkeley DB by Sleepycat Software

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

SleepycatSoftware

BerkleyDB 2.0 –

transactions

Page 89: Oracle's Take On NoSQL

Berkeley DB by Sleepycat Software

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

SleepycatSoftware

BerkleyDB 2.0 –

transactions

BerkleyDB3.0 – API

Page 90: Oracle's Take On NoSQL

Berkeley DB by Sleepycat Software

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

SleepycatSoftware

BerkleyDB 2.0 –

transactions

BerkleyDB3.0 – API

BerkleyDB 4.0 –

HA single master, multiple reader

Page 91: Oracle's Take On NoSQL

Berkeley DB by Sleepycat Software

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

SleepycatSoftware

BerkleyDB 2.0 –

transactions

BerkleyDB3.0 – API

BerkleyDB 4.0 –

HA single master, multiple reader

BerkleyDB Java Edition

pure Javaimpl.

Page 92: Oracle's Take On NoSQL

Berkeley DB by Oracle

19701996 1997 19701998 1999 19702000 2001 19702002 2003 19702004 2005 19702006 2007

SleepycatSoftware

BerkleyDB 2.0–

transactions

BerkleyDB3.0 – API

BerkleyDB 4.0 –

HA single master, multiple reader

BerkleyDB Java Edition

pure Javaimpl.

Oraclebought

Sleepycat – embedded DB

Page 94: Oracle's Take On NoSQL

VMWareRedis2009

LinkedInVoldemort2009

TwitterFlockDB2010

AmazonDynamo2007

FacebookCassandra2008

Yahoo!PNUTS2008

BashoRiak2009

10genMongoDB2009

GoogleFileSystem2003

GoogleMapReduce2004

GoogleBigTable2006

ApacheCouchDB2005

ApacheHadoop2007

And Then Everybody And Their Dog Were Creating Databases

May 2011

Oracle Whitepaper

Debunking the NoSQL hype

Now available only in Internet

caches and torrent sites

Page 95: Oracle's Take On NoSQL

Vive La Révolution!

● Just 4 months later on Oracle OpenWorld in start of October 2011 Oracle announced they were working on a NoSQL solution, availability – end of October 2011

● December 2011 – version 1.2.x● December 2012 – Oracle NoSQL Database 2.0,

11gR2 (11.2.x)● The Old Dog Learns The New Tricks – VERY,

VERY FAST

Page 96: Oracle's Take On NoSQL

General ArchitectureStorage Nodes

Page 97: Oracle's Take On NoSQL

Replication Node – DB of key value pairs

Page 98: Oracle's Take On NoSQL

Divide keyspace into shards

Page 99: Oracle's Take On NoSQL

PopulateStorage Nodes

Page 100: Oracle's Take On NoSQL

Shard 1, Replication node 1, master

Page 101: Oracle's Take On NoSQL

Shard 1, Replication node 1, master + replicas

Page 102: Oracle's Take On NoSQL

Shard 1, 2, 3, Replication node 1, master

Page 103: Oracle's Take On NoSQL

Shard 1, 2, 3, Replication node 1, master + replicas

Page 104: Oracle's Take On NoSQL

Shard 1, 2, 3, RN 1, MR + REPShard 1, 2, 3, RN 2, MR

Page 105: Oracle's Take On NoSQL

Shard 1, 2, 3, RN 1, MR + REPShard 1, 2, 3, RN 2, MR + REP

Page 106: Oracle's Take On NoSQL

Add last masters

Page 107: Oracle's Take On NoSQL

Add All Data

Page 108: Oracle's Take On NoSQL

Clients With Clever Drivers – Less Roundtrips

Page 109: Oracle's Take On NoSQL

Initialize Handle

private KVStore store;private KVStoreConfig config;

public void getHandle() { String[] hosts = {"localhost:5000", "127.0.0.1:5000"}; config = new KVStoreConfig("example", hosts); // set default time out config.setRequestTimeout(50, TimeUnit.MILLISECONDS); // can set consistency, durability // config.setConsistency(Consistency.ABSOLUTE) // .setDurability(Durability.COMMIT_SYNC); // set*Void() store = KVStoreFactory.getStore(config); }

Page 110: Oracle's Take On NoSQL

Release Resources

public void release() { store.close();}

Page 111: Oracle's Take On NoSQL

But Let's Do It the Java 7 Way

public void getHandleJava7() { try (KVStore store1 = KVStoreFactory.getStore(config)) { // MEAT GOES HERE } catch (Exception e) { } finally { }}

Page 112: Oracle's Take On NoSQL

How to Write

public void writeKeyValue() throws UnsupportedEncodingException { List<String> major = new ArrayList<>(); major.add("Muffin"); major.add("Man"); List<String> minor = new ArrayList<>(); minor.add("address"); Key k = Key.createKey(major, minor); String address = "Drury Lane"; Value v = Value.createValue(address.getBytes("UTF-8")); store.put(k, v); store.putIfAbsent(k, v); store.putIfPresent(k, v); store.putIfVersion(k, v, null);}

Page 113: Oracle's Take On NoSQL

How to Delete

public void deleteKeyValue(){ List<String> major = Arrays.asList("Muffin", "Man"); List<String> minor = Arrays.asList("address"); Key k = Key.createKey(major, minor); store.delete(k); store.multiDelete(Key.createKey(major), null, null);}

Page 114: Oracle's Take On NoSQL

How to Read – 1

public void readARecord() throws UnsupportedEncodingException{ List<String> major = Arrays.asList("Muffin", "Man"); List<String> minor = Arrays.asList("address"); Key k = Key.createKey(major, minor); ValueVersion vv = store.get(k); Value v = vv.getValue(); String result = new String(v.getValue(), "UTF-8"); result.equals("Drury Lane");}

Page 115: Oracle's Take On NoSQL

How to Read – 2

public void readFullMajor1Go(){ List<String> major = Arrays.asList("Muffin", "Man"); Key k = Key.createKey(major); // Single operation SortedMap<Key,ValueVersion> records = store.multiGet(k, null, null); for (Map.Entry<Key, ValueVersion> entry : records.entrySet()) { Key key = entry.getKey(); List<String> minor = key.getMinorPath(); ValueVersion vv = entry.getValue(); Value v = vv.getValue(); // Do some work with the Value here }}

Page 116: Oracle's Take On NoSQL

How to Read – 3

public void readFullMajorManyGoes(){ List<String> major = Arrays.asList("Muffin", "Man"); Key k = Key.createKey(major); // Non atomic Iterator<KeyValueVersion> it = store.multiGetIterator( Direction.FORWARD, // BACKWARD, UNORDEREDED 0, // Batch size, 0 - use default k, // the key null, // KeyRange null); // Depth - CHILDREN_ONLY, PARENT_AND_CHILDREN, // DESCENDANTS_ONLY, PARENT_AND_DESCENDANTS while (it.hasNext()){ Value v = it.next().getValue(); // Do some work with the Value here }}

Page 117: Oracle's Take On NoSQL

How to Read – 4

public void readPartialMatch() { List<String> major = Arrays.asList("Muffin"); Key k = Key.createKey(major); // Non atomic, read large part of DB Iterator<KeyValueVersion> it = store.storeIterator( Direction.UNORDERED, // BACKWARD, FORWARD 0, // Batch size, 0 - use default k, // the key null, // KeyRange null); // Depth - CHILDREN_ONLY, PARENT_AND_CHILDREN, // DESCENDANTS_ONLY, PARENT_AND_DESCENDANTS while (it.hasNext()){ Value v = it.next().getValue(); // Do some work with the Value here }}

Page 118: Oracle's Take On NoSQL

Key ranges

public void prepareKeyRange() { // Bowerick Wowbagger the Infinitely Prolonged // Hitchhikers Guide To the Galaxy // Arthur Philip Dent - You are a jerk KeyRange kr = new KeyRange( "Arthur Philip Dent", // start true, // inclusive? [( "A-Rth-Urp-Hil-Ipdenu", // slug true); // inclusive? )]}

Page 119: Oracle's Take On NoSQL

Sequence of Operations - TX

public void sequence(){ OperationFactory of = store.getOperationFactory(); List<Operation> ops = new ArrayList<>(); Key k = null; Value v = null; ops.add(of.createDelete(k)); ops.add(of.createPut(k, v)); // of.createDeleteIfVersion(); of.createPutIfAbsent(); // of.createPutIfPresent(); of.createPutIfVersion() try { store.execute(ops); } catch (OperationExecutionException | // cannot exec DurabilityException | // durability not met IllegalArgumentException | // list is , null∅ RequestTimeoutException e) { // timeout } catch (FaultException e) { // sth else }}

Page 120: Oracle's Take On NoSQL

Apache Avro

Page 121: Oracle's Take On NoSQL

Avro JSON Schemas

{ "type": "record", "namespace": "bgoug", "name": "Developer", "fields": [ { "name": "name", "type": "string", "default" : "NONE"}, { "name": "age", "type": "int", "default" : "NONE"}, { "name": "language", "type": "string", "default" : "Java"} ]}

Page 122: Oracle's Take On NoSQL

Prepare Avro

public void prepareSchemas() throws IOException{ Map<String, Schema> schemas = new HashMap<>(); Schema.Parser parser = new Schema.Parser(); Schema developerSchema = parser.parse(new File("DeveloperSchema.avsc")); schemas.put(developerSchema.getFullName(), developerSchema); Schema dbAdminSchema = parser.parse(new File("DbAdminSchema.avsc")); schemas.put(dbAdminSchema.getFullName(), dbAdminSchema);}

Page 123: Oracle's Take On NoSQL

Generic Avro

public void genericAvro(){ AvroCatalog catalog = store.getAvroCatalog(); GenericAvroBinding binding = catalog.getGenericMultiBinding(schemas); GenericRecord dev = new GenericData.Record(developerSchema); dev.put("name", "Sam A. Hacker"); dev.put("age", 37); dev.put("language", "Java"); Key k = null; //Key.createKey store.put(k, binding.toValue(dev)); Value v = store.get(k).getValue(); GenericRecord dbAdmin = binding.toObject(v); dbAdmin.get("name");}

Page 124: Oracle's Take On NoSQL

Specific Avro

public void specificAvro(){ AvroCatalog catalog = store.getAvroCatalog(); SpecificAvroBinding binding = catalog.getSpecificMultiBinding(); // generate via provided ant task // org.apache.avro.compiler.specific.SchemaTask Developer dev = new Developer(); dev.setName("Sam. A. Hacker"); dev.setAge(37); dev.setLanguage("Java"); Key k = null; //Key.createKey store.put(k, binding.toValue(dev)); Value v = store.get(k).getValue(); SpecificRecord sr = binding.toObject(v); if (sr.getSchema().getFullName().equals("dba")){ DbAdmin dbAdmin = (DbAdmin) sr; }}

Page 125: Oracle's Take On NoSQL

JSON Avro

public void jsonAvro(){ AvroCatalog catalog = store.getAvroCatalog(); JsonAvroBinding binding = catalog.getJsonMultiBinding(schemas); String jsonText = "{\"name\": \"Sam. A. Hacker\"," + " \"age\": 34, \"language\": \"Java\"}"; ObjectMapper jsonMapper = new ObjectMapper(); JsonNode json = jsonMapper.readTree(jsonText); JsonRecord dev = new JsonRecord(json, developerSchema); Key k = null; //Key.createKey store.put(k, binding.toValue(dev)); Value v = store.get(k).getValue(); JsonRecord jr = binding.toObject(v); if (jr.getSchema().getFullName().equals("dba")){ JsonNode dbAdmin = jr.getJsonNode(); dbAdmin.get("db"); }}

Page 126: Oracle's Take On NoSQL

Licensing

● Community Edition – FLOSS, AGPLv3

● Enterprise edition:– SNMP, Oracle RDBMS compatibility, JMX

– $40/user/year (min. 25), $2000/processor/year

– RDBMS Standard Edition One ≤ NoSQL ≤ RDBMS Standard Edition

Page 127: Oracle's Take On NoSQL

Further General Resources

● Martin Fowler: NoSQL Distilled to an hour http://vimeo.com/66052102

● Martin Fowler: NoSQL Distilled http://martinfowler.com/nosql.html

● Ilya Katsov: NoSQL Data Modelling Techniques http://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/

● Christof Strauch: NoSQL Databases http://www.christof-strauch.de/nosqldbs.pdf

● Michael Stonebreaker http://slideshot.epfl.ch/play/suri_stonebraker

Page 128: Oracle's Take On NoSQL

Further Resources on CAP

● Eric Brewer: Towards Robust Distributed Systems http://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf

● Eric Brewer: NoSQL: Past, Present, Future http://www.infoq.com/presentations/NoSQL-History

● Eric Brewer: CAP Twelve Years Later: How the "Rules" Have Changed http://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed

● Nancy Lynch, Seth Gilbert: Brewer’s Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services http://lpd.epfl.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf

Page 129: Oracle's Take On NoSQL

Further Oracle NoSQL Resources

● Oracle's Product Page: http://www.oracle.com/technetwork/products/nosqldb/overview/index.html

● Good Documentation: http://docs.oracle.com/cd/NOSQL/html/index.html

Page 130: Oracle's Take On NoSQL

Code examples

● https://github.com/alshopov/OracleNoSQLExamples