This notebook illustrates the Aerospike Document API, which is used to store a JSON document in Aerospike database and perform operations on a stored JSON document, with code examples.
This notebook requires the Aerospike Database running locally with Java kernel and Aerospike Java Client. To create a Docker container that satisfies the requirements and holds a copy of Aerospike notebooks, visit the Aerospike Notebooks Repo.
The Document API is introduced in blog posts this and this.
This goal of this notebook is to demonstrate the examples from these blog posts and also to allow easy experimentation with Document API and JSONPath capabilities.
The main topics in this notebook include:
This tutorial assumes familiarity with the following topics:
This notebook requires that Aerospike Database is running.
import io.github.spencerpark.ijava.IJava;
import io.github.spencerpark.jupyter.kernel.magic.common.Shell;
IJava.getKernelInstance().getMagics().registerMagics(Shell.class);
%sh asd
Aerospike Java client 5.1.3 and the document api library.
%%loadFromPOM
<dependencies>
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-client</artifactId>
<version>5.1.3</version>
</dependency>
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-document-api</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
Define convenience functions readJSONFromAFile
and truncateTestData
.
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;
// convenience function to read JSON doc from a file
String readJSONFromAFile(String filePath) throws IOException {
StringBuilder contentBuilder = new StringBuilder();
Stream<String> stream = Files.lines(Paths.get(filePath), StandardCharsets.UTF_8);
stream.forEach(s -> contentBuilder.append(s).append("\n"));
return contentBuilder.toString();
}
import com.aerospike.client.AerospikeException;
// convenience function to truncate test data
void truncateTestData() {
try {
aerospikeClient.truncate(null, NAMESPACE, SET, null);
}
catch (AerospikeException e) {
// ignore
}
}
The Aerospike Document API provides CRUD operations at arbitrary points within a JSON document as described in this blog post.
The document API is as represented in the interface IAerospikeDocumentClient, which is shown below for convenience. The API is fairly simple and has get
, put
, append
, and delete
methods, and yet is powerful as it allows a JSONPath argument to specify parts of the document simply and expressively to apply these methods.
public interface IAerospikeDocumentClient { /** * Retrieve the object in the document with key documentKey that is referenced by the JSON path. * * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path to get the reference from. * returns Object referenced by jsonPath. */ Object get(Key documentKey, String documentBinName, String jsonPath) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Retrieve the object in the document with key documentKey that is referenced by the JSON path. * * readPolicy An Aerospike read policy to use for the get() operation. * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path to get the reference from. * returns Object referenced by jsonPath. */ Object get(Policy readPolicy, Key documentKey, String documentBinName, String jsonPath) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Put a document. * * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonObject A JSON object to put. */ void put(Key documentKey, String documentBinName, JsonNode jsonObject); /** * Put a document. * * writePolicy An Aerospike write policy to use for the put() operation. * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonObject A JSON object to put. */ void put(WritePolicy writePolicy, Key documentKey, String documentBinName, JsonNode jsonObject); /** * Put a map representation of a JSON object at a particular path in a JSON document. * * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path to put the given JSON object in. * jsonObject A JSON object to put in the given JSON path. */ void put(Key documentKey, String documentBinName, String jsonPath, Object jsonObject) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Put a map representation of a JSON object at a particular path in a JSON document. * * writePolicy An Aerospike write policy to use for the put() and operate() operations. * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path to put the given JSON object in. * jsonObject A JSON object to put in the given JSON path. */ void put(WritePolicy writePolicy, Key documentKey, String documentBinName, String jsonPath, Object jsonObject) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Append an object to a list in a document specified by a JSON path. * * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path that includes a list to append the given JSON object to. * jsonObject A JSON object to append to the list at the given JSON path. */ void append(Key documentKey, String documentBinName, String jsonPath, Object jsonObject) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Append an object to a list in a document specified by a JSON path. * * writePolicy An Aerospike write policy to use for the operate() operation. * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path that includes a list to append the given JSON object to. * jsonObject A JSON object to append to the list at the given JSON path. */ void append(WritePolicy writePolicy, Key documentKey, String documentBinName, String jsonPath, Object jsonObject) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Delete an object in a document specified by a JSON path. * * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path for the object deletion. */ void delete(Key documentKey, String documentBinName, String jsonPath) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException; /** * Delete an object in a document specified by a JSON path. * * writePolicy An Aerospike write policy to use for the operate() operation. * documentKey An Aerospike Key. * documentBinName The bin name that will store the json. * jsonPath A JSON path for the object deletion. */ void delete(WritePolicy writePolicy, Key documentKey, String documentBinName, String jsonPath) throws JsonPathParser.JsonParseException, DocumentApiException, JsonProcessingException;
The code examples from the blog post Aerospike Document API are shown below.
The example JSON document used is stored in file doc_api_example_tommyleejones.json
, and has this json:
{ "forenames": [ "Tommy", "Lee" ], "surname": "Jones", "date_of_birth": { "day": 15, "month": 9, "year": 1946 }, "selected_filmography":{ "2012":["Lincoln","Men In Black 3"], "2007":["No Country For Old Men"], "2002":["Men in Black 2"], "1997":["Men in Black","Volcano"], "1994":["Natural Born Killers","Cobb"], "1991":["JFK"], "1980":["Coal Miner's Daughter","Barn Burning"] }, "imdb_rank":{ "source":"https://www.imdb.com/list/ls050274118/", "rank":51 }, "best_films_ranked": [ { "source": "http://www.rottentomatoes.com", "films": ["The Fugitive","No Country For Old Men","Men In Black","Coal Miner's Daughter","Lincoln"] }, { "source":"https://medium.com/the-greatest-films-according-to-me/10-greatest-films-of-tommy-lee-jones-97426103e3d6", "films":["The Three Burials of Melquiades Estrada","The Homesman","No Country for Old Men","In the Valley of Elah","Coal Miner's Daughter"] } ] }
Create a document client using an Aerospike client.
import com.aerospike.client.AerospikeClient;
import com.aerospike.documentapi.*;
final String NAMESPACE = "test";
final String SET = "document-api";
AerospikeClient aerospikeClient = new AerospikeClient("localhost", 3000);
System.out.println("Initialized Aerospike client and connected to the cluster.");
AerospikeDocumentClient documentClient = new AerospikeDocumentClient(aerospikeClient);
System.out.println("Initialized document client from the Aerospike client.");;
Initialized Aerospike client and connected to the cluster. Initialized document client from the Aerospike client.
Using the convenience function readJSONFromAFile
defined above, read a json file.
import com.fasterxml.jackson.databind.JsonNode;
import com.aerospike.documentapi.JsonConverters;
// Read the json document into a string.
String jsonString = readJSONFromAFile("doc_api_example_tommyleejones.json");
System.out.println("Read JSON doc from file.");
// Convert JSON string to a JsonNode
JsonNode jsonNode = JsonConverters.convertStringToJsonNode(jsonString);
System.out.format("JSON doc: %s\n", jsonNode);;
Read JSON doc from file. JSON doc: {"forenames":["Tommy","Lee"],"surname":"Jones","date_of_birth":{"day":15,"month":9,"year":1946},"selected_filmography":{"2012":["Lincoln","Men In Black 3"],"2007":["No Country For Old Men"],"2002":["Men in Black 2"],"1997":["Men in Black","Volcano"],"1994":["Natural Born Killers","Cobb"],"1991":["JFK"],"1980":["Coal Miner's Daughter","Barn Burning"]},"imdb_rank":{"source":"https://www.imdb.com/list/ls050274118/","rank":51},"best_films_ranked":[{"source":"http://www.rottentomatoes.com","films":["The Fugitive","No Country For Old Men","Men In Black","Coal Miner's Daughter","Lincoln"]},{"source":"https://medium.com/the-greatest-films-according-to-me/10-greatest-films-of-tommy-lee-jones-97426103e3d6","films":["The Three Burials of Melquiades Estrada","The Homesman","No Country for Old Men","In the Valley of Elah","Coal Miner's Daughter"]}]}
import com.aerospike.client.Key;
import com.jayway.jsonpath.JsonPath;
// Construct a key
Key tommyLeeJonesDBKey = new Key(NAMESPACE, SET, "tommy-lee-jones.json");
// Add the document to database
String documentBinName = "documentBin";
documentClient.put(tommyLeeJonesDBKey, documentBinName, jsonNode);
System.out.println("Stored JSON doc in database.");
Stored JSON doc in database.
// indexed array elements
documentClient.get(tommyLeeJonesDBKey, documentBinName, "$.best_films_ranked[0].films[0]" );
The Fugitive
// complex component denoted by a path
documentClient.get(tommyLeeJonesDBKey, documentBinName, "$.selected_filmography.1980");
[Coal Miner's Daughter, Barn Burning]
// add year 2019 and films
List<String> _2019Films = new Vector<String>();
_2019Films.add("Ad Astra");
documentClient.put(tommyLeeJonesDBKey, documentBinName, "$.selected_filmography.2019", _2019Films);
// read the update
documentClient.get(tommyLeeJonesDBKey, documentBinName, "$.selected_filmography.2019" );
[Ad Astra]
// update the imdb rank
documentClient.put(tommyLeeJonesDBKey, documentBinName, "$.imdb_rank.rank", 45);
// read the update
documentClient.get(tommyLeeJonesDBKey, documentBinName, "$.imdb_rank.rank" );
45
// append films to best_films_ranked
documentClient.append(tommyLeeJonesDBKey, documentBinName, "$.best_films_ranked[0].films", "Rolling Thunder");
documentClient.append(tommyLeeJonesDBKey, documentBinName, "$.best_films_ranked[0].films", "The Three Burials");
// read the updates
documentClient.get(tommyLeeJonesDBKey, documentBinName, "$.best_films_ranked[0].films" );
[The Fugitive, No Country For Old Men, Men In Black, Coal Miner's Daughter, Lincoln, Rolling Thunder, The Three Burials]
// print state before deletion
Object docObject = documentClient.get(tommyLeeJonesDBKey, documentBinName, "$");
System.out.format("Before delete: \n%s\n", docObject);
// delete all descendants of the document root
documentClient.delete(tommyLeeJonesDBKey, documentBinName, "$..*");
// print state after deletion
docObject = documentClient.get(tommyLeeJonesDBKey, documentBinName, "$");
System.out.format("After delete: \n%s\n", docObject);;
Before delete: {imdb_rank={rank=45, source=https://www.imdb.com/list/ls050274118/}, forenames=[Tommy, Lee], surname=Jones, date_of_birth={month=9, day=15, year=1946}, selected_filmography={1997=[Men in Black, Volcano], 2019=[Ad Astra], 2007=[No Country For Old Men], 1994=[Natural Born Killers, Cobb], 2002=[Men in Black 2], 1991=[JFK], 1980=[Coal Miner's Daughter, Barn Burning], 2012=[Lincoln, Men In Black 3]}, best_films_ranked=[{films=[The Fugitive, No Country For Old Men, Men In Black, Coal Miner's Daughter, Lincoln, Rolling Thunder, The Three Burials], source=http://www.rottentomatoes.com}, {films=[The Three Burials of Melquiades Estrada, The Homesman, No Country for Old Men, In the Valley of Elah, Coal Miner's Daughter], source=https://medium.com/the-greatest-films-according-to-me/10-greatest-films-of-tommy-lee-jones-97426103e3d6}]} After delete: {}
Please refer to this introduction to JSONPath: JSONPath, XPATH for JSON.
The following table summarizes its syntax.
JSONPath | Description |
---|---|
$ | the root object/element |
@ | the current object/element |
. or [] | child operator |
.. | recursive descent |
* | wildcard. All objects/elements regardless their names |
[] | subscript operator in array |
[,] | alternate names or array indices as a set |
[start:end:step] | array slice operator |
[?( |
boolean filter expression |
( |
script expression |
The following table summarizes its key uses.
JSONPath | Result |
---|---|
$.store.book[*].author | the authors of all books in the store |
$..author | all authors |
$.store.* | all things in store, which are some books and a red bicycle |
$.store..price | the price of everything in the store |
$..book[2] | the third book |
$..book[(@.length-1)] $..book[-1:] | the last book in order $..book[0,1] $..book[:2] | the first two books $..book[?(@.isbn)] | filter all books with isbn number $..book[?(@.price<10)] | filter all books cheaper than 10 $..* | all members of JSON structure $..book.length() | the number of books
Below are the code examples from the blog post Aerospike Document API: JSONPath Queries.
The example JSON document it uses is stored in file doc_api_example_store.json
, and has this json:
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95, "ref": [1,2] }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99, "ref": [2,4,16] }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99, "ref": [1,3,5] }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99, "ref": [1,2,7] } ], "bicycle": { "color": "red", "price": 19.95 } }, "expensive": 10 }
String jsonString = readJSONFromAFile("doc_api_example_store.json");
System.out.println("Read JSON doc from file.");
Read JSON doc from file.
// Store the JSON doc in the database and read it back.
import com.aerospike.client.Key;
import com.aerospike.documentapi.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.jayway.jsonpath.JsonPath;
// Create a document client via an existing aerospikeClient
AerospikeDocumentClient documentClient = new AerospikeDocumentClient(aerospikeClient);
// Convert JSON string to a JsonNode
JsonNode jsonNode = JsonConverters.convertStringToJsonNode(jsonString);
System.out.println(jsonNode);
// Construct an appropriate key
Key documentKey = new Key(NAMESPACE, SET, "jsonExampleKey");
String documentBinName = "documentBin";
// Add to database
documentClient.put(documentKey, documentBinName, jsonNode);
System.out.println("Stored JSON doc to database.");
{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95,"ref":[1,2]},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99,"ref":[2,4,16]},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99,"ref":[1,3,5]},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99,"ref":[1,2,7]}],"bicycle":{"color":"red","price":19.95}},"expensive":10} Stored JSON doc to database.
// Get all products, both books and bicycles
String jsonPath = "$.store.*";
Object objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.println(objectFromDB);
{bicycle={color=red, price=19.95}, book=[{ref=[1, 2], category=reference, title=Sayings of the Century, author=Nigel Rees, price=8.95}, {ref=[2, 4, 16], category=fiction, title=Sword of Honour, author=Evelyn Waugh, price=12.99}, {ref=[1, 3, 5], category=fiction, title=Moby Dick, author=Herman Melville, price=8.99, isbn=0-553-21311-3}, {ref=[1, 2, 7], category=fiction, title=The Lord of the Rings, author=J. R. R. Tolkien, price=22.99, isbn=0-395-19395-8}]}
// Get the authors of all books
String jsonPath = "$.store.book[*].author";
Object objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.println(objectFromDB);
["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"]
// 3. Modify the authors of all books to “J.K. Rowling”
// Get the authors of all books
String jsonPath = "$.store.book[*].author";
String jsonObject = "J.K. Rowling";
// Modify the authors of all books to "J.K. Rowling"
documentClient.put(documentKey, documentBinName, jsonPath, jsonObject);
Object objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.println(objectFromDB);
["J.K. Rowling","J.K. Rowling","J.K. Rowling","J.K. Rowling"]
// 4. Get all the books that have an ISBN number
jsonPath = "$..book[?(@.isbn)]";
objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.println(objectFromDB);
[{"ref":[1,3,5],"category":"fiction","title":"Moby Dick","author":"J.K. Rowling","price":8.99,"isbn":"0-553-21311-3"},{"ref":[1,2,7],"category":"fiction","title":"The Lord of the Rings","author":"J.K. Rowling","price":22.99,"isbn":"0-395-19395-8"}]
// 5. Get all the books in store cheaper than 10
jsonPath = "$.store.book[?(@.price < 10)]";
objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.println(objectFromDB);
[{"ref":[1,2],"category":"reference","title":"Sayings of the Century","author":"J.K. Rowling","price":8.95},{"ref":[1,3,5],"category":"fiction","title":"Moby Dick","author":"J.K. Rowling","price":8.99,"isbn":"0-553-21311-3"}]
// 6. Get all the books matching regex (ignore case)
jsonPath = "$..book[?(@.author =~ /.*ROWLING/i)]";
objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.println(objectFromDB);
[{"ref":[1,2],"category":"reference","title":"Sayings of the Century","author":"J.K. Rowling","price":8.95},{"ref":[2,4,16],"category":"fiction","title":"Sword of Honour","author":"J.K. Rowling","price":12.99},{"ref":[1,3,5],"category":"fiction","title":"Moby Dick","author":"J.K. Rowling","price":8.99,"isbn":"0-553-21311-3"},{"ref":[1,2,7],"category":"fiction","title":"The Lord of the Rings","author":"J.K. Rowling","price":22.99,"isbn":"0-395-19395-8"}]
// 7. Delete the price field of every object exists in store
// Get the price of everything
String jsonPath = "$.store..price";
Object objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.format("Before delete: %s\n", objectFromDB);
// Delete the price field of every object exists in the store
documentClient.delete(documentKey, documentBinName, jsonPath);
Object objectFromDB = documentClient.get(documentKey, documentBinName, jsonPath);
System.out.format("After delete: %s\n", objectFromDB);;
Before delete: [19.95,8.95,12.99,8.99,22.99] After delete: []
Restore the original store
document for the following examples.
documentClient.put(documentKey, documentBinName, jsonNode);
documentClient.get(documentKey, documentBinName, "$");
{store={bicycle={color=red, price=19.95}, book=[{ref=[1, 2], category=reference, title=Sayings of the Century, author=Nigel Rees, price=8.95}, {ref=[2, 4, 16], category=fiction, title=Sword of Honour, author=Evelyn Waugh, price=12.99}, {ref=[1, 3, 5], category=fiction, title=Moby Dick, author=Herman Melville, price=8.99, isbn=0-553-21311-3}, {ref=[1, 2, 7], category=fiction, title=The Lord of the Rings, author=J. R. R. Tolkien, price=22.99, isbn=0-395-19395-8}]}, expensive=10}
JSONPath has functions min
, sum
, size
, length
, etc. See the JSONPath repo for a full list.
// length(): find number of references to Moby Dick
jsonPath = "$..store.book[?(@.title == 'Moby Dick')].ref.length()";
documentClient.get(documentKey, documentBinName, jsonPath );
3
// avg(): find average price of books
jsonPath = "$..book..price.avg()";
documentClient.get(documentKey, documentBinName, jsonPath );
13.48
Operators like in
and anyof
are supported. See the JSONPath repo for a full list.
// in: books with category in ['reference', 'biography']
jsonPath = "$..book[?(@.category in ['reference', 'biography'])]";
documentClient.get(documentKey, documentBinName, jsonPath );
[{"ref":[1,2],"category":"reference","title":"Sayings of the Century","author":"Nigel Rees","price":8.95}]
// in: books that have 2 in their reference list
jsonPath = "$..book[?(2 in @.ref)]";
documentClient.get(documentKey, documentBinName, jsonPath );
[{"ref":[1,2],"category":"reference","title":"Sayings of the Century","author":"Nigel Rees","price":8.95},{"ref":[2,4,16],"category":"fiction","title":"Sword of Honour","author":"Evelyn Waugh","price":12.99},{"ref":[1,2,7],"category":"fiction","title":"The Lord of the Rings","author":"J. R. R. Tolkien","price":22.99,"isbn":"0-395-19395-8"}]
// anyof: books whose ref list has any of 1, 3, 7, or 100.
jsonPath = "$..book[?(@.ref anyof [1, 3, 7, 100])]";
documentClient.get(documentKey, documentBinName, jsonPath );
[{"ref":[1,2],"category":"reference","title":"Sayings of the Century","author":"Nigel Rees","price":8.95},{"ref":[1,3,5],"category":"fiction","title":"Moby Dick","author":"Herman Melville","price":8.99,"isbn":"0-553-21311-3"},{"ref":[1,2,7],"category":"fiction","title":"The Lord of the Rings","author":"J. R. R. Tolkien","price":22.99,"isbn":"0-395-19395-8"}]
// books with price between 10 and 20
jsonPath = "$..book[?(@.price > 10 && @.price < 20)]";
documentClient.get(documentKey, documentBinName, jsonPath );
[{"ref":[2,4,16],"category":"fiction","title":"Sword of Honour","author":"Evelyn Waugh","price":12.99}]
// comparing with another element
jsonPath = "$..book[?(@.price < $.expensive)]";
documentClient.get(documentKey, documentBinName, jsonPath );
[{"ref":[1,2],"category":"reference","title":"Sayings of the Century","author":"Nigel Rees","price":8.95},{"ref":[1,3,5],"category":"fiction","title":"Moby Dick","author":"Herman Melville","price":8.99,"isbn":"0-553-21311-3"}]
// composable conditions: books in fiction category with isbn and priced less than 10
jsonPath = "$..book[?(@.category == 'fiction' && @.isbn && @.price < 10 )]";
documentClient.get(documentKey, documentBinName, jsonPath );
[{"ref":[1,3,5],"category":"fiction","title":"Moby Dick","author":"Herman Melville","price":8.99,"isbn":"0-553-21311-3"}]
// substitute your json path
jsonPath = "$";
documentClient.get(documentKey, documentBinName, jsonPath );
{store={bicycle={color=red, price=19.95}, book=[{ref=[1, 2], category=reference, title=Sayings of the Century, author=Nigel Rees, price=8.95}, {ref=[2, 4, 16], category=fiction, title=Sword of Honour, author=Evelyn Waugh, price=12.99}, {ref=[1, 3, 5], category=fiction, title=Moby Dick, author=Herman Melville, price=8.99, isbn=0-553-21311-3}, {ref=[1, 2, 7], category=fiction, title=The Lord of the Rings, author=J. R. R. Tolkien, price=22.99, isbn=0-395-19395-8}]}, expensive=10}
Remove tutorial data and close connection.
truncateTestData();
aerospikeClient.close();
System.out.println("Removed tutorial data and closed server connection.");
Removed tutorial data and closed server connection.
Visit Aerospike notebooks repo to run additional Aerospike notebooks. To run a different notebook, download the notebook from the repo to your local machine, and then click on File->Open in the notebook menu, and select Upload.