Slide 1

Slide 1 text

Native APIs for Querying Couchbase Server with N1QL Jeff Morris | Software Engineer, Couchbase Michael Nitschinger | Software Engineer, Couchbase

Slide 2

Slide 2 text

Everything shown in this talk is a preview and subject to change before we ship official N1QL integration. Take everything with a grain of salt and give us feedback to make it even better. Disclaimer ©2014 Couchbase, Inc. 2

Slide 3

Slide 3 text

Introduction

Slide 4

Slide 4 text

Motivation ©2014 Couchbase, Inc. 4 Querying is integral to Couchbase Server SDKs need to provide first-class querying for §  Views §  N1QL The 2.0 SDKs provide document oriented APIs and querying needs to blend together

Slide 5

Slide 5 text

N1QL Overview ©2014 Couchbase, Inc. 5 N1QL (“Nickel”) is the next generation query language for Couchbase Server §  Designed to be similar to SQL §  First-Class JSON support §  Currently in Developer Preview §  See http://query.couchbase.com §  Supports SELECT, DML, DDL § SDKs focus is on SELECT for now

Slide 6

Slide 6 text

N1QL Primer: Select ©2014 Couchbase, Inc. 6

Slide 7

Slide 7 text

N1QL Primer: Joins ©2014 Couchbase, Inc. 7

Slide 8

Slide 8 text

N1QL Primer: Popular Products in Category ©2014 Couchbase, Inc. 8

Slide 9

Slide 9 text

2.0 Querying API ©2014 Couchbase, Inc. 9 Provides consistent experience across §  Views §  N1QL Blends into Document API Sweet spot between §  Consistency across SDKs §  Language features

Slide 10

Slide 10 text

N1QL Querying in .NET

Slide 11

Slide 11 text

Query Generators and Executers •  Ad-hoc queries •  New LINQ Provider Mapping results and Handling Errors •  Query Mapping •  Query Results N1QL Query Support in .NET SDK 2.0 ©2014 Couchbase, Inc. 11

Slide 12

Slide 12 text

§  Part of the SDK 2.0 IBucket interface §  Standard un-typed, string based queries §  No syntactical help §  Results can be mapped to POCOs or to a dynamic type §  Supports all N1QL commands, keywords, etc §  Errors are handled and propagated up to the caller §  The current query interface for N1QL queries in Couchbase Server §  Github Url: https://github.com/couchbase/couchbase-net-client Ad-Hoc Queries ©2014 Couchbase, Inc. 12

Slide 13

Slide 13 text

Ad-hoc Query Example ©2014 Couchbase, Inc. 13

Slide 14

Slide 14 text

The QueryResult object ©2014 Couchbase, Inc. 14

Slide 15

Slide 15 text

Handling Errors ©2014 Couchbase, Inc. 15

Slide 16

Slide 16 text

Mapping to Types ©2014 Couchbase, Inc. 16

Slide 17

Slide 17 text

§  An extension of the Couchbase .NET SDK 2.0 §  Open Source Apache 2.0 License § Pull requests kindly accepted! §  Github url: https://github.com/couchbaselabs/Linq2Couchbase §  Brings familiar LINQ syntax to N1QL and Couchbase Server §  Currently supports a minimal subset of the N1QL language (this will soon change) §  Errors are un-handled §  Results are mapped to POCOs §  The “future” query interface for N1QL and Couchbase Server in .NET Linq2Couchbase ©2014 Couchbase, Inc. 17

Slide 18

Slide 18 text

Basic Queries ©2014 Couchbase, Inc. 18

Slide 19

Slide 19 text

Basic Queries: Projections to Anonymous Types ©2014 Couchbase, Inc. 19

Slide 20

Slide 20 text

Basic Queries: “where” clause ©2014 Couchbase, Inc. 20

Slide 21

Slide 21 text

Basic Queries: limit and range queries ©2014 Couchbase, Inc. 21

Slide 22

Slide 22 text

Expect a GA released with N1QL GA Eventually a “full-featured” LINQ provider Anything that is not supported by the LINQ provider can be done via IBucket.Query(string query) Linq2Couchbase: Future Support ©2014 Couchbase, Inc. 22

Slide 23

Slide 23 text

.NET Demo

Slide 24

Slide 24 text

N1QL Querying in Java

Slide 25

Slide 25 text

Java SDK API ©2014 Couchbase, Inc. 25 Access types §  Asynchronous (Reactive) using Rx Observables §  Synchronous Utilizes a JSON streaming parser and pushes chunks as they arrive Works on a per-bucket basis

Slide 26

Slide 26 text

The Result of a Query ©2014 Couchbase, Inc. 26

Slide 27

Slide 27 text

The Row ©2014 Couchbase, Inc. 27

Slide 28

Slide 28 text

Synchronous Querying ©2014 Couchbase, Inc. 28

Slide 29

Slide 29 text

Synchronous Querying ©2014 Couchbase, Inc. 29

Slide 30

Slide 30 text

Asynchronous Querying ©2014 Couchbase, Inc. 30

Slide 31

Slide 31 text

N1QL DSL ©2014 Couchbase, Inc. 31 §  The SDK ships with a N1QL DSL §  syntax aware (based on the EBNF) §  strongly typed §  Should be used in favor of the raw string §  Makes developing N1QL queries a breeze §  Built-in IDE autocomplete awareness §  Heavily inspired by jOOQ (http://www.jooq.org/)

Slide 32

Slide 32 text

IDE Support ©2014 Couchbase, Inc. 32

Slide 33

Slide 33 text

IDE Support ©2014 Couchbase, Inc. 33

Slide 34

Slide 34 text

IDE Support ©2014 Couchbase, Inc. 34

Slide 35

Slide 35 text

Examples ©2014 Couchbase, Inc. 35

Slide 36

Slide 36 text

Examples ©2014 Couchbase, Inc. 36

Slide 37

Slide 37 text

Java Demo

Slide 38

Slide 38 text

QA