Aerospike Nested CDTs - Meetup Dec 2019

Aerospike
AerospikeAerospike
Exploring Data Modeling
Modeling with Nested CDTs
Zohar Elkayam, Aerospike
2 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ A Quick Overview of Aerospike Data Types.
▪ Recap: CDTs: The List and Map APIs.
▪ Modeling with Nested CDTs.
▪ A real-life Example.
Agenda
3 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Aerospike is a Primary Key Database
Objects stored in Aerospike are called records.
A bin holds the value of a supported data type: integer, double, string, bytes, list, map,
geospatial.
Every record is uniquely identified by the 3-tuple (namespace, set, primary-key).
A record contains one or more bins.
(namespace, set, primary-key)
EXP – Expiration Timestamp
LUT – Last Update Time
GEN – Generation
RECORD
EXP LUT GEN BIN1 BIN2
4 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ Aerospike is a row-oriented distributed database.
▪ Rows (records) contain one or more columns (bins).
▪ Similar to an RDBMS with primary-key table lookups.
▪ Single record transactions.
Aerospike Concepts
Aerospike RDBMS
Namespace Tablespace or Database
Set Table
Record Row
Bin Column
Bin type
Integer
Double
String
Bytes
List (Unordered, Ordered)
Map (Unordered,
K-Ordered, KV-Ordered)
GeoJSON
5 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ Aerospike data types have powerful APIs.
▪ Atomic operations simplify application logic and reduce network load.
▪ Complex Data Types (CDT – such as List and Map) can be nested to many levels.
▪ Before 4.6: Atomic operations can execute only at the top level of a List or Map.
▪ After 4.6: Atomic operations can execute at all levels of a nested CDT.
▪ Native operations perform and scale better than UDFs.
Data Modeling in Aerospike
6 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Example of a Record
('test', 'users’, 37) ➔ {
'name': 'Apolonius Kensington',
'age': 31,
'logins_ts': [ 1576077683, 1576224612, 1576350640 ],
'cards': [
{ 'type': 'visa’,
'last4': 5996,
'expires': '2019-09',
'usage_cnt': 12},
{
'type': 'mastercard',
'last4': 4177,
'expires': '2018-11',
'usage_cnt': 1}
],
'pass': p??Ȇ??"R*?vw96Q
}
A simple list bin
A map
Nested CDT Bin: a
list of maps
7 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
List operations supported by the server. Method names in the clients might be different.
• set_type() (unordered, ordered)
• sort(), clear(), size()
• append(), append_items(), insert(), insert_items(), set(), increment()
• get_by_index(), get_by_index_range(), get_by_rank(), get_by_rank_range(),
get_by_value(), get_by_value_interval(), get_all_by_value(),
get_all_by_value_list(), get_by_value_rel_rank_range()
• remove_by_index(), remove_by_index_range(), remove_by_rank(),
remove_by_rank_range(), remove_by_value(), remove_by_value_interval(),
remove_all_by_value(), remove_all_by_value_list(),
remove_by_value_rel_rank_range()
List Operations
8 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Map operations supported by the server. Method names in the clients might be different.
• set_type() (unordered, k-ordered or kv-ordered)
• size(), clear()
• add(), add_items(), increment(), decrement()
• get_by_key(), get_by_index(), get_by_rank(), get_by_key_interval(),
get_by_index_range(), get_by_value_interval(), get_by_rank_range(),
get_all_by_value(), get_by_key_rel_index_range(), get_by_value_rel_rank_range(),
get_all_by_key_list(), get_all_by_value_list()
• remove_by_key(), remove_by_index(), remove_by_rank(), remove_by_key_interval(),
remove_by_index_range(), remove_by_value_interval(), remove_by_rank_range(),
remove_all_by_value(), remove_all_by_key_list(), remove_all_by_value_list(),
remove_by_key_rel_index_range(), remove_by_value_rel_rank_range()
Map Operations
9 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ Version 4.6 added the ability to perform list and map operations on nested
objects.
▪ For example, we will be able to manipulate lists that are the value of a map items
(2nd level) the same way we manipulate the map items themselves (1st level).
▪ The new CDT introduced some general performance improvements around
comparing lists and maps.
▪ This is currently supported on some of the clients: C, C#, Java, Node.js,
Python, Go.
New CDT (Map and List) Operations
10 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ Nested CDT operations are executed on the internal level.
Example:
▪ Adding to a list inside a map would use List Operations.
▪ Incrementing a value a value of a map inside a list would use Map Operations.
▪ But how do we specify the actual location? Use the CTX context object.
▪ The CTX object will indicate where to find the object/value to operate on.
▪ We can nest the CTX to get into a deeper level.
▪ https://www.aerospike.com/docs/guide/cdt-context.html
Getting into the Nested: CTX
BY_LIST_INDEX
BY_LIST_RANK
BY_LIST_VALUE
BY_MAP_INDEX
BY_MAP_RANK
BY_MAP_KEY
BY_MAP_VALUE
11 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
bin = [0, 1, [2, [3, 4], 5, 6], 7, [8, 9] ]
Sub level 2 (1 CTX object):
> subcontext_eval([BY_LIST_INDEX, -1], list.append(99) )
bin = [0, 1, [2, [3, 4], 5, 6], 7, [8, 9, 99] ]
Sub level 3 (2 CTX objects, read left to right):
> subcontext_eval([BY_LIST_INDEX, 2, BY_LIST_INDEX, 1], list.append(44))
bin = [0, 1, [2, [3, 4, 44], 5, 6], 7, [8, 9, 99] ]
Top Level (no CTX object):
> list.append(10)
bin = [0, 1, [2, [3, 4, 44], 5, 6], 7, [8, 9, 99], 10 ]
CTX Examples
12 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ The customer is getting tuples of game level and timestamp when they were
sampled for each player.
▪ Those levels and timestamps are not received in order.
▪ The customer would like to keep only the earliest timestamp observed for
each level.
▪ The customer also would like to keep only the last n levels and remove the
rest.
▪ The customer would also like to query the list by timestamp and get the
level the player was at that timestamp (equal or observed before that ts).
Nested CDT Example (a real-life example!)
13 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ A possible data model to solve the problem: keep a map where the level is
the key and the timestamp is the value:
{
7: 700,
8: 705,
9: 720,
10: 740
}
▪ But how do we handle the out of order records? How do we query?
▪ We will need to do that in the app – read the record, recreate the entire map and
rewrite the record (assuming no one tried to change the record while we were
modifying it in the app: use CAS to insure that!).
The Data Model: Original
14 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ The suggested data model: keep a map where the level is the key and a list
of timestamps is the value.
{
7: [700],
8: [705],
9: [720],
10: [740]
}
▪ We will append and new timestamp to the list and trim it to keep the oldest
one. We will also trim the entire map based on the keys – all of this will be
done incrementally and in a single operation.
The Data Model: Using Nested CDT and API
15 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
for (List p: data) {
console.info("Working on " + p.get(0) + " : " + p.get(1));
int myLevel = Integer.parseInt(p.get(0).toString());
List<Value> l1 = new ArrayList<Value>();
Map<Value,Value> m1 = new HashMap<Value,Value>();
m1.put(Value.get(myLevel), Value.get(l1));
// map policy to add a level only if it does not already exist, set the map to be sorted by the key
MapPolicy mapPolicy = new MapPolicy(MapOrder.KEY_ORDERED, (MapWriteFlags.CREATE_ONLY | MapWriteFlags.NO_FAIL));
// Operate to run multiple commands on the same key
Record record = client.operate(params.writePolicy, key,
// add the level with empty initial ts if it does not exist, skip if it does
MapOperation.putItems(mapPolicy, binName, m1),
// add the new timestamps to the level
ListOperation.append(binName, Value.get(p.get(1)), CTX.mapKey(Value.get(myLevel))),
// keep the oldest timestamp observed, remove the rest
ListOperation.removeByRankRange(binName, 0, 1, ListReturnType.INVERTED, CTX.mapKey(Value.get(myName))),
// keep only the mostRecent (4) levels sorted by timestamp
MapOperation.removeByRankRange(binName, negMostRecent, mostRecent, MapReturnType.INVERTED)
);
Code Sample
16 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Nested Example: Output
2019-12-14 22:10:05 IST INFO Add node BB9040011AC4202 172.17.0.4 3000
2019-12-14 22:10:05 IST INFO Add node BB9020011AC4202 172.17.0.2 3000
2019-12-14 22:10:05 IST INFO Add node BB9050011AC4202 172.17.0.5 3000
2019-12-14 22:10:05 IST INFO Add node BB9030011AC4202 172.17.0.3 3000
2019-12-14 22:10:05 IST INFO Working on 9 : 700
2019-12-14 22:10:05 IST INFO Record: (gen:1),(exp:316642206),(bins:(levels:{9=[700]}))
2019-12-14 22:10:05 IST INFO Working on 11 : 710
2019-12-14 22:10:05 IST INFO Record: (gen:2),(exp:316642206),(bins:(levels:{9=[700], 11=[710]}))
2019-12-14 22:10:05 IST INFO Working on 11 : 705
2019-12-14 22:10:05 IST INFO Record: (gen:3),(exp:316642206),(bins:(levels:{9=[700], 11=[705]}))
2019-12-14 22:10:05 IST INFO Working on 11 : 720
2019-12-14 22:10:05 IST INFO Record: (gen:4),(exp:316642206),(bins:(levels:{9=[700], 11=[705]}))
2019-12-14 22:10:05 IST INFO Working on 12 : 730
2019-12-14 22:10:05 IST INFO Record: (gen:5),(exp:316642206),(bins:(levels:{9=[700], 11=[705], 12=[730]}))
2019-12-14 22:10:05 IST INFO Working on 13 : 740
2019-12-14 22:10:05 IST INFO Record: (gen:6),(exp:316642206),(bins:(levels:{9=[700], 11=[705], 12=[730], 13=[740]}))
2019-12-14 22:10:05 IST INFO Working on 14 : 750
2019-12-14 22:10:05 IST INFO Record: (gen:7),(exp:316642206),(bins:(levels:{11=[705], 12=[730], 13=[740], 14=[750]}))
2019-12-14 22:10:05 IST INFO Working on 10 : 690
2019-12-14 22:10:05 IST INFO Record: (gen:8),(exp:316642206),(bins:(levels:{11=[705], 12=[730], 13=[740], 14=[750]}))
2019-12-14 22:10:05 IST INFO Working on 11 : 702
2019-12-14 22:10:05 IST INFO Record: (gen:9),(exp:316642206),(bins:(levels:{11=[702], 12=[730], 13=[740], 14=[750]}))
17 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Code Sample: The Read API
2019-12-15 07:20:14 IST INFO Working on 9 : 700
2019-12-15 07:20:14 IST INFO Record: (gen:1),(exp:316675215),(bins:(levels:{9=[700]}))
2019-12-15 07:20:14 IST INFO Looking for [731] got: [9=[700]]
2019-12-15 07:20:14 IST INFO Working on 11 : 710
2019-12-15 07:20:14 IST INFO Record: (gen:2),(exp:316675215),(bins:(levels:{9=[700], 11=[710]}))
2019-12-15 07:20:14 IST INFO Looking for [731] got: [11=[710]]
2019-12-15 07:20:14 IST INFO Working on 11 : 705
2019-12-15 07:20:14 IST INFO Record: (gen:3),(exp:316675215),(bins:(levels:{9=[700], 11=[705]}))
2019-12-15 07:20:14 IST INFO Looking for [731] got: [11=[705]]
2019-12-15 07:20:14 IST INFO Working on 11 : 720
2019-12-15 07:20:14 IST INFO Record: (gen:4),(exp:316675215),(bins:(levels:{9=[700], 11=[705]}))
2019-12-15 07:20:14 IST INFO Looking for [731] got: [11=[705]]
2019-12-15 07:20:14 IST INFO Working on 12 : 730
2019-12-15 07:20:14 IST INFO Record: (gen:5),(exp:316675215),(bins:(levels:{9=[700], 11=[705], 12=[730]}))
2019-12-15 07:20:14 IST INFO Looking for [731] got: [12=[730]]
2019-12-15 07:20:14 IST INFO Working on 13 : 740
2019-12-15 07:20:14 IST INFO Record: (gen:6),(exp:316675215),(bins:(levels:{9=[700], 11=[705], 12=[730], 13=[740]}))
2019-12-15 07:20:14 IST INFO Looking for [731] got: [12=[730]]
// PART 2: the Read API
// set the timestamp to search since timestamp is in a list
List<Value> ltmp = new ArrayList<Value>();
ltmp.add(Value.get(731));
// Find the item which was before our timestamp
Record rec2 = client.operate(params.writePolicy, key,
MapOperation.getByValueRelativeRankRange(binName, Value.get(ltmp), -1, 1, MapReturnType.KEY_VALUE));
18 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ The customer came back asking to change the data model – he would need
to keep more metadata on each level.
▪ So the data model changed, and it would now be a map containing a list of
lists:
{
7: [[700, 501]],
8: [[705, 508]],
9: [[720, 550]],
10: [[740, 600]]
}
Nested CDT Example – More Complex!
19 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
for (List p: data) {
console.info("Working on " + p.get(0) + " : " + p.get(1) + " : " + p.get(2));
int myName = Integer.parseInt(p.get(0).toString());
List<Value> ts = new ArrayList<Value>();
List<Value> l1 = new ArrayList<Value>();
// Create a touple for timestamp observer, and insert time(?)
ts.add(Value.get(p.get(1)));
ts.add(Value.get(p.get(2)));
// Create a list of lists element
l1.add(Value.get(ts));
// Create a map element of {level:[[ts, insert_date]]}
Map<Value,Value> m1 = new HashMap<Value,Value>();
m1.put(Value.get(myName), Value.get(l1));
// map policy to add a level only if it does not already exist, set the map to be sorted by the key
MapPolicy mapPolicy = new MapPolicy(MapOrder.KEY_ORDERED, (MapWriteFlags.CREATE_ONLY | MapWriteFlags.NO_FAIL));
// Operate to run multiple commands on the same key
Record record = client.operate(params.writePolicy, key,
// add the level with empty init ts if it does not exist, ignore if it does
MapOperation.putItems(mapPolicy, binName, m1),
// add the new timestamp to the level (so now we have 2 candidates)
ListOperation.append(binName, Value.get(ts), CTX.mapKey(Value.get(myName))),
// remove the redundant candidate and keep the oldest timestamp observed
ListOperation.removeByRankRange(binName, 0, 1, ListReturnType.INVERTED, CTX.mapKey(Value.get(myName))),
// keep only the mostRecent (4) levels sorted by timestamp
MapOperation.removeByRankRange(binName, negMostRecent, mostRecent, MapReturnType.INVERTED)
);
Code Sample – 3 level nest
20 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Code Sample: The Read API
// PART 2: the Read API
// set the timestamp to search since timestamp is in a list of lists since this is how we store it on the record
// The ts we look the date for is *731*
int value_to_look_for = 731;
List<Value> ltmp2 = new ArrayList<Value>();
ltmp2.add(Value.get(value_to_look_for));
ltmp2.add(Value.INFINITY);
List<Value> ltmp = new ArrayList<Value>();
ltmp.add(Value.get(ltmp2));
// Find the item which was before our timestamp, INF
Record rec2 = client.operate(params.writePolicy, key,
MapOperation.getByValueRelativeRankRange(binName, Value.get(ltmp), -1, 1, MapReturnType.KEY_VALUE));
console.info("Looking for " + ltmp + " got: " + rec2.getValue(binName));
21 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
Nested Example: Output
2019-12-14 22:21:01 IST INFO Add node BB9040011AC4202 172.17.0.4 3000
2019-12-14 22:21:01 IST INFO Add node BB9020011AC4202 172.17.0.2 3000
2019-12-14 22:21:01 IST INFO Add node BB9050011AC4202 172.17.0.5 3000
2019-12-14 22:21:01 IST INFO Add node BB9030011AC4202 172.17.0.3 3000
2019-12-14 22:21:02 IST INFO Working on 9 : 700 : 500
2019-12-14 22:21:02 IST INFO ##Record: (gen:1),(exp:316642862),(bins:(levels:{9=[[700, 500]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [9=[[700, 500]]]
2019-12-14 22:21:02 IST INFO Working on 11 : 710 : 550
2019-12-14 22:21:02 IST INFO ##Record: (gen:2),(exp:316642862),(bins:(levels:{9=[[700, 500]], 11=[[710, 550]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [11=[[710, 550]]]
2019-12-14 22:21:02 IST INFO Working on 11 : 705 : 540
2019-12-14 22:21:02 IST INFO ##Record: (gen:3),(exp:316642862),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [11=[[705, 540]]]
2019-12-14 22:21:02 IST INFO Working on 11 : 720 : 560
2019-12-14 22:21:02 IST INFO ##Record: (gen:4),(exp:316642863),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [11=[[705, 540]]]
2019-12-14 22:21:02 IST INFO Working on 12 : 730 : 570
2019-12-14 22:21:02 IST INFO ##Record: (gen:5),(exp:316642863),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]], 12=[[730, 570]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]]
2019-12-14 22:21:02 IST INFO Working on 13 : 740 : 590
2019-12-14 22:21:02 IST INFO ##Record: (gen:6),(exp:316642863),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]], 12=[[730, 570]], 13=[[740, 590]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]]
2019-12-14 22:21:02 IST INFO Working on 14 : 750 : 600
2019-12-14 22:21:02 IST INFO ##Record: (gen:7),(exp:316642863),(bins:(levels:{11=[[705, 540]], 12=[[730, 570]], 13=[[740, 590]], 14=[[750, 600]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]]
2019-12-14 22:21:02 IST INFO Working on 10 : 690 : 410
2019-12-14 22:21:02 IST INFO ##Record: (gen:8),(exp:316642863),(bins:(levels:{11=[[705, 540]], 12=[[730, 570]], 13=[[740, 590]], 14=[[750, 600]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]]
2019-12-14 22:21:02 IST INFO Working on 11 : 702 : 450
2019-12-14 22:21:02 IST INFO ##Record: (gen:9),(exp:316642863),(bins:(levels:{11=[[702, 450]], 12=[[730, 570]], 13=[[740, 590]], 14=[[750, 600]]}))
2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]]
22 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
▪ We talked about Aerospike’s data types, and how they can be used for modeling.
▪ We looked more closely at the nestd CDT APIs.
▪ Nested CDT are a powerful tool – use it wisely.
What next?
▪ If you haven’t seen it, take a look at the slides from the first Israeli ASUG meetups.
▪ Go to GitHub; clone the code samples repo; run it; read the code.
▪ Read the Aerospike blog. Get familiar with all the database features.
▪ Participate in the community forum (https://discuss.aerospike.com), StackOverflow’s
aerospike tag.
Summary
23 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc.
List & Map API
▪ https://www.aerospike.com/docs/guide/cdt-list.html
▪ https://www.aerospike.com/docs/guide/cdt-ordering.html
▪ https://www.aerospike.com/docs/guide/cdt-context.html
▪ https://www.aerospike.com/docs/guide/cdt-list-ops.html
▪ https://www.aerospike.com/docs/guide/cdt-map.html
▪ https://aerospike-python-client.readthedocs.io/en/latest/aerospike_helpers.operations.html
▪ https://www.aerospike.com/apidocs/java/com/aerospike/client/cdt/ListOperation.html
Code Samples
▪ https://github.com/aerospike-examples/
Aerospike Acadamy
▪ http://acadamy.aerospike.com/
More material you can explore:
Thank You!
Any questions?
zelkayam@aerospike.com
1 of 24

Recommended

Exploring Modeling - Doing More with Lists by
Exploring Modeling - Doing More with ListsExploring Modeling - Doing More with Lists
Exploring Modeling - Doing More with ListsRonen Botzer
454 views25 slides
Data Profiling in Apache Calcite by
Data Profiling in Apache CalciteData Profiling in Apache Calcite
Data Profiling in Apache CalciteJulian Hyde
1.7K views22 slides
Spatial query on vanilla databases by
Spatial query on vanilla databasesSpatial query on vanilla databases
Spatial query on vanilla databasesJulian Hyde
1.1K views48 slides
ACADILD:: HADOOP LESSON by
ACADILD:: HADOOP LESSON ACADILD:: HADOOP LESSON
ACADILD:: HADOOP LESSON Padma shree. T
92 views10 slides
Apache Nemo by
Apache NemoApache Nemo
Apache NemoNAVER Engineering
706 views70 slides
Usage of NCL, IDL, and MATLAB to access NASA HDF4/HDF-EOS2/HDF-EOS5 data by
Usage of NCL, IDL, and MATLAB to access NASA HDF4/HDF-EOS2/HDF-EOS5 dataUsage of NCL, IDL, and MATLAB to access NASA HDF4/HDF-EOS2/HDF-EOS5 data
Usage of NCL, IDL, and MATLAB to access NASA HDF4/HDF-EOS2/HDF-EOS5 dataThe HDF-EOS Tools and Information Center
2.9K views61 slides

More Related Content

What's hot

Lazy beats Smart and Fast by
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and FastJulian Hyde
975 views51 slides
Schema Design by Chad Tindel, Solution Architect, 10gen by
Schema Design  by Chad Tindel, Solution Architect, 10genSchema Design  by Chad Tindel, Solution Architect, 10gen
Schema Design by Chad Tindel, Solution Architect, 10genMongoDB
5.9K views32 slides
C07.heaps by
C07.heapsC07.heaps
C07.heapssyeda madeha azmat
28 views14 slides
EDF2012 Kostas Tzouma - Linking and analyzing bigdata - Stratosphere by
EDF2012   Kostas Tzouma - Linking and analyzing bigdata - StratosphereEDF2012   Kostas Tzouma - Linking and analyzing bigdata - Stratosphere
EDF2012 Kostas Tzouma - Linking and analyzing bigdata - StratosphereEuropean Data Forum
948 views17 slides
Taming the Tiger: Tips and Tricks for Using Telegraf by
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafInfluxData
146 views91 slides
Processing Geospatial at Scale at LocationTech by
Processing Geospatial at Scale at LocationTechProcessing Geospatial at Scale at LocationTech
Processing Geospatial at Scale at LocationTechRob Emanuele
1.6K views77 slides

What's hot(20)

Lazy beats Smart and Fast by Julian Hyde
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and Fast
Julian Hyde975 views
Schema Design by Chad Tindel, Solution Architect, 10gen by MongoDB
Schema Design  by Chad Tindel, Solution Architect, 10genSchema Design  by Chad Tindel, Solution Architect, 10gen
Schema Design by Chad Tindel, Solution Architect, 10gen
MongoDB5.9K views
EDF2012 Kostas Tzouma - Linking and analyzing bigdata - Stratosphere by European Data Forum
EDF2012   Kostas Tzouma - Linking and analyzing bigdata - StratosphereEDF2012   Kostas Tzouma - Linking and analyzing bigdata - Stratosphere
EDF2012 Kostas Tzouma - Linking and analyzing bigdata - Stratosphere
Taming the Tiger: Tips and Tricks for Using Telegraf by InfluxData
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using Telegraf
InfluxData146 views
Processing Geospatial at Scale at LocationTech by Rob Emanuele
Processing Geospatial at Scale at LocationTechProcessing Geospatial at Scale at LocationTech
Processing Geospatial at Scale at LocationTech
Rob Emanuele1.6K views
ちょっとHadoopについて語ってみるか(仮題) by moai kids
ちょっとHadoopについて語ってみるか(仮題)ちょっとHadoopについて語ってみるか(仮題)
ちょっとHadoopについて語ってみるか(仮題)
moai kids3.2K views
Processing Geospatial Data At Scale @locationtech by Rob Emanuele
Processing Geospatial Data At Scale @locationtechProcessing Geospatial Data At Scale @locationtech
Processing Geospatial Data At Scale @locationtech
Rob Emanuele1.2K views
Q4 2016 GeoTrellis Presentation by Rob Emanuele
Q4 2016 GeoTrellis PresentationQ4 2016 GeoTrellis Presentation
Q4 2016 GeoTrellis Presentation
Rob Emanuele963 views
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux... by InfluxData
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
InfluxData1.2K views
Enabling Access to Big Geospatial Data with LocationTech and Apache projects by Rob Emanuele
Enabling Access to Big Geospatial Data with LocationTech and Apache projectsEnabling Access to Big Geospatial Data with LocationTech and Apache projects
Enabling Access to Big Geospatial Data with LocationTech and Apache projects
Rob Emanuele735 views
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa... by InfluxData
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...
InfluxData136 views
Geo Package and OWS Context at FOSS4G PDX by Luis Bermudez
Geo Package and OWS Context at FOSS4G PDXGeo Package and OWS Context at FOSS4G PDX
Geo Package and OWS Context at FOSS4G PDX
Luis Bermudez1.7K views
ComputeFest 2012: Intro To R for Physical Sciences by alexstorer
ComputeFest 2012: Intro To R for Physical SciencesComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical Sciences
alexstorer470 views
Hadoop導入事例 in クックパッド by Tatsuya Sasaki
Hadoop導入事例 in クックパッドHadoop導入事例 in クックパッド
Hadoop導入事例 in クックパッド
Tatsuya Sasaki5.4K views
Academy PRO: Elasticsearch Misc by Binary Studio
Academy PRO: Elasticsearch MiscAcademy PRO: Elasticsearch Misc
Academy PRO: Elasticsearch Misc
Binary Studio172 views
Latent Semantic Analysis of Wikipedia with Spark by Sandy Ryza
Latent Semantic Analysis of Wikipedia with SparkLatent Semantic Analysis of Wikipedia with Spark
Latent Semantic Analysis of Wikipedia with Spark
Sandy Ryza9.5K views
All you need to know about CREATE STATISTICS by EDB
All you need to know about CREATE STATISTICSAll you need to know about CREATE STATISTICS
All you need to know about CREATE STATISTICS
EDB196 views

Similar to Aerospike Nested CDTs - Meetup Dec 2019

Exploring Modeling - Best Practices with Aerospike Data Types by
Exploring Modeling - Best Practices with Aerospike Data TypesExploring Modeling - Best Practices with Aerospike Data Types
Exploring Modeling - Best Practices with Aerospike Data TypesRonen Botzer
466 views25 slides
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi... by
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...InfluxData
515 views30 slides
AWS Office Hours: Amazon Elastic MapReduce by
AWS Office Hours: Amazon Elastic MapReduce AWS Office Hours: Amazon Elastic MapReduce
AWS Office Hours: Amazon Elastic MapReduce Amazon Web Services
3.7K views26 slides
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift by
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftBest Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftAmazon Web Services
751 views73 slides
Bridging Structured and Unstructred Data with Apache Hadoop and Vertica by
Bridging Structured and Unstructred Data with Apache Hadoop and VerticaBridging Structured and Unstructred Data with Apache Hadoop and Vertica
Bridging Structured and Unstructred Data with Apache Hadoop and VerticaSteve Watt
4.9K views35 slides
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges... by
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...Altinity Ltd
3.7K views34 slides

Similar to Aerospike Nested CDTs - Meetup Dec 2019(20)

Exploring Modeling - Best Practices with Aerospike Data Types by Ronen Botzer
Exploring Modeling - Best Practices with Aerospike Data TypesExploring Modeling - Best Practices with Aerospike Data Types
Exploring Modeling - Best Practices with Aerospike Data Types
Ronen Botzer466 views
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi... by InfluxData
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
InfluxData515 views
AWS Office Hours: Amazon Elastic MapReduce by Amazon Web Services
AWS Office Hours: Amazon Elastic MapReduce AWS Office Hours: Amazon Elastic MapReduce
AWS Office Hours: Amazon Elastic MapReduce
Amazon Web Services3.7K views
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift by Amazon Web Services
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftBest Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Bridging Structured and Unstructred Data with Apache Hadoop and Vertica by Steve Watt
Bridging Structured and Unstructred Data with Apache Hadoop and VerticaBridging Structured and Unstructred Data with Apache Hadoop and Vertica
Bridging Structured and Unstructred Data with Apache Hadoop and Vertica
Steve Watt4.9K views
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges... by Altinity Ltd
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
Altinity Ltd3.7K views
ClickHouse materialized views - a secret weapon for high performance analytic... by Altinity Ltd
ClickHouse materialized views - a secret weapon for high performance analytic...ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...
Altinity Ltd1.3K views
Aerospike User Group: Exploring Data Modeling by Brillix
Aerospike User Group: Exploring Data ModelingAerospike User Group: Exploring Data Modeling
Aerospike User Group: Exploring Data Modeling
Brillix499 views
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla by ScyllaDB
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
ScyllaDB4.3K views
Real-Time Spark: From Interactive Queries to Streaming by Databricks
Real-Time Spark: From Interactive Queries to StreamingReal-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to Streaming
Databricks5.2K views
Advanced kapacitor by InfluxData
Advanced kapacitorAdvanced kapacitor
Advanced kapacitor
InfluxData5.6K views
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Web by Heiko Behrens
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Webbeyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
Heiko Behrens1.4K views
SF Big Analytics 20191112: How to performance-tune Spark applications in larg... by Chester Chen
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
Chester Chen466 views
A Century Of Weather Data - Midwest.io by Randall Hunt
A Century Of Weather Data - Midwest.ioA Century Of Weather Data - Midwest.io
A Century Of Weather Data - Midwest.io
Randall Hunt616 views
Tactical data engineering by Julian Hyde
Tactical data engineeringTactical data engineering
Tactical data engineering
Julian Hyde970 views
Keeping Spark on Track: Productionizing Spark for ETL by Databricks
Keeping Spark on Track: Productionizing Spark for ETLKeeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETL
Databricks4.2K views

More from Aerospike

Aerospike-AppsFlyer COVID-19 Crisis Growth Elad Leev by
Aerospike-AppsFlyer COVID-19 Crisis Growth Elad LeevAerospike-AppsFlyer COVID-19 Crisis Growth Elad Leev
Aerospike-AppsFlyer COVID-19 Crisis Growth Elad LeevAerospike
99 views21 slides
Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ... by
Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ...Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ...
Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ...Aerospike
63 views20 slides
Contentsquare Aerospike Usage and COVID-19 Impact - Doron Hoffman by
Contentsquare Aerospike Usage and COVID-19 Impact - Doron HoffmanContentsquare Aerospike Usage and COVID-19 Impact - Doron Hoffman
Contentsquare Aerospike Usage and COVID-19 Impact - Doron HoffmanAerospike
90 views15 slides
Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &... by
Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &...Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &...
Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &...Aerospike
48 views16 slides
Aerospike Meetup - Introduction - Ami - 04 March 2020 by
Aerospike Meetup - Introduction - Ami - 04 March 2020Aerospike Meetup - Introduction - Ami - 04 March 2020
Aerospike Meetup - Introduction - Ami - 04 March 2020Aerospike
86 views20 slides
Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04... by
Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04...Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04...
Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04...Aerospike
65 views15 slides

More from Aerospike(10)

Aerospike-AppsFlyer COVID-19 Crisis Growth Elad Leev by Aerospike
Aerospike-AppsFlyer COVID-19 Crisis Growth Elad LeevAerospike-AppsFlyer COVID-19 Crisis Growth Elad Leev
Aerospike-AppsFlyer COVID-19 Crisis Growth Elad Leev
Aerospike99 views
Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ... by Aerospike
Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ...Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ...
Handling Increasing Load and Reducing Costs Using Aerospike NoSQL Database - ...
Aerospike63 views
Contentsquare Aerospike Usage and COVID-19 Impact - Doron Hoffman by Aerospike
Contentsquare Aerospike Usage and COVID-19 Impact - Doron HoffmanContentsquare Aerospike Usage and COVID-19 Impact - Doron Hoffman
Contentsquare Aerospike Usage and COVID-19 Impact - Doron Hoffman
Aerospike90 views
Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &... by Aerospike
Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &...Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &...
Handling Increasing Load and Reducing Costs During COVID-19 Crisis - Oshrat &...
Aerospike48 views
Aerospike Meetup - Introduction - Ami - 04 March 2020 by Aerospike
Aerospike Meetup - Introduction - Ami - 04 March 2020Aerospike Meetup - Introduction - Ami - 04 March 2020
Aerospike Meetup - Introduction - Ami - 04 March 2020
Aerospike86 views
Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04... by Aerospike
Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04...Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04...
Aerospike Meetup - Real Time Insights using Spark with Aerospike - Zohar - 04...
Aerospike65 views
Aerospike Meetup - Nielsen Customer Story - Alex - 04 March 2020 by Aerospike
Aerospike Meetup - Nielsen Customer Story - Alex - 04 March 2020Aerospike Meetup - Nielsen Customer Story - Alex - 04 March 2020
Aerospike Meetup - Nielsen Customer Story - Alex - 04 March 2020
Aerospike110 views
Aerospike Roadmap Overview - Meetup Dec 2019 by Aerospike
Aerospike Roadmap Overview - Meetup Dec 2019Aerospike Roadmap Overview - Meetup Dec 2019
Aerospike Roadmap Overview - Meetup Dec 2019
Aerospike110 views
Aerospike Data Modeling - Meetup Dec 2019 by Aerospike
Aerospike Data Modeling - Meetup Dec 2019Aerospike Data Modeling - Meetup Dec 2019
Aerospike Data Modeling - Meetup Dec 2019
Aerospike40 views
JDBC Driver for Aerospike - Meetup Dec 2019 by Aerospike
JDBC Driver for Aerospike - Meetup Dec 2019JDBC Driver for Aerospike - Meetup Dec 2019
JDBC Driver for Aerospike - Meetup Dec 2019
Aerospike107 views

Recently uploaded

Liqid: Composable CXL Preview by
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL PreviewCXL Forum
121 views8 slides
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ... by
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ..."Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...Fwdays
33 views39 slides
Tunable Laser (1).pptx by
Tunable Laser (1).pptxTunable Laser (1).pptx
Tunable Laser (1).pptxHajira Mahmood
21 views37 slides
"How we switched to Kanban and how it integrates with product planning", Vady... by
"How we switched to Kanban and how it integrates with product planning", Vady..."How we switched to Kanban and how it integrates with product planning", Vady...
"How we switched to Kanban and how it integrates with product planning", Vady...Fwdays
61 views24 slides
The Importance of Cybersecurity for Digital Transformation by
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital TransformationNUS-ISS
25 views26 slides
Combining Orchestration and Choreography for a Clean Architecture by
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean ArchitectureThomasHeinrichs1
68 views24 slides

Recently uploaded(20)

Liqid: Composable CXL Preview by CXL Forum
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum121 views
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ... by Fwdays
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ..."Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
Fwdays33 views
"How we switched to Kanban and how it integrates with product planning", Vady... by Fwdays
"How we switched to Kanban and how it integrates with product planning", Vady..."How we switched to Kanban and how it integrates with product planning", Vady...
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays61 views
The Importance of Cybersecurity for Digital Transformation by NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS25 views
Combining Orchestration and Choreography for a Clean Architecture by ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs168 views
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad... by Fwdays
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad..."Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad...
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad...
Fwdays40 views
Understanding GenAI/LLM and What is Google Offering - Felix Goh by NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS39 views
Micron CXL product and architecture update by CXL Forum
Micron CXL product and architecture updateMicron CXL product and architecture update
Micron CXL product and architecture update
CXL Forum27 views
MemVerge: Past Present and Future of CXL by CXL Forum
MemVerge: Past Present and Future of CXLMemVerge: Past Present and Future of CXL
MemVerge: Past Present and Future of CXL
CXL Forum110 views
MemVerge: Memory Viewer Software by CXL Forum
MemVerge: Memory Viewer SoftwareMemVerge: Memory Viewer Software
MemVerge: Memory Viewer Software
CXL Forum118 views
Photowave Presentation Slides - 11.8.23.pptx by CXL Forum
Photowave Presentation Slides - 11.8.23.pptxPhotowave Presentation Slides - 11.8.23.pptx
Photowave Presentation Slides - 11.8.23.pptx
CXL Forum126 views
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur by Fwdays
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
Fwdays40 views
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure by CXL Forum
Astera Labs:  Intelligent Connectivity for Cloud and AI InfrastructureAstera Labs:  Intelligent Connectivity for Cloud and AI Infrastructure
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure
CXL Forum125 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk90 views
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy by Fwdays
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
Fwdays40 views

Aerospike Nested CDTs - Meetup Dec 2019

  • 1. Exploring Data Modeling Modeling with Nested CDTs Zohar Elkayam, Aerospike
  • 2. 2 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ A Quick Overview of Aerospike Data Types. ▪ Recap: CDTs: The List and Map APIs. ▪ Modeling with Nested CDTs. ▪ A real-life Example. Agenda
  • 3. 3 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Aerospike is a Primary Key Database Objects stored in Aerospike are called records. A bin holds the value of a supported data type: integer, double, string, bytes, list, map, geospatial. Every record is uniquely identified by the 3-tuple (namespace, set, primary-key). A record contains one or more bins. (namespace, set, primary-key) EXP – Expiration Timestamp LUT – Last Update Time GEN – Generation RECORD EXP LUT GEN BIN1 BIN2
  • 4. 4 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ Aerospike is a row-oriented distributed database. ▪ Rows (records) contain one or more columns (bins). ▪ Similar to an RDBMS with primary-key table lookups. ▪ Single record transactions. Aerospike Concepts Aerospike RDBMS Namespace Tablespace or Database Set Table Record Row Bin Column Bin type Integer Double String Bytes List (Unordered, Ordered) Map (Unordered, K-Ordered, KV-Ordered) GeoJSON
  • 5. 5 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ Aerospike data types have powerful APIs. ▪ Atomic operations simplify application logic and reduce network load. ▪ Complex Data Types (CDT – such as List and Map) can be nested to many levels. ▪ Before 4.6: Atomic operations can execute only at the top level of a List or Map. ▪ After 4.6: Atomic operations can execute at all levels of a nested CDT. ▪ Native operations perform and scale better than UDFs. Data Modeling in Aerospike
  • 6. 6 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Example of a Record ('test', 'users’, 37) ➔ { 'name': 'Apolonius Kensington', 'age': 31, 'logins_ts': [ 1576077683, 1576224612, 1576350640 ], 'cards': [ { 'type': 'visa’, 'last4': 5996, 'expires': '2019-09', 'usage_cnt': 12}, { 'type': 'mastercard', 'last4': 4177, 'expires': '2018-11', 'usage_cnt': 1} ], 'pass': p??Ȇ??"R*?vw96Q } A simple list bin A map Nested CDT Bin: a list of maps
  • 7. 7 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. List operations supported by the server. Method names in the clients might be different. • set_type() (unordered, ordered) • sort(), clear(), size() • append(), append_items(), insert(), insert_items(), set(), increment() • get_by_index(), get_by_index_range(), get_by_rank(), get_by_rank_range(), get_by_value(), get_by_value_interval(), get_all_by_value(), get_all_by_value_list(), get_by_value_rel_rank_range() • remove_by_index(), remove_by_index_range(), remove_by_rank(), remove_by_rank_range(), remove_by_value(), remove_by_value_interval(), remove_all_by_value(), remove_all_by_value_list(), remove_by_value_rel_rank_range() List Operations
  • 8. 8 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Map operations supported by the server. Method names in the clients might be different. • set_type() (unordered, k-ordered or kv-ordered) • size(), clear() • add(), add_items(), increment(), decrement() • get_by_key(), get_by_index(), get_by_rank(), get_by_key_interval(), get_by_index_range(), get_by_value_interval(), get_by_rank_range(), get_all_by_value(), get_by_key_rel_index_range(), get_by_value_rel_rank_range(), get_all_by_key_list(), get_all_by_value_list() • remove_by_key(), remove_by_index(), remove_by_rank(), remove_by_key_interval(), remove_by_index_range(), remove_by_value_interval(), remove_by_rank_range(), remove_all_by_value(), remove_all_by_key_list(), remove_all_by_value_list(), remove_by_key_rel_index_range(), remove_by_value_rel_rank_range() Map Operations
  • 9. 9 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ Version 4.6 added the ability to perform list and map operations on nested objects. ▪ For example, we will be able to manipulate lists that are the value of a map items (2nd level) the same way we manipulate the map items themselves (1st level). ▪ The new CDT introduced some general performance improvements around comparing lists and maps. ▪ This is currently supported on some of the clients: C, C#, Java, Node.js, Python, Go. New CDT (Map and List) Operations
  • 10. 10 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ Nested CDT operations are executed on the internal level. Example: ▪ Adding to a list inside a map would use List Operations. ▪ Incrementing a value a value of a map inside a list would use Map Operations. ▪ But how do we specify the actual location? Use the CTX context object. ▪ The CTX object will indicate where to find the object/value to operate on. ▪ We can nest the CTX to get into a deeper level. ▪ https://www.aerospike.com/docs/guide/cdt-context.html Getting into the Nested: CTX BY_LIST_INDEX BY_LIST_RANK BY_LIST_VALUE BY_MAP_INDEX BY_MAP_RANK BY_MAP_KEY BY_MAP_VALUE
  • 11. 11 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. bin = [0, 1, [2, [3, 4], 5, 6], 7, [8, 9] ] Sub level 2 (1 CTX object): > subcontext_eval([BY_LIST_INDEX, -1], list.append(99) ) bin = [0, 1, [2, [3, 4], 5, 6], 7, [8, 9, 99] ] Sub level 3 (2 CTX objects, read left to right): > subcontext_eval([BY_LIST_INDEX, 2, BY_LIST_INDEX, 1], list.append(44)) bin = [0, 1, [2, [3, 4, 44], 5, 6], 7, [8, 9, 99] ] Top Level (no CTX object): > list.append(10) bin = [0, 1, [2, [3, 4, 44], 5, 6], 7, [8, 9, 99], 10 ] CTX Examples
  • 12. 12 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ The customer is getting tuples of game level and timestamp when they were sampled for each player. ▪ Those levels and timestamps are not received in order. ▪ The customer would like to keep only the earliest timestamp observed for each level. ▪ The customer also would like to keep only the last n levels and remove the rest. ▪ The customer would also like to query the list by timestamp and get the level the player was at that timestamp (equal or observed before that ts). Nested CDT Example (a real-life example!)
  • 13. 13 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ A possible data model to solve the problem: keep a map where the level is the key and the timestamp is the value: { 7: 700, 8: 705, 9: 720, 10: 740 } ▪ But how do we handle the out of order records? How do we query? ▪ We will need to do that in the app – read the record, recreate the entire map and rewrite the record (assuming no one tried to change the record while we were modifying it in the app: use CAS to insure that!). The Data Model: Original
  • 14. 14 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ The suggested data model: keep a map where the level is the key and a list of timestamps is the value. { 7: [700], 8: [705], 9: [720], 10: [740] } ▪ We will append and new timestamp to the list and trim it to keep the oldest one. We will also trim the entire map based on the keys – all of this will be done incrementally and in a single operation. The Data Model: Using Nested CDT and API
  • 15. 15 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. for (List p: data) { console.info("Working on " + p.get(0) + " : " + p.get(1)); int myLevel = Integer.parseInt(p.get(0).toString()); List<Value> l1 = new ArrayList<Value>(); Map<Value,Value> m1 = new HashMap<Value,Value>(); m1.put(Value.get(myLevel), Value.get(l1)); // map policy to add a level only if it does not already exist, set the map to be sorted by the key MapPolicy mapPolicy = new MapPolicy(MapOrder.KEY_ORDERED, (MapWriteFlags.CREATE_ONLY | MapWriteFlags.NO_FAIL)); // Operate to run multiple commands on the same key Record record = client.operate(params.writePolicy, key, // add the level with empty initial ts if it does not exist, skip if it does MapOperation.putItems(mapPolicy, binName, m1), // add the new timestamps to the level ListOperation.append(binName, Value.get(p.get(1)), CTX.mapKey(Value.get(myLevel))), // keep the oldest timestamp observed, remove the rest ListOperation.removeByRankRange(binName, 0, 1, ListReturnType.INVERTED, CTX.mapKey(Value.get(myName))), // keep only the mostRecent (4) levels sorted by timestamp MapOperation.removeByRankRange(binName, negMostRecent, mostRecent, MapReturnType.INVERTED) ); Code Sample
  • 16. 16 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Nested Example: Output 2019-12-14 22:10:05 IST INFO Add node BB9040011AC4202 172.17.0.4 3000 2019-12-14 22:10:05 IST INFO Add node BB9020011AC4202 172.17.0.2 3000 2019-12-14 22:10:05 IST INFO Add node BB9050011AC4202 172.17.0.5 3000 2019-12-14 22:10:05 IST INFO Add node BB9030011AC4202 172.17.0.3 3000 2019-12-14 22:10:05 IST INFO Working on 9 : 700 2019-12-14 22:10:05 IST INFO Record: (gen:1),(exp:316642206),(bins:(levels:{9=[700]})) 2019-12-14 22:10:05 IST INFO Working on 11 : 710 2019-12-14 22:10:05 IST INFO Record: (gen:2),(exp:316642206),(bins:(levels:{9=[700], 11=[710]})) 2019-12-14 22:10:05 IST INFO Working on 11 : 705 2019-12-14 22:10:05 IST INFO Record: (gen:3),(exp:316642206),(bins:(levels:{9=[700], 11=[705]})) 2019-12-14 22:10:05 IST INFO Working on 11 : 720 2019-12-14 22:10:05 IST INFO Record: (gen:4),(exp:316642206),(bins:(levels:{9=[700], 11=[705]})) 2019-12-14 22:10:05 IST INFO Working on 12 : 730 2019-12-14 22:10:05 IST INFO Record: (gen:5),(exp:316642206),(bins:(levels:{9=[700], 11=[705], 12=[730]})) 2019-12-14 22:10:05 IST INFO Working on 13 : 740 2019-12-14 22:10:05 IST INFO Record: (gen:6),(exp:316642206),(bins:(levels:{9=[700], 11=[705], 12=[730], 13=[740]})) 2019-12-14 22:10:05 IST INFO Working on 14 : 750 2019-12-14 22:10:05 IST INFO Record: (gen:7),(exp:316642206),(bins:(levels:{11=[705], 12=[730], 13=[740], 14=[750]})) 2019-12-14 22:10:05 IST INFO Working on 10 : 690 2019-12-14 22:10:05 IST INFO Record: (gen:8),(exp:316642206),(bins:(levels:{11=[705], 12=[730], 13=[740], 14=[750]})) 2019-12-14 22:10:05 IST INFO Working on 11 : 702 2019-12-14 22:10:05 IST INFO Record: (gen:9),(exp:316642206),(bins:(levels:{11=[702], 12=[730], 13=[740], 14=[750]}))
  • 17. 17 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Code Sample: The Read API 2019-12-15 07:20:14 IST INFO Working on 9 : 700 2019-12-15 07:20:14 IST INFO Record: (gen:1),(exp:316675215),(bins:(levels:{9=[700]})) 2019-12-15 07:20:14 IST INFO Looking for [731] got: [9=[700]] 2019-12-15 07:20:14 IST INFO Working on 11 : 710 2019-12-15 07:20:14 IST INFO Record: (gen:2),(exp:316675215),(bins:(levels:{9=[700], 11=[710]})) 2019-12-15 07:20:14 IST INFO Looking for [731] got: [11=[710]] 2019-12-15 07:20:14 IST INFO Working on 11 : 705 2019-12-15 07:20:14 IST INFO Record: (gen:3),(exp:316675215),(bins:(levels:{9=[700], 11=[705]})) 2019-12-15 07:20:14 IST INFO Looking for [731] got: [11=[705]] 2019-12-15 07:20:14 IST INFO Working on 11 : 720 2019-12-15 07:20:14 IST INFO Record: (gen:4),(exp:316675215),(bins:(levels:{9=[700], 11=[705]})) 2019-12-15 07:20:14 IST INFO Looking for [731] got: [11=[705]] 2019-12-15 07:20:14 IST INFO Working on 12 : 730 2019-12-15 07:20:14 IST INFO Record: (gen:5),(exp:316675215),(bins:(levels:{9=[700], 11=[705], 12=[730]})) 2019-12-15 07:20:14 IST INFO Looking for [731] got: [12=[730]] 2019-12-15 07:20:14 IST INFO Working on 13 : 740 2019-12-15 07:20:14 IST INFO Record: (gen:6),(exp:316675215),(bins:(levels:{9=[700], 11=[705], 12=[730], 13=[740]})) 2019-12-15 07:20:14 IST INFO Looking for [731] got: [12=[730]] // PART 2: the Read API // set the timestamp to search since timestamp is in a list List<Value> ltmp = new ArrayList<Value>(); ltmp.add(Value.get(731)); // Find the item which was before our timestamp Record rec2 = client.operate(params.writePolicy, key, MapOperation.getByValueRelativeRankRange(binName, Value.get(ltmp), -1, 1, MapReturnType.KEY_VALUE));
  • 18. 18 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ The customer came back asking to change the data model – he would need to keep more metadata on each level. ▪ So the data model changed, and it would now be a map containing a list of lists: { 7: [[700, 501]], 8: [[705, 508]], 9: [[720, 550]], 10: [[740, 600]] } Nested CDT Example – More Complex!
  • 19. 19 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. for (List p: data) { console.info("Working on " + p.get(0) + " : " + p.get(1) + " : " + p.get(2)); int myName = Integer.parseInt(p.get(0).toString()); List<Value> ts = new ArrayList<Value>(); List<Value> l1 = new ArrayList<Value>(); // Create a touple for timestamp observer, and insert time(?) ts.add(Value.get(p.get(1))); ts.add(Value.get(p.get(2))); // Create a list of lists element l1.add(Value.get(ts)); // Create a map element of {level:[[ts, insert_date]]} Map<Value,Value> m1 = new HashMap<Value,Value>(); m1.put(Value.get(myName), Value.get(l1)); // map policy to add a level only if it does not already exist, set the map to be sorted by the key MapPolicy mapPolicy = new MapPolicy(MapOrder.KEY_ORDERED, (MapWriteFlags.CREATE_ONLY | MapWriteFlags.NO_FAIL)); // Operate to run multiple commands on the same key Record record = client.operate(params.writePolicy, key, // add the level with empty init ts if it does not exist, ignore if it does MapOperation.putItems(mapPolicy, binName, m1), // add the new timestamp to the level (so now we have 2 candidates) ListOperation.append(binName, Value.get(ts), CTX.mapKey(Value.get(myName))), // remove the redundant candidate and keep the oldest timestamp observed ListOperation.removeByRankRange(binName, 0, 1, ListReturnType.INVERTED, CTX.mapKey(Value.get(myName))), // keep only the mostRecent (4) levels sorted by timestamp MapOperation.removeByRankRange(binName, negMostRecent, mostRecent, MapReturnType.INVERTED) ); Code Sample – 3 level nest
  • 20. 20 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Code Sample: The Read API // PART 2: the Read API // set the timestamp to search since timestamp is in a list of lists since this is how we store it on the record // The ts we look the date for is *731* int value_to_look_for = 731; List<Value> ltmp2 = new ArrayList<Value>(); ltmp2.add(Value.get(value_to_look_for)); ltmp2.add(Value.INFINITY); List<Value> ltmp = new ArrayList<Value>(); ltmp.add(Value.get(ltmp2)); // Find the item which was before our timestamp, INF Record rec2 = client.operate(params.writePolicy, key, MapOperation.getByValueRelativeRankRange(binName, Value.get(ltmp), -1, 1, MapReturnType.KEY_VALUE)); console.info("Looking for " + ltmp + " got: " + rec2.getValue(binName));
  • 21. 21 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. Nested Example: Output 2019-12-14 22:21:01 IST INFO Add node BB9040011AC4202 172.17.0.4 3000 2019-12-14 22:21:01 IST INFO Add node BB9020011AC4202 172.17.0.2 3000 2019-12-14 22:21:01 IST INFO Add node BB9050011AC4202 172.17.0.5 3000 2019-12-14 22:21:01 IST INFO Add node BB9030011AC4202 172.17.0.3 3000 2019-12-14 22:21:02 IST INFO Working on 9 : 700 : 500 2019-12-14 22:21:02 IST INFO ##Record: (gen:1),(exp:316642862),(bins:(levels:{9=[[700, 500]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [9=[[700, 500]]] 2019-12-14 22:21:02 IST INFO Working on 11 : 710 : 550 2019-12-14 22:21:02 IST INFO ##Record: (gen:2),(exp:316642862),(bins:(levels:{9=[[700, 500]], 11=[[710, 550]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [11=[[710, 550]]] 2019-12-14 22:21:02 IST INFO Working on 11 : 705 : 540 2019-12-14 22:21:02 IST INFO ##Record: (gen:3),(exp:316642862),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [11=[[705, 540]]] 2019-12-14 22:21:02 IST INFO Working on 11 : 720 : 560 2019-12-14 22:21:02 IST INFO ##Record: (gen:4),(exp:316642863),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [11=[[705, 540]]] 2019-12-14 22:21:02 IST INFO Working on 12 : 730 : 570 2019-12-14 22:21:02 IST INFO ##Record: (gen:5),(exp:316642863),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]], 12=[[730, 570]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]] 2019-12-14 22:21:02 IST INFO Working on 13 : 740 : 590 2019-12-14 22:21:02 IST INFO ##Record: (gen:6),(exp:316642863),(bins:(levels:{9=[[700, 500]], 11=[[705, 540]], 12=[[730, 570]], 13=[[740, 590]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]] 2019-12-14 22:21:02 IST INFO Working on 14 : 750 : 600 2019-12-14 22:21:02 IST INFO ##Record: (gen:7),(exp:316642863),(bins:(levels:{11=[[705, 540]], 12=[[730, 570]], 13=[[740, 590]], 14=[[750, 600]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]] 2019-12-14 22:21:02 IST INFO Working on 10 : 690 : 410 2019-12-14 22:21:02 IST INFO ##Record: (gen:8),(exp:316642863),(bins:(levels:{11=[[705, 540]], 12=[[730, 570]], 13=[[740, 590]], 14=[[750, 600]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]] 2019-12-14 22:21:02 IST INFO Working on 11 : 702 : 450 2019-12-14 22:21:02 IST INFO ##Record: (gen:9),(exp:316642863),(bins:(levels:{11=[[702, 450]], 12=[[730, 570]], 13=[[740, 590]], 14=[[750, 600]]})) 2019-12-14 22:21:02 IST INFO Looking for [[731, INF]] got: [12=[[730, 570]]]
  • 22. 22 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. ▪ We talked about Aerospike’s data types, and how they can be used for modeling. ▪ We looked more closely at the nestd CDT APIs. ▪ Nested CDT are a powerful tool – use it wisely. What next? ▪ If you haven’t seen it, take a look at the slides from the first Israeli ASUG meetups. ▪ Go to GitHub; clone the code samples repo; run it; read the code. ▪ Read the Aerospike blog. Get familiar with all the database features. ▪ Participate in the community forum (https://discuss.aerospike.com), StackOverflow’s aerospike tag. Summary
  • 23. 23 Proprietary & Confidential | All rights reserved. © 2019 Aerospike Inc. List & Map API ▪ https://www.aerospike.com/docs/guide/cdt-list.html ▪ https://www.aerospike.com/docs/guide/cdt-ordering.html ▪ https://www.aerospike.com/docs/guide/cdt-context.html ▪ https://www.aerospike.com/docs/guide/cdt-list-ops.html ▪ https://www.aerospike.com/docs/guide/cdt-map.html ▪ https://aerospike-python-client.readthedocs.io/en/latest/aerospike_helpers.operations.html ▪ https://www.aerospike.com/apidocs/java/com/aerospike/client/cdt/ListOperation.html Code Samples ▪ https://github.com/aerospike-examples/ Aerospike Acadamy ▪ http://acadamy.aerospike.com/ More material you can explore: