-
Notifications
You must be signed in to change notification settings - Fork 0
/
text
280 lines (280 loc) · 73.6 KB
/
text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
Pandoc (Meta {unMeta = fromList [("id",MetaString "expressions"),("jupyter",MetaMap (fromList [("kernelspec",MetaMap (fromList [("display_name",MetaString "Java"),("language",MetaString "java"),("name",MetaString "java")])),("language_info",MetaMap (fromList [("codemirror_mode",MetaString "java"),("file_extension",MetaString ".jshell"),("mimetype",MetaString "text/x-java-source"),("name",MetaString "Java"),("pygments_lexer",MetaString "java"),("version",MetaString "11.0.8+10-LTS")])),("nbformat",MetaString "4"),("nbformat_minor",MetaString "4"),("toc",MetaMap (fromList [("base_numbering",MetaString "1"),("nav_menu",MetaMap (fromList [])),("number_sections",MetaBool True),("sideBar",MetaBool True),("skip_h1_title",MetaBool False),("title_cell",MetaString "Table of Contents"),("title_sidebar",MetaString "Contents"),("toc_cell",MetaBool True),("toc_position",MetaMap (fromList [])),("toc_section_display",MetaBool True),("toc_window_display",MetaBool False)]))])),("title",MetaString "Expressions in Aerospike")]})
[Header 1 ("understanding-expressions-in-aerospike",[],[]) [Str "Understanding",Space,Str "Expressions",Space,Str "in",Space,Str "Aerospike"]
,Para [Str "This",Space,Str "notebook",Space,Str "describes",Space,Str "how",Space,Str "expressions",Space,Str "work",Space,Str "in",Space,Str "Aerospike:",Space,Str "how",Space,Str "they",Space,Str "are",Space,Str "formed,",Space,Str "their",Space,Str "syntax,",Space,Str "benefits,",Space,Str "and",Space,Str "how",Space,Str "they",Space,Str "are",Space,Str "used",Space,Str "in",Space,Str "filters",Space,Str "and",Space,Str "operations."]
,Para [Str "This",Space,Str "notebook",Space,Str "requires",Space,Str "Aerospike",Space,Str "database",Space,Str "running",Space,Str "on",Space,Str "localhost.",Space,Str "Visit",Space,Link ("",[],[]) [Str "Aerospike",Space,Str "notebooks",Space,Str "repo"] ("https://github.com/aerospike-examples/interactive-notebooks",""),Space,Str "for",Space,Str "additional",Space,Str "details",Space,Str "and",Space,Str "the",Space,Str "docker",Space,Str "container."]
,Header 2 ("introduction",[],[]) [Str "Introduction"]
,Para [Str "In",Space,Str "this",Space,Str "notebook,",Space,Str "we",Space,Str "will",Space,Str "see",Space,Str "how",Space,Str "expressions",Space,Str "work",Space,Str "in",Space,Str "Aerospike",Space,Str "and",Space,Str "benefits",Space,Str "they",Space,Str "provide."]
,Para [Str "The",Space,Str "expressions",Space,Str "functionality",Space,Str "has",Space,Str "been",Space,Str "enhanced",Space,Str "in",Space,Str "Aerospike",Space,Str "Database",Space,Str "5.6.",Space,Str "Expressions",Space,Str "appear",Space,Str "in",Space,Str "two",Space,Str "flavors",Space,Str "in",Space,Str "the",Space,Str "client",Space,Str "library:",Space,Str "Filter",Space,Str "Expressions",Space,Str "and",Space,Str "Operation",Space,Str "Expressions.",Space,Str "Filter",Space,Str "Expressions",Space,Str "provide",Space,Str "a",Space,Str "mechanism",Space,Str "to",Space,Str "select",Space,Str "records",Space,Str "for",Space,Str "operations",Space,Str "and",Space,Str "replace",Space,Str "Predicate",Space,Str "Expressions,",Space,Str "which",Space,Str "have",Space,Str "been",Space,Str "deprecated",Space,Str "since",Space,Str "the",Space,Str "5.2",Space,Str "release.",Space,Str "Operation",Space,Str "Expressions",Space,Str "enable",Space,Str "new",Space,Str "read",Space,Str "and",Space,Str "write",Space,Str "capabilities",Space,Str "as",Space,Str "described",Space,Str "later.",Space,Str "Expressions",Space,Str "are",Space,Str "also",Space,Str "used",Space,Str "on",Space,Str "server",Space,Str "as",Space,Str "XDR",Space,Str "Filter",Space,Str "Expressions",Space,Str "to",Space,Str "specify",Space,Str "which",Space,Str "records",Space,Str "are",Space,Str "shipped",Space,Str "to",Space,Str "remote",Space,Str "destinations."]
,Para [Str "We",Space,Str "will",Space,Str "describe",Space,Str "at",Space,Str "a",Space,Str "high",Space,Str "level",Space,Str "how",Space,Str "expressions",Space,Str "are",Space,Str "formed",Space,Str "in",Space,Str "Aerospike",Space,Str "and",Space,Str "the",Space,Str "capabilities",Space,Str "they",Space,Str "enable.",Space,Str "After",Space,Str "highlighting",Space,Str "key",Space,Str "syntax",Space,Str "patterns,",Space,Str "we",Space,Str "will",Space,Str "show",Space,Str "with",Space,Str "specific",Space,Str "code",Space,Str "examples",Space,Str "how",Space,Str "expressions",Space,Str "are",Space,Str "used."]
,Para [Str "The",Space,Str "main",Space,Str "topics",Space,Str "in",Space,Str "this",Space,Str "notebook",Space,Str "include:"]
,BulletList
[[Plain [Str "scope",Space,Str "of",Space,Str "expressions"]]
,[Plain [Str "benefits"]]
,[Plain [Str "syntax"]]
,[Plain [Str "usage"]]
,[Plain [Str "coding",Space,Str "examples"]]]
,Header 2 ("prerequisites",[],[]) [Str "Prerequisites"]
,Para [Str "This",Space,Str "tutorial",Space,Str "assumes",Space,Str "familiarity",Space,Str "with",Space,Str "the",Space,Str "following",Space,Str "topics:"]
,BulletList
[[Plain [Link ("",[],[]) [Str "Aerospike",Space,Str "Notebooks",Space,Str "-",Space,Str "Readme",Space,Str "and",Space,Str "Tips"] ("../readme_tips.ipynb","")]]
,[Plain [Link ("",[],[]) [Str "Hello",Space,Str "World"] ("hello_world.ipynb","")]]
,[Plain [Link ("",[],[]) [Str "Introduction",Space,Str "to",Space,Str "Data",Space,Str "Modeling"] ("java-intro_to_data_modeling.ipynb","")]]]
,Header 2 ("setup",[],[]) [Str "Setup"]
,Header 3 ("ensure-database-is-running",[],[]) [Str "Ensure",Space,Str "Database",Space,Str "is",Space,Str "Running"]
,Para [Str "This",Space,Str "notebook",Space,Str "requires",Space,Str "that",Space,Str "Aerospike",Space,Str "database",Space,Str "is",Space,Str "running."]
,CodeBlock ("",["java"],[]) "import io.github.spencerpark.ijava.IJava;\nimport io.github.spencerpark.jupyter.kernel.magic.common.Shell;\nIJava.getKernelInstance().getMagics().registerMagics(Shell.class);\n%sh asd"
,Header 3 ("download-and-install-additional-components",[],[]) [Str "Download",Space,Str "and",Space,Str "Install",Space,Str "Additional",Space,Str "Components."]
,Para [Str "Install",Space,Str "the",Space,Str "Aerospike",Space,Str "Java",Space,Str "client",Space,Str "version",Space,Str "5.1.3",Space,Str "(or",Space,Str "higher)",Space,Str "that",Space,Str "has",Space,Str "the",Space,Str "support",Space,Str "for",Space,Str "expressions."]
,CodeBlock ("",["java"],[]) "%%loadFromPOM\n<dependencies>\n <dependency>\n <groupId>com.aerospike</groupId>\n <artifactId>aerospike-client</artifactId>\n <version>5.1.3</version>\n </dependency>\n</dependencies>"
,Header 3 ("initialize-client",[],[]) [Str "Initialize",Space,Str "Client"]
,Para [Str "Initialize",Space,Str "the",Space,Str "client.",Space,Str "Also,",Space,Str "define",Space,Str "constants",Space,Str "including",Space,Str "the",Space,Str "namespace",Space,Code ("",[],[]) "test",Space,Str "and",Space,Str "set",Space,Code ("",[],[]) "expressions",Space,Str "and",Space,Str "a",Space,Str "convenient",Space,Str "function",Space,Code ("",[],[]) "truncateTestData",Str "."]
,CodeBlock ("",["java"],[]) "import com.aerospike.client.AerospikeClient;\n\nAerospikeClient client = new AerospikeClient(\"localhost\", 3000);\nSystem.out.println(\"Initialized the client and connected to the cluster.\");\n\nfinal String Namespace = \"test\";\nfinal String Set = \"expressions\";\n\n// convenience functions to truncate test data\nvoid truncateTestData() {\n try {\n client.truncate(null, Namespace, Set, null);\n }\n catch (AerospikeException e) {\n // ignore\n }\n}"
,BlockQuote
[CodeBlock ("",[],[]) "Initialized the client and connected to the cluster.\n"]
,Header 3 ("access-shell-commands",[],[]) [Str "Access",Space,Str "Shell",Space,Str "Commands"]
,Para [Str "You",Space,Str "may",Space,Str "execute",Space,Str "shell",Space,Str "commands",Space,Str "including",Space,Str "Aerospike",Space,Str "tools",Space,Str "like",Space,Link ("",[],[]) [Str "aql"] ("https://docs.aerospike.com/docs/tools/aql/index.html",""),Space,Str "and",Space,Link ("",[],[]) [Str "asadm"] ("https://docs.aerospike.com/docs/tools/asadm/index.html",""),Space,Str "in",Space,Str "the",Space,Str "terminal",Space,Str "tab",Space,Str "throughout",Space,Str "this",Space,Str "tutorial.",Space,Str "Open",Space,Str "a",Space,Str "terminal",Space,Str "tab",Space,Str "by",Space,Str "selecting",Space,Str "File->Open",Space,Str "from",Space,Str "the",Space,Str "notebook",Space,Str "menu,",Space,Str "and",Space,Str "then",Space,Str "New->Terminal."]
,Header 1 ("defining-expressions",[],[]) [Str "Defining",Space,Str "Expressions"]
,Para [Emph [Str "An",Space,Str "expression",Space,Str "is",Space,Str "a",Space,Str "syntactic",Space,Str "entity",Space,Str "in",Space,Str "a",Space,Str "programming",Space,Str "language",Space,Str "that",Space,Str "may",Space,Str "be",Space,Str "evaluated",Space,Str "to",Space,Str "determine",Space,Str "its",Space,Str "value."],Str "[(Wikipedia)](",Link ("",["uri"],[]) [Str "https://en.wikipedia.org/wiki/Expression_(computer_science\\)"] ("https://en.wikipedia.org/wiki/Expression_(computer_science\\)",""),Str ")"]
,Para [Str "In",Space,Str "other",Space,Str "words,",Space,Str "an",Space,Str "expression",Space,Str "evaluates",Space,Str "to",Space,Str "(or",Space,Str "returns)",Space,Str "a",Space,Str "value.",Space,Str "Some",Space,Str "simple",Space,Str "examples",Space,Str "of",Space,Str "an",Space,Str "expression",Space,Str "would",Space,Str "be:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "5",SoftBreak,Str "7",Space,Str "+",Space,Str "3",SoftBreak,Str "2",Space,Str ">",Space,Str "1",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Para [Str "Expressions",Space,Str "can",Space,Str "have:"]
,BulletList
[[Plain [Str "constants:",Space,RawInline (Format "markdown") "\n```\n",Str "5,",Space,Str "\8220horse\8221,",Space,Str "[1,",Space,Str "2,",Space,Str "3]",RawInline (Format "markdown") "\n```\n"]]
,[Plain [Str "variables:",Space,RawInline (Format "markdown") "\n```\n",Str "var",Space,Str "x",Space,Str "=",Space,Str "pow(b,",Space,Str "c)",Space,Str "+",Space,Str "d",RawInline (Format "markdown") "\n```\n"]]
,[Plain [Str "functions:",Space,RawInline (Format "markdown") "\n```\n",Str "pow,",Space,Str "mod,",Space,Str "min",RawInline (Format "markdown") "\n```\n"]]
,[Plain [Str "and",Space,Str "operators:",Space,RawInline (Format "markdown") "\n```\n",Str "==,",Space,Str "+,",Space,Str "or",RawInline (Format "markdown") "\n```\n"]]]
,Para [Str "Expressions",Space,Str "are",Space,Str "composable.",Space,Str "In",Space,Str "other",Space,Str "words,",Space,Str "complex",Space,Str "expressions",Space,Str "can",Space,Str "be",Space,Str "formed",Space,Str "from",Space,Str "simpler",Space,Str "expressions.",Space,Str "For",Space,Str "example:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "1",Space,Str "+",Space,Str "min(2,",Space,Str "a",Space,Str "+",Space,Str "2)",Space,Str "<",Space,Str "sqrt(b)",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Para [Str "An",Space,Str "expression",Space,Str "is",Space,Str "not",Space,Str "an",Space,Str "assignment:",Space,Str "An",Space,Str "expression",Space,Str "does",Space,Str "not",Space,Str "assign",Space,Str "a",Space,Str "value",Space,Str "to",Space,Str "a",Space,Str "variable,",Space,Str "but",Space,Str "simply",Space,Str "evaluates",Space,Str "to",Space,Str "a",Space,Str "value",Space,Str "which",Space,Str "may",Space,Str "be",Space,Str "used",Space,Str "in",Space,Str "an",Space,Str "assignment",Space,Str "statement",Space,Str "that",Space,Str "assigns",Space,Str "the",Space,Str "value",Space,Str "to",Space,Str "a",Space,Str "variable."]
,Header 1 ("expressions-in-aerospike",[],[]) [Str "Expressions",Space,Str "in",Space,Str "Aerospike"]
,Para [Str "This",Space,Str "section",Space,Str "provides",Space,Str "a",Space,Str "higher",Space,Str "level",Space,Str "view",Space,Str "of",Space,Str "the",Space,Str "capabilities",Space,Str "and",Space,Str "workings",Space,Str "of",Space,Str "expressions",Space,Str "in",Space,Str "Aerospike.",Space,Str "The",Space,Str "subsequent",Space,Str "sections",Space,Str "will",Space,Str "drill",Space,Str "down",Space,Str "into",Space,Str "the",Space,Str "details."]
,Header 2 ("evaluation-context",[],[]) [Str "Evaluation",Space,Str "Context"]
,Para [Str "Expressions",Space,Str "are",Space,Str "evaluated",Space,Str "on",Space,Str "server",Space,Str "for",Space,Str "filtering",Space,Str "conditions,",Space,Str "reading",Space,Str "and",Space,Str "writing",Space,Str "to",Space,Str "bins,",Space,Str "and",Space,Str "configuring",Space,Str "XDR",Space,Str "replication.",Space,Str "Therefore,",Space,Str "an",Space,Str "expression",Space,Str "only",Space,Str "works",Space,Str "on",Space,Str "server",Space,Str "data",Space,Str "entities",Space,Str "such",Space,Str "as",Space,Str "the",Space,Str "metadata",Space,Str "and",Space,Str "record",Space,Str "data,",Space,Str "and",Space,Str "uses",Space,Str "any",Space,Str "constants",Space,Str "that",Space,Str "the",Space,Str "client",Space,Str "may",Space,Str "provide.",Space,Str "When",Space,Str "used",Space,Str "from",Space,Str "the",Space,Str "client",Space,Str "library,",Space,Str "expressions",Space,Str "are",Space,Str "created",Space,Str "on",Space,Str "the",Space,Str "client",Space,Str "and",Space,Str "sent",Space,Str "to",Space,Str "the",Space,Str "server",Space,Str "in",Space,Str "an",Space,Str "API",Space,Str "operation.",Space,Str "Before",Space,Str "sending,",Space,Str "the",Space,Str "client",Space,Str "object",Space,Str "format",Space,Str "of",Space,Str "an",Space,Str "expression",Space,Str "is",Space,Str "converted",Space,Str "to",Space,Str "a",Space,Str "wire",Space,Str "format",Space,Str "using",Space,Str "the",Space,Code ("",[],[]) "build",Space,Str "operation."]
,Header 2 ("components-and-scope",[],[]) [Str "Components",Space,Str "and",Space,Str "Scope"]
,Para [Emph [Str "An",Space,Str "expression",Space,Str "is",Space,Str "a",Space,Str "combination",Space,Str "of",Space,Str "one",Space,Str "or",Space,Str "more",Space,Str "constants,",Space,Str "variables,",Space,Str "functions,",Space,Str "and",Space,Str "operators",Space,Str "that",Space,Str "the",Space,Str "programming",Space,Str "language",Space,Str "interprets",Space,Str "...",Space,Str "and",Space,Str "computes",Space,Str "to",Space,Str "produce",Space,Str "another",Space,Str "value."],Space,Str "[(Wikipedia)](",Link ("",["uri"],[]) [Str "https://en.wikipedia.org/wiki/Expression_(computer_science\\)"] ("https://en.wikipedia.org/wiki/Expression_(computer_science\\)",""),Str ")"]
,Para [Str "In",Space,Str "Aerospike,",Space,Str "expressions",Space,Str "use",Space,Str "bins",Space,Str "and",Space,Str "metadata",Space,Str "as",Space,Str "variables,",Space,Str "metadata",Space,Str "and",Space,Str "API",Space,Str "functions,",Space,Str "and",Space,Str "values",Space,Str "that",Space,Str "ae",Space,Str "strongly",Space,Str "typed",Space,Str "as",Space,Str "boolean,",Space,Str "integer,",Space,Str "float,",Space,Str "string,",Space,Str "list,",Space,Str "map,",Space,Str "blob,",Space,Str "GeoJSON,",Space,Str "or",Space,Str "HyperLogLog.",Space,Str "A",Space,Str "host",Space,Str "of",Space,Str "arithmetic,",Space,Str "logical,",Space,Str "convenience,",Space,Str "and",Space,Str "API",Space,Str "operations",Space,Str "are",Space,Str "available",Space,Str "for",Space,Str "these",Space,Str "data."]
,Para [Str "Please",Space,Str "refer",Space,Str "to",Space,Str "the",Space,Link ("",[],[]) [Str "documentation"] ("https://docs.aerospike.com/docs/guide/expressions/",""),Space,Str "for",Space,Str "the",Space,Str "list",Space,Str "of",Space,Str "supported",Space,Str "components."]
,Header 2 ("immutability-of-components",[],[]) [Str "Immutability",Space,Str "of",Space,Str "Components"]
,Para [Str "In",Space,Str "Aerospike,",Space,Str "an",Space,Str "expression",Space,Str "works",Space,Str "on",Space,Str "a",Space,Str "transient",Space,Str "copy,",Space,Str "therefore",Space,Str "evauating",Space,Str "an",Space,Str "expression",Space,Str "does",Space,Str "not",Space,Str "change",Space,Str "the",Space,Str "metadata",Space,Str "or",Space,Str "bins",Space,Str "that",Space,Str "are",Space,Str "used",Space,Str "in",Space,Str "the",Space,Str "expression."]
,Header 2 ("use-of-variables",[],[]) [Str "Use",Space,Str "of",Space,Str "Variables"]
,Para [Str "A",Space,Str "variable",Space,Str "can",Space,Str "be",Space,Str "defined",Space,Str "to",Space,Str "represent",Space,Str "a",Space,Str "sub-expression",Space,Str "for",Space,Str "syntactic",Space,Str "clarity",Space,Str "and",Space,Str "efficiency.",Space,Str "A",Space,Str "variable",Space,Str "is",Space,Str "first",Space,Str "defined",Space,Str "and",Space,Str "initialized",Space,Str "by",Space,Str "assigning",Space,Str "it",Space,Str "to",Space,Str "an",Space,Str "expression,",Space,Str "and",Space,Str "then",Space,Str "used",Space,Str "as",Space,Str "a",Space,Str "substitute",Space,Str "for",Space,Str "the",Space,Str "expression.",Space,Str "In",Space,Str "the",Space,Str "example",Space,Str "below,",Space,Str "a",Space,Str "variable",Space,Code ("",[],[]) "myvar",Space,Str "is",Space,Str "defined",Space,Str "and",Space,Str "used",Space,Str "in",Space,Str "an",Space,Str "expression",Space,Code ("",[],[]) "myexpr",Str ":",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "myvar",Space,Str "=",Space,Str "(a",Space,Str "+",Space,Str "b)",Space,Str "/",Space,Str "min(a,",Space,Str "b)",SoftBreak,Str "myexpr",Space,Str "=",Space,Str "myvar",Space,Str "+",Space,Str "1",Space,Str "/",Space,Str "myvar",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Header 2 ("conditional-evaluation",[],[]) [Str "Conditional",Space,Str "Evaluation"]
,Para [Str "An",Space,Str "expression",Space,Str "can",Space,Str "be",Space,Str "condiitonally",Space,Str "evaluated",Space,Str "with",Space,Str "an",Space,Code ("",[],[]) "if-then-else",Space,Str "like",Space,Str "construct.",Space,Str "For",Space,Str "example:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "if",Space,Str "(cond_1)",Space,Str "{",SoftBreak,Str "myexpr",Space,Str "=",Space,Str "expr_1;",SoftBreak,Str "}",SoftBreak,Str "else",Space,Str "if",Space,Str "(cond_2)",Space,Str "{",SoftBreak,Str "myexpr",Space,Str "=",Space,Str "expr_2;",SoftBreak,Str "}",SoftBreak,Str "...",SoftBreak,Str "else",Space,Str "{",SoftBreak,Str "myexpr",Space,Str "=",Space,Str "default;",SoftBreak,Str "}",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Header 2 ("uses-and-types",[],[]) [Str "Uses",Space,Str "and",Space,Str "Types"]
,Para [Str "Expressions",Space,Str "are",Space,Str "used",Space,Str "in:"]
,BulletList
[[Plain [Str "selection",Space,Str "conditions",Space,Str "aka",Space,Str "predicates",Space,Str "(called",Space,Str "Filter",Space,Str "Expressions),"]]
,[Plain [Str "operations",Space,Str "(called",Space,Str "Operation",Space,Str "Expressions),",Space,Str "and"]]
,[Plain [Str "XDR's",Space,Str "shipping",Space,Str "configuration",Space,Str "(called",Space,Str "XDR",Space,Str "Filter",Space,Str "Expressions)."]]]
,Para [Str "The",Space,Str "functionality",Space,Str "of",Space,Str "expressions",Space,Str "is",Space,Str "the",Space,Str "same,",Space,Str "although",Space,Str "the",Space,Str "context",Space,Str "determines",Space,Str "their",Space,Str "use.",Space,Str "For",Space,Str "example,",Space,Str "Filter",Space,Str "and",Space,Str "XDR",Space,Str "Filter",Space,Str "Expressions",Space,Str "are",Space,Str "boolean",Space,Str "expressions,",Space,Str "whereas",Space,Str "Operation",Space,Str "Expressions",Space,Str "can",Space,Str "evaluate",Space,Str "to",Space,Str "any",Space,Str "supported",Space,Str "type."]
,Para [Str "Only",Space,Str "Filter",Space,Str "and",Space,Str "Operation",Space,Str "Expressions",Space,Str "can",Space,Str "be",Space,Str "used",Space,Str "in",Space,Str "the",Space,Str "client",Space,Str "library",Space,Str "and",Space,Str "therefore",Space,Str "will",Space,Str "be",Space,Str "the",Space,Str "focus",Space,Str "of",Space,Str "this",Space,Str "tutorial.",Space,Str "Please",Space,Str "refer",Space,Str "to",Space,Str "the",Space,Link ("",[],[]) [Str "documentation"] ("https://docs.aerospike.com/docs/guide/expressions/#xdr-filter-expressions",""),Space,Str "for",Space,Str "the",Space,Str "details",Space,Str "of",Space,Str "XDR",Space,Str "Filter",Space,Str "Expressions."]
,Header 1 ("benefits-of-expressions",[],[]) [Str "Benefits",Space,Str "of",Space,Str "Expressions"]
,Para [Str "Here",Space,Str "are",Space,Str "some",Space,Str "key",Space,Str "benefits",Space,Str "and",Space,Str "capabilities",Space,Str "that",Space,Str "expressions",Space,Str "enable:"]
,BulletList
[[Para [Str "Capabilities",Space,Str "in",Space,Str "expressions",Space,Str "include:"]
,BulletList
[[Plain [Str "variables",Space,Str "for",Space,Str "syntactic",Space,Str "clarity",Space,Str "and",Space,Str "efficiency,"]]
,[Plain [Str "conditional",Space,Str "evaluation,",LineBreak]]
,[Plain [Str "access",Space,Str "to",Space,Str "metadata",Space,Str "and",Space,Str "bin",Space,Str "data,",Space,Str "and"]]
,[Plain [Str "access",Space,Str "to",Space,Str "powerful",Space,Str "APIs",Space,Str "and",Space,Str "enhanced",Space,Str "set",Space,Str "of",Space,Str "operators."]]]]
,[Para [Str "The",Space,Str "enhanced",Space,Str "filtering",Space,Str "expressions",Space,Str "allow",Space,Str "records",Space,Str "to",Space,Str "be",Space,Str "processed",Space,Str "more",Space,Str "efficiently",Space,Str "by",Space,Str "avoiding",Space,Str "the",Space,Str "need",Space,Str "for",Space,Str "potentially",Space,Str "more",Space,Str "expensive",Space,Str "client",Space,Str "or",Space,Str "UDF",Space,Str "based",Space,Str "processing."]]
,[Para [Str "Reads",Space,Str "and",Space,Str "writes",Space,Str "are",Space,Str "now",Space,Str "possible",Space,Str "with",Space,Str "Operation",Space,Str "Expressions."]
,BulletList
[[Plain [Str "in",Space,Str "reads,",Space,Str "this",Space,Str "can",Space,Str "eliminate",Space,Str "the",Space,Str "need",Space,Str "to",Space,Str "bring",Space,Str "large",Space,Str "amounts",Space,Str "of",Space,Str "data",Space,Str "to",Space,Str "the",Space,Str "client",Space,Str "with",Space,Str "more",Space,Str "precise",Space,Str "ability",Space,Str "to",Space,Str "specify",Space,Str "the",Space,Str "data",Space,Str "to",Space,Str "be",Space,Str "fetched."]]
,[Plain [Str "a",Space,Str "bin",Space,Str "can",Space,Str "be",Space,Str "updated",Space,Str "with",Space,Str "the",Space,Str "results",Space,Str "of",Space,Str "an",Space,Str "expression,",Space,Str "which",Space,Str "can",Space,Str "eliminate",Space,Str "having",Space,Str "to",Space,Str "read",Space,Str "before",Space,Str "update",Space,Str "by",Space,Str "allowing",Space,Str "everything",Space,Str "to",Space,Str "happen",Space,Str "on",Space,Str "the",Space,Str "server",Space,Str "side",Space,Str "in",Space,Str "the",Space,Str "same",Space,Str "request",Space,Str "including",Space,Str "the",Space,Str "read,",Space,Str "processing",Space,Str "for",Space,Str "update,",Space,Str "and",Space,Str "update.",Space,Str "This",Space,Str "saves",Space,Str "a",Space,Str "round-trip",Space,Str "and",Space,Str "transfer",Space,Str "of",Space,Str "potentially",Space,Str "large",Space,Str "data.",Space,Str "In",Space,Str "a",Space,Str "concurrent",Space,Str "setting,",Space,Str "this",Space,Str "also",Space,Str "avoids",Space,Str "retries",Space,Str "due",Space,Str "to",Space,Str "conflicts",Space,Link ("",[],[]) [Str "see",Space,Str "the",Space,Str "R-M-W",Space,Str "pattern"] ("../python/transactions_rmw_pattern.ipynb",""),Str "."]]]]
,[Para [Str "Multi-step",Space,Str "operations",Space,Str "that",Space,Str "can",Space,Str "build",Space,Str "on",Space,Str "each",Space,Str "other\8217s",Space,Str "results",Space,Str "are",Space,Str "now",Space,Str "possible",Space,Str "through",Space,Str "operation",Space,Str "expressions."]]]
,Header 1 ("syntax-details",[],[]) [Str "Syntax",Space,Str "Details"]
,Para [Str "With",Space,Str "a",Space,Str "better",Space,Str "understanding",Space,Str "of",Space,Str "their",Space,Str "structure,",Space,Str "it",Space,Str "is",Space,Str "easier",Space,Str "to",Space,Str "parse",Space,Str "Aerospike",Space,Str "expressions."]
,Header 2 ("notation",[],[]) [Str "Notation"]
,Para [Str "Aerospike",Space,Str "expressions",Space,Str "use",Space,Link ("",[],[]) [Str "Polish",Space,Str "Notation"] ("https://en.wikipedia.org/wiki/Polish_notation",""),Space,Str "(aka",Space,Str "prefix",Space,Str "notation)",Space,Str "which",Space,Str "is",Space,Str "widely",Space,Str "seen",Space,Str "in",Space,Str "most",Space,Str "programming",Space,Str "language",Space,Str "functions:",Space,Code ("",[],[]) "fn(a, b)",Str ".",Space,Str "So",Space,Str "the",Space,Str "expression",Space,Code ("",[],[]) "5 + 3",Space,Str "in",Space,Str "Aerospike",Space,Str "Java",Space,Str "client",Space,Str "would",Space,Str "be:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Exp.add(",SoftBreak,Str "Exp.val(5),",SoftBreak,Str "Exp.val(3))",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Note,",Space,Str "the",Space,Str "overloaded",Space,Code ("",[],[]) "val",Space,Str "method",Space,Str "converts",Space,Str "all",Space,Str "suported",Space,Str "types",Space,Str "to",Space,Str "a",Space,Code ("",[],[]) "Value",Space,Str "object,",Space,Str "which",Space,Str "provides",Space,Str "an",Space,Str "abstraction",Space,Str "for",Space,Str "all",Space,Str "supported",Space,Str "value",Space,Str "types."]
,Header 2 ("composition",[],[]) [Str "Composition"]
,Para [Str "A",Space,Str "complex",Space,Str "expression",Space,Str "can",Space,Str "be",Space,Str "composed",Space,Str "using",Space,Str "two",Space,Str "or",Space,Str "more",Space,Str "sub-expressions.",Space,Str "For",Space,Str "example,",Space,Str "with",Space,Str "integer",Space,Str "bins",Space,Code ("",[],[]) "a",Space,Str "and",Space,Code ("",[],[]) "b",Str ",",Space,Str "the",Space,Str "expression",Space,Code ("",[],[]) "(a - b) / (a + b)",Space,Str "would",Space,Str "be:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Exp.div(",SoftBreak,Str "Exp.sub(",SoftBreak,Str "Exp.intBin(\"a\"),",SoftBreak,Str "Exp.intBin(\"b\")),",SoftBreak,Str "Exp.add(",SoftBreak,Str "Exp.intBin(\"a\"),",SoftBreak,Str "Exp.intBin(\"b\")))",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Note,",Space,Str "there",Space,Str "are",Space,Str "corresponding",Space,Str "access",Space,Str "methods",Space,Str "to",Space,Str "access",Space,Str "bin",Space,Str "values",Space,Str "for",Space,Str "other",Space,Str "supported",Space,Str "types.",Space,Str "Since",Space,Str "a",Space,Str "bin",Space,Str "may",Space,Str "hold",Space,Str "any",Space,Str "value",Space,Str "type,",Space,Str "an",Space,Str "incorrect",Space,Str "type",Space,Str "access",Space,Str "results",Space,Str "in",Space,Str "an",Space,Str "error.",Space,Str "A",Space,Str "conditional",Space,Str "type",Space,Str "check",Space,Str "may",Space,Str "be",Space,Str "used",Space,Str "to",Space,Str "prevent",Space,Str "a",Space,Str "run-time",Space,Str "error."]
,Header 2 ("variable-definition-and-use",[],[]) [Str "Variable",Space,Str "Definition",Space,Str "and",Space,Str "Use"]
,Para [Str "The",Space,Code ("",[],[]) "let",Space,Str "construct",Space,Str "defines",Space,Str "the",Space,Str "scope",Space,Str "of",Space,Str "variables",Space,Str "and",Space,Str "the",Space,Str "expression",Space,Str "that",Space,Str "uses",Space,Str "them.",Space,Str "The",Space,Code ("",[],[]) "def",Space,Str "construct",Space,Str "defines",Space,Str "a",Space,Str "variable",Space,Str "and",Space,Str "assigns",Space,Str "it",Space,Str "to",Space,Str "an",Space,Str "expression.",Space,Str "Another",Space,Str "expression",Space,Str "in",Space,Str "the",Space,Str "scope",Space,Str "can",Space,Str "use",Space,Str "the",Space,Str "variable",Space,Str "as",Space,Str "a",Space,Str "substitute",Space,Str "for",Space,Str "the",Space,Str "expression",Space,Str "it",Space,Str "defines.",Space,Str "For",Space,Str "example,",Space,Str "in",Space,Str "the",Space,Str "expression",Space,Code ("",[],[]) "5 < (a + b) < 10",Space,Str "using",Space,Str "a",Space,Str "variable",Space,Code ("",[],[]) "x",Space,Str "for",Space,Str "the",Space,Str "sum",Space,Str "of",Space,Str "integer",Space,Str "bins",Space,Code ("",[],[]) "a",Space,Str "and",Space,Code ("",[],[]) "b",Str ":",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Exp.let(",Space,Str "//",Space,Str "let",Space,Str "defines",Space,Str "the",Space,Str "scope",Space,Str "of",Space,Str "variables",Space,Str "for",Space,Str "this",Space,Str "expression",SoftBreak,Str "Exp.def(\"x\",",Space,Str "//",Space,Str "def",Space,Str "defines",Space,Str "a",Space,Str "variable",SoftBreak,Str "Exp.sum(",Space,Str "//",Space,Str "and",Space,Str "also",Space,Str "assigns",Space,Str "it",Space,Str "to",Space,Str "an",Space,Str "expression",SoftBreak,Str "Exp.intBin(\"a\"),",SoftBreak,Str "Exp.intBin(\"b\")),",LineBreak,Str "Exp.and(",Space,Str "//",Space,Str "the",Space,Str "expression",Space,Str "in",Space,Str "let",Space,Str "scope",Space,Str "can",Space,Str "use",Space,Str "the",Space,Str "variable",SoftBreak,Str "Exp.lt(",SoftBreak,Str "Exp.val(5),",SoftBreak,Str "Exp.var(\"x\")),",Space,Str "//",Space,Str "var",Space,Str "to",Space,Str "use",Space,Str "the",Space,Str "variable",SoftBreak,Str "Exp.lt(",SoftBreak,Str "Exp.var(\"x\"),",SoftBreak,Str "Exp.val(10))));",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Note",Space,Str "in",Space,Str "the",Space,Str "above",Space,Str "example,",Space,Str "the",Space,Str "variable",Space,Code ("",[],[]) "x",Space,Str "avoids",Space,Str "repetitive",Space,Str "access",Space,Str "to",Space,Str "the",Space,Str "bins",Space,Code ("",[],[]) "a",Space,Str "and",Space,Code ("",[],[]) "b",Str ".",Space,Str "Also,",Space,Str "variables",Space,Str "defined",Space,Str "in",Space,Code ("",[],[]) "let",Space,Str "cannot",Space,Str "be",Space,Str "used",Space,Str "beyond",Space,Str "its",Space,Str "scope."]
,Header 2 ("conditional-evaluation",[],[]) [Str "Conditional",Space,Str "Evaluation"]
,Para [Str "The",Space,Code ("",[],[]) "cond",Space,Str "construct",Space,Str "includes",Space,Str "one",Space,Str "or",Space,Str "more",Space,Str "pairs",Space,Str "of",Space,Code ("",[],[]) "bool exp, value exp",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "default",Space,Str "value:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "bool",Space,Str "exp1,",Space,Str "value",Space,Str "exp1,",Space,Str "bool",Space,Str "exp2,",Space,Str "value",Space,Str "exp2,",Space,Str "...,",Space,Str "default-value",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "It",Space,Str "evaluates",Space,Str "like",Space,Str "the",Space,Str "if-then-else",Space,Str "logic:",Space,Str "the",Space,Str "expression",Space,Str "takes",Space,Str "the",Space,Str "value",Space,Str "of",Space,Str "the",Space,Str "first",Space,Code ("",[],[]) "value exp",Space,Str "in",Space,Str "the",Space,Str "sequence",Space,Str "whose",Space,Str "corresponding",Space,Code ("",[],[]) "bool exp",Space,Str "evaluates",Space,Str "to",Space,Str "true.",Space,Str "If",Space,Str "all",Space,Str "boolean",Space,Str "conditions",Space,Str "fail,",Space,Str "then",Space,Str "it",Space,Str "evaluates",Space,Str "to",Space,Str "the",Space,Str "last",Space,Str "default-value."]
,Para [Str "So",Space,Str "an",Space,Str "expression",Space,Str "to",Space,Str "evaluate",Space,Str "a",Space,Str "simple",Space,Code ("",[],[]) "risk",Space,Str "value",Space,Str "\"high\"",Space,Str "or",Space,Str "\"normal\"",Space,Str "based",Space,Str "on",Space,Str "int",Space,Str "bin",Space,Code ("",[],[]) "age",Space,Str "and",Space,Str "bool",Space,Str "bin",Space,Code ("",[],[]) "comorbidities",Space,Str "would",Space,Str "be:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "//",Space,Str "if",Space,Str "(age",Space,Str ">",Space,Str "65",Space,Str "&&",Space,Str "comorbidities)",Space,Str "{risk",Space,Str "=",Space,Str "\"high\";}",SoftBreak,Str "//",Space,Str "else",Space,Str "{risk",Space,Str "=",Space,Str "\"normal\";}",SoftBreak,Str "Exp.cond(",SoftBreak,Str "Exp.and(",SoftBreak,Str "Exp.gt(",SoftBreak,Str "Exp.intBin(\"age\"),",Space,Str "Exp.val(65)),",SoftBreak,Str "Exp.boolBin(comorbidities)),",SoftBreak,Str "Exp.val(\"high\"),",SoftBreak,Str "Exp.val(\"normal\"));",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Header 2 ("useful-syntax-patterns",[],[]) [Str "Useful",Space,Str "Syntax",Space,Str "Patterns"]
,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "table",Space,Str "that",Space,Str "summarizes",Space,Str "some",Space,Str "useful",Space,Str "expression",Space,Str "syntax",Space,Str "patterns."]
,Table ("",[],[]) (Caption Nothing
[])
[(AlignLeft,ColWidth 0.6428571428571429)
,(AlignLeft,ColWidth 0.35714285714285715)]
(TableHead ("",[],[])
[Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Expression"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Syntax",Space,Str "Example"]]]])
[(TableBody ("",[],[]) (RowHeadColumns 0)
[]
[Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "3"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.val(3))"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "\"abc\""]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.val(\"abc\")"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "|-3|"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.abs(Exp.val(-3))"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "1",Space,Str "+",Space,Str "2"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.add(Exp.val(1)),",Space,Str "Exp.val(2))"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "var",Space,Str "a",Space,Str "=",Space,Str "5"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.def(\"a\",",Space,Str "Exp.val(5))"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "2",Space,Str ">",Space,Str "3"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.gt(Exp.val(2),",Space,Str "Exp.val(3)"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Function",Space,Str "lastUpdateTime"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.lastUpdateTime()"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "List",Space,Str "API",Space,Str "listSize"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "ListExp.listSize(list)"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Composition",Space,Str "a",Space,Str "+",Space,Str "2",Space,Str "*",Space,Str "b"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.add(Exp.var(a),",Space,Str "Exp.mul(Exp.val(2),",Space,Str "Exp.var(b))"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Condtional",Space,Str "eval",Space,Str "if",Space,Str "(a",Space,Str "==",Space,Str "1)",Space,Str "then",Space,Str "2;",Space,Str "else",Space,Str "3"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.cond(Exp.eq(Exp.var(\"a\"),",Space,Str "Exp.val(1)),",Space,Str "Exp.val(2),",Space,Str "Exp.val(3))"]]]
,Row ("",[],[])
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Integer",Space,Str "\"bin\"",Space,Str "value"]]
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
[Plain [Str "Exp.intBin(\"bin\")"]]]])]
(TableFoot ("",[],[])
[])
,Header 1 ("coding-patterns",[],[]) [Str "Coding",Space,Str "Patterns"]
,Para [Str "An",Space,Str "expression",Space,Str "object",Space,Str "is",Space,Str "constructed",Space,Str "on",Space,Str "the",Space,Str "client",Space,Str "to",Space,Str "be",Space,Str "sent",Space,Str "to",Space,Str "the",Space,Str "server",Space,Str "where",Space,Str "it",Space,Str "is",Space,Str "evaluated",Space,Str "and",Space,Str "used."]
,Para [Str "An",Space,Str "expression's",Space,Str "wire",Space,Str "protocol",Space,Str "representation",Space,Str "is",Space,Str "constructed",Space,Str "with",Space,Str "the",Space,Code ("",[],[]) "build()",Space,Str "function.",Space,Str "A",Space,Str "simple",Space,Str "expression",Space,Code ("",[],[]) "fname == \"Frank\"",Space,Str "will",Space,Str "be",Space,Str "built",Space,Str "thus:",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Expression",Space,Str "simpleExp",Space,Str "=",Space,Str "Exp.build(",SoftBreak,Str "Exp.eq(",SoftBreak,Str "Exp.stringBin(\"fname\"),",SoftBreak,Str "Exp.val(\"Frank\")));",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Para [Str "Note",Space,Str "the",Space,Str "wire",Space,Str "protocol",Space,Str "representation",Space,Str "of",Space,Str "expression",Space,Str "is",Space,Str "of",Space,Str "type",Space,Code ("",[],[]) "Expression",Str ",",Space,Str "whereas",Space,Str "a",Space,Str "client",Space,Str "object",Space,Str "is",Space,Str "of",Space,Str "type",Space,Code ("",[],[]) "Exp",Str "."]
,Para [Str "An",Space,Str "expression",Space,Str "can",Space,Str "be",Space,Str "used",Space,Str "as",Space,Str "a",Space,Str "filter",Space,Str "expression",Space,Str "or",Space,Str "an",Space,Str "operation",Space,Str "expression,",Space,Str "as",Space,Str "described",Space,Str "below."]
,Para [Str "Both",Space,Str "filter",Space,Str "and",Space,Str "operation",Space,Str "expressions",Space,Str "can",Space,Str "be",Space,Str "used",Space,Str "independently",Space,Str "of",Space,Str "each",Space,Str "other",Space,Str "and",Space,Str "also",Space,Str "in",Space,Str "the",Space,Str "same",Space,Str "API",Space,Str "call."]
,Header 2 ("filter-expressions",[],[]) [Str "Filter",Space,Str "Expressions"]
,Para [Str "Filter",Space,Str "expressions",Space,Str "are",Space,Str "so",Space,Str "named",Space,Str "because",Space,Str "they",Space,Str "are",Space,Str "used",Space,Str "as",Space,Str "a",Space,Str "condition",Space,Str "to",Space,Str "select",Space,Str "or",Space,Str "discard",Space,Str "a",Space,Str "record.",Space,Str "They",Space,Str "always",Space,Str "evaluate",Space,Str "to",Space,Str "a",Space,Str "boolean",Space,Str "value",Space,Str "to",Space,Str "indicate",Space,Str "whether",Space,Str "the",Space,Str "record",Space,Str "is",Space,Str "selected",Space,Str "(true)",Space,Str "or",Space,Str "filtered",Space,Str "out",Space,Str "(false).",SoftBreak,Str "A",Space,Str "filter",Space,Str "expression,",Space,Str "as",Space,Str "the",Space,Str "deprecated",Space,Str "Predicate",Space,Str "Expression,",Space,Str "is",Space,Str "sent",Space,Str "to",Space,Str "the",Space,Str "server",Space,Str "through",Space,Str "the",Space,Str "API's",Space,Str "policy",Space,Str "object",Space,Str "parameter.",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Policy",Space,Str "policy",Space,Str "=",Space,Str "new",Space,Str "Policy();",SoftBreak,Str "policy.filterExp",Space,Str "=",Space,Str "Exp.build(",Space,Str "//",Space,Str "sent",Space,Str "through",Space,Str "filterExp",Space,Str "attribute",Space,Str "of",Space,Str "policy",SoftBreak,Str "Exp.eq(",SoftBreak,Str "Exp.intBin(\"a\"),",SoftBreak,Str "Exp.val(11)));",LineBreak,Str "...",SoftBreak,Str "client.query(policy,",Space,Str "stmt)",Space,Str "//",Space,Str "policy",Space,Str "is",Space,Str "specified",Space,Str "as",Space,Str "a",Space,Str "parameter",Space,Str "in",Space,Str "API",Space,Str "calls",SoftBreak,RawInline (Format "markdown") "\n```\n"]
,Header 2 ("operation-expressions",[],[]) [Str "Operation",Space,Str "Expressions"]
,Para [Str "Operation",Space,Str "expressions",Space,Str "as",Space,Str "the",Space,Str "name",Space,Str "suggests",Space,Str "are",Space,Str "used",Space,Str "in",Space,Str "an",Space,Str "operation",Space,Str "-",Space,Str "either",Space,Str "to",Space,Str "read",Space,Str "from",Space,Str "bins",Space,Str "or",Space,Str "write",Space,Str "to",Space,Str "a",Space,Str "bin.",Space,Str "Specifically",Space,Str "they",Space,Str "are",Space,Str "used",Space,Str "in",Space,Code ("",[],[]) "read",Space,Str "and",Space,Code ("",[],[]) "write",Space,Str "methods",Space,Str "of",Space,Code ("",[],[]) "ExpOperation",Str "."]
,Para [Str "The",Space,Str "basic",Space,Str "computational",Space,Str "model",Space,Str "of",Space,Code ("",[],[]) "operate",Str ",",Space,Str "where",Space,Str "operation",Space,Str "expressions",Space,Str "are",Space,Str "used,",Space,Str "remains",Space,Str "the",Space,Str "same:",Space,Str "A",Space,Str "series",Space,Str "of",Space,Str "read",Space,Str "or",Space,Str "write",Space,Str "operations",Space,Str "are",Space,Str "performed",Space,Str "in",Space,Str "a",Space,Str "given",Space,Str "sequence",Space,Str "on",Space,Str "a",Space,Str "single",Space,Str "record.",Space,Str "What",Space,Str "is",Space,Str "new",Space,Str "is",Space,Str "that",Space,Str "a",Space,Str "read",Space,Str "operation",Space,Str "can",Space,Str "be",Space,Str "an",Space,Str "expression",Space,Str "involving",Space,Str "zero",Space,Str "or",Space,Str "more",Space,Str "bins.",Space,Str "Also,",Space,Str "a",Space,Str "write",Space,Str "operation",Space,Str "can",Space,Str "get",Space,Str "the",Space,Str "value",Space,Str "from",Space,Str "an",Space,Str "expression",Space,Str "(enabling,",Space,Str "for",Space,Str "example,",Space,Str "use",Space,Str "of",Space,Str "cross-bin",Space,Str "data",Space,Str "with",Space,Str "conditional",Space,Str "logic)",Space,Str "instead",Space,Str "of",Space,Str "a",Space,Str "simple",Space,Str "constant",Space,Str "to",Space,Str "update",Space,Str "a",Space,Str "bin."]
,Para [Str "A",Space,Str "read",Space,Str "with",Space,Str "operation",Space,Str "expression",Space,Str "can",Space,Str "also",Space,Str "use",Space,Str "an",Space,Str "arbitrary",Space,Str "name",Space,Str "for",Space,Str "the",Space,Str "\"computed",Space,Str "bin\"",Space,Str "similar",Space,Str "to",Space,Str "the",Space,Str "\"as\"",Space,Str "keyword",Space,Str "in",Space,Str "the",Space,Str "SQL",Space,Str "statement",Space,Code ("",[],[]) "SELECT expr AS bin",Str "."]
,Para [Str "The",Space,Str "pattern",Space,Str "for",Space,Str "coding",Space,Str "an",Space,Str "Operation",Space,Str "Expression",Space,Str "is:"]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "Define",Space,Str "Expression",Space,Str "to",Space,Str "read",Space,Str "or",Space,Str "write",Space,Str "the",Space,Str "bins."]]
,[Plain [Str "Use",Space,Code ("",[],[]) "Expression",Space,Str "object",Space,Str "in",Space,Code ("",[],[]) "ExpOperation.read",Space,Str "or",Space,Code ("",[],[]) ".write",Space,Str "method",Space,Str "that",Space,Str "returns",Space,Str "an",Space,Code ("",[],[]) "Operation",Str "."]]
,[Plain [Str "Use",Space,Str "\"expression",Space,Str "operations\"",Space,Str "in",Space,Str "any",Space,Str "API",Space,Str "call",Space,Str "that",Space,Str "takes",Space,Str "an",Space,Str "operation",Space,Str "list."]]]
,Para [Str "This",Space,Str "is",Space,Str "illustrated",Space,Str "below."]
,CodeBlock ("",[],[]) "<pre>\n// operate expression with write \n// 1. Define Expression to write the bin with.\n// if (age > 65 && comorbidities) {risk = \"high\";} \n// else {risk = \"normal\";}\nExpression writeExp = Exp.build(\n Exp.cond(\n Exp.and(\n Exp.gt(\n Exp.intBin(\"age\"), Exp.val(65)),\n Exp.boolBin(comorbidities)),\n Exp.val(\"high\"), \n Exp.val(\"normal\"));\n// 2. Use Expression object in ExpOperation.write method.\nOperation writeExpOp = ExpOperation.write(\"risk\",\n Expression writeExp, // evaluates bin value to update \n ExpWriteFlags.DEFAULT);\n\n// operate expression with read\n// 1. Define Expression to read bins.\n// read \"yes\" if (risk == \"high\" or worktype == \"frontline\") else \"no\" \n// as a computed bin \"eligible\"\nExpression readExp = Exp.build(\n Exp.cond(\n Exp.or(\n Exp.eq(\n Exp.stringBin(\"risk\"), Exp.val(\"high\")),\n Exp.eq(\n Exp.stringBin(\"worktype\"), Exp.val(\"frontline\"))),\n Exp.val(\"yes\"),\n Exp.val(\"no\")));\n// 2. Use Expression object in ExpOperation.read method.\nOperation readExpOp = ExpOperation.read(\"eligible\", // named \"computed bin\"\n Expression readExp, // evaluates value to return \n ExpReadFlags.DEFAULT);\n \n// 3. Use \"expression operations\" in any API call that takes an operation list. \nRecord record = Client.operate(WritePolicy policy, Key key, Operation writeExpOp, Operation readExpOp);\n</pre>"
,Header 1 ("code-examples",[],[]) [Str "Code",Space,Str "Examples"]
,Para [Str "Below",Space,Str "are",Space,Str "code",Space,Str "examples",Space,Str "that",Space,Str "illustrate",Space,Str "the",Space,Str "expression",Space,Str "features",Space,Str "described",Space,Str "above."]
,Header 2 ("filter-expressions",[],[]) [Str "Filter",Space,Str "Expressions"]
,Para [Str "The",Space,Str "following",Space,Str "example",Space,Str "illustrates",Space,Str "the",Space,Str "capabilities",Space,Str "of",Space,Str "filtering",Space,Str "on",Space,Str "metadata",Space,Str "and",Space,Str "use",Space,Str "of",Space,Str "List",Space,Str "APIs",Space,Str "(neither",Space,Str "are",Space,Str "possible",Space,Str "with",Space,Str "the",Space,Str "deprecated",Space,Str "predicate",Space,Str "expressions)."]
,Para [Str "In",Space,Str "this",Space,Str "illustrative",Space,Str "example",Space,Str "the",Space,Str "filter",Space,Str "selects:"]
,BulletList
[[Plain [Str "recently",Space,Str "updated",Space,Str "(sinceUpdate",Space,Str "<",Space,Str "2)",Space,Str "records"]]
,[Plain [Str "with",Space,Str "list",Space,Str "bin",Space,Str "having",Space,Str "a",Space,Str "range",Space,Str "of",Space,Str "values",Space,Str "(i.e.,",Space,Str "max",Space,Str "value",Space,Str "-",Space,Str "min",Space,Str "value)",Space,Str "greater",Space,Str "than",Space,Str "1000."]]]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "Populate",Space,Str "the",Space,Str "test",Space,Str "data",Space,Str "with",Space,Str "20",Space,Str "records",Space,Str "with",Space,Str "an",Space,Str "integer",Space,Str "bin",Space,Str "\"bin1\"",Space,Str "values",Space,Str "1-20",Space,Str "and",Space,Str "a",Space,Str "list",Space,Str "bin",Space,Str "having",Space,Str "3",Space,Str "randomly",Space,Str "selected",Space,Str "numbers",Space,Str "in",Space,Str "the",Space,Str "range",Space,Str "1",Space,Str "to",Space,Str "2000."]]
,[Plain [Str "Sleep",Space,Str "for",Space,Str "2",Space,Str "seconds,"]]
,[Plain [Str "Touch",Space,Str "the",Space,Str "even",Space,Str "numbered",Space,Str "records."]]
,[Plain [Str "Run",Space,Str "the",Space,Str "query",Space,Str "with",Space,Str "the",Space,Str "filter."]]]
,Para [Str "The",Space,Str "results",Space,Str "should",Space,Str "only",Space,Str "contain",Space,Str "even",Space,Str "valued",Space,Str "bin1",Space,Str "and",Space,Str "bin2",Space,Str "with",Space,Str "value",Space,Str "range",Space,Str ">",Space,Str "1000."]
,CodeBlock ("",["java"],[]) "import java.util.ArrayList;\nimport java.util.Random; \nimport com.aerospike.client.AerospikeException;\nimport com.aerospike.client.Bin;\nimport com.aerospike.client.Key;\nimport com.aerospike.client.policy.WritePolicy;\nimport com.aerospike.client.policy.QueryPolicy;\nimport com.aerospike.client.exp.Exp;\nimport com.aerospike.client.exp.ListExp;\nimport com.aerospike.client.Operation;\nimport com.aerospike.client.task.ExecuteTask;\nimport com.aerospike.client.query.Statement;\nimport com.aerospike.client.query.RecordSet;\nimport com.aerospike.client.Record;\nimport com.aerospike.client.cdt.ListReturnType;\n\n// start with a clean state\ntruncateTestData();\n\n// 1. Populate the test data with 20 records with an integer bin \"bin1\" values 1-20 \n// and a list bin having 3 randomly selected numbers in the range 1 to 2000.\n\nRandom rand = new Random(1); \nfinal int LIST_RANGE = 2000;\nWritePolicy wpolicy = new WritePolicy();\nwpolicy.sendKey = true;\nfor (int i = 1; i <= 20; i++) {\n Key key = new Key(Namespace, Set, \"id-\"+i);\n Bin bin1 = new Bin(new String(\"bin1\"), i);\n ArrayList<Integer> intList = new ArrayList<Integer>();\n intList.add(rand.nextInt(LIST_RANGE));\n intList.add(rand.nextInt(LIST_RANGE));\n intList.add(rand.nextInt(LIST_RANGE));\n Bin bin2 = new Bin(new String(\"bin2\"), intList);\n client.put(wpolicy, key, bin1, bin2);\n}\nSystem.out.println(\"Test data populated.\");;\n\n// 2. Sleep for 2 seconds, \nThread.sleep(2000);\n\n// 3. Touch the even numbered records.\nStatement stmt = new Statement();\nstmt.setNamespace(Namespace);\nstmt.setSetName(Set);\n\nWritePolicy policy = new WritePolicy();\npolicy.filterExp = Exp.build(\n Exp.eq(\n Exp.mod(Exp.intBin(\"bin1\"), Exp.val(2)),\n Exp.val(0)));\n\nExecuteTask task = client.execute(policy, stmt, Operation.touch()); \ntask.waitTillComplete(500, 1000);\nSystem.out.println(\"Touched even numbered records.\");;\n\n// 4. Run the query with the filter.\n// records updated in last 2 seconds and whose list value range is more than 1000\nStatement stmt = new Statement();\nstmt.setNamespace(Namespace);\nstmt.setSetName(Set);\n\n// expression filter is specifed in the operation policy\nQueryPolicy policy = new QueryPolicy(client.queryPolicyDefault);\npolicy.filterExp = Exp.build(\n Exp.and(\n Exp.lt(Exp.sinceUpdate(), Exp.val(2000)), // updated in last 2s\n Exp.gt( // range of values in bin2 greater than 1000\n Exp.sub(ListExp.getByRank(ListReturnType.VALUE, Exp.Type.INT, Exp.val(-1), Exp.listBin(\"bin2\")), // largest\n ListExp.getByRank(ListReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.listBin(\"bin2\"))), // smallest\n Exp.val(1000))));\n\nRecordSet rs = client.query(policy, stmt);\n\nSystem.out.println(\"Results of filter expression query (all even records with bin2 max-min > 1000):\");\nwhile (rs.next()) {\n Key key = rs.getKey();\n Record record = rs.getRecord();\n System.out.format(\"key=%s bins=%s\\n\", key.userKey, record.bins);\n}\nrs.close();"
,BlockQuote
[CodeBlock ("",[],[]) "Test data populated.\nTouched even numbered records.\nResults of filter expression query (all even records with bin2 max-min > 1000):\nkey=id-4 bins={bin1=4, bin2=[1748, 569, 473]}\nkey=id-10 bins={bin1=10, bin2=[153, 1437, 1302]}\nkey=id-18 bins={bin1=18, bin2=[333, 1676, 55]}\nkey=id-16 bins={bin1=16, bin2=[592, 220, 1888]}\n"]
,Para [Str "You",Space,Str "may",Space,Str "view",Space,Str "the",Space,Str "state",Space,Str "of",Space,Str "the",Space,Str "database",Space,Str "and",Space,Str "ensure",Space,Str "correctness",Space,Str "of",Space,Str "the",Space,Str "output",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "following",Space,Str "command",Space,Str "in",Space,Str "the",Space,Str "terminal",Space,Str "tab:"]
,Para [Code ("",[],[]) "aql -c \"select * from test.expressions\""]
,Header 2 ("operation-expressions",[],[]) [Str "Operation",Space,Str "Expressions"]
,Para [Str "In",Space,Str "the",Space,Str "following",Space,Str "example,",Space,Str "these",Space,Str "new",Space,Str "capabilites",Space,Str "that",Space,Str "were",Space,Str "not",Space,Str "possible",Space,Str "earlier",Space,Str "are",Space,Str "illustrated:"]
,BulletList
[[Plain [Str "expressions",Space,Str "involving",Space,Str "zero",Space,Str "or",Space,Str "more",Space,Str "bins",Space,Str "to",Space,Str "write",Space,Str "a",Space,Str "bin"]]
,[Plain [Str "named",Space,Str "\"computed",Space,Str "bins\"",Space,Str "that",Space,Str "return",Space,Str "the",Space,Str "value",Space,Str "of",Space,Str "a",Space,Str "specified",Space,Str "expression",Space,Str "involving",Space,Str "zero",Space,Str "or",Space,Str "more",Space,Str "bins"]]
,[Plain [Str "conditional",Space,Str "evaluation",Space,Str "of",Space,Str "expression"]]
,[Plain [Str "use",Space,Str "of",Space,Str "variables",Space,Str "in",Space,Str "an",Space,Str "expression"]]]
,Para [Str "The",Space,Str "code",Space,Str "has",Space,Str "the",Space,Str "following",Space,Str "steps:"]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "The",Space,Str "test",Space,Str "data",Space,Str "is",Space,Str "populated",Space,Str "with",Space,Str "three",Space,Str "randomly",Space,Str "generated",Space,Str "test",Space,Str "scores",Space,Str "ranging",Space,Str "from",Space,Str "50",Space,Str "to",Space,Str "100",Space,Str "for",Space,Str "student",Space,Str "ids",Space,Str "1-20."]]
,[Plain [Str "The",Space,Str "data",Space,Str "is",Space,Str "updated",Space,Str "by",Space,Str "writing",Space,Str "two",Space,Str "additional",Space,Str "bins:",Space,Str "\"class\"",Space,Str "which",Space,Str "represents",Space,Str "the",Space,Str "teacher's",Space,Str "input",Space,Str "(0-10)",Space,Str "based",Space,Str "on",Space,Str "class",Space,Str "participation,",Space,Str "and",Space,Str "\"grade\"",Space,Str "which",Space,Str "is",Space,Str "computed",Space,Str "by",Space,Str "adding",Space,Str "\"classwork\"",Space,Str "to",Space,Str "average",Space,Str "of",Space,Str "test",Space,Str "scores,",Space,Str "and",Space,Str "using",Space,Str "this",Space,Str "formula",Space,Str "to",Space,Str "compute",Space,Str "the",Space,Str "grade:",Space,Str "50-70",Space,Str "->",Space,Str "C,",Space,Str "65==70-85",Space,Str "->",Space,Str "B,",Space,Str "85+",Space,Str "->",Space,Str "A."]]
,[Plain [Str "A",Space,Str "report",Space,Str "is",Space,Str "then",Space,Str "generated",Space,Str "for",Space,Str "the",Space,Str "id,",Space,Str "grade,",Space,Str "total",Space,Str "score,",Space,Str "and",Space,Str "min/max/average",Space,Str "of",Space,Str "test",Space,Str "scores."]]]
,CodeBlock ("",["java"],[]) "import com.aerospike.client.exp.Expression;\nimport com.aerospike.client.exp.ExpOperation;\nimport com.aerospike.client.exp.ExpReadFlags;\nimport com.aerospike.client.exp.ExpWriteFlags;\n \n// start with a clean state\ntruncateTestData();\n\n// 1. The test data is populated with three randomly genrated test scores ranging from 50 to 100 \n// for student ids 1-20.\n\nRandom rand = new Random(1); \nfinal int SCORE_RANGE = 50;\nWritePolicy wpolicy = new WritePolicy();\nwpolicy.sendKey = true;\nfor (int i = 1; i <= 20; i++) {\n Key key = new Key(Namespace, Set, \"id-\"+i);\n Bin id = new Bin(new String(\"id\"), i);\n ArrayList<Integer> testScores = new ArrayList<Integer>();\n testScores.add(50 + rand.nextInt(SCORE_RANGE));\n testScores.add(50 + rand.nextInt(SCORE_RANGE));\n testScores.add(50 + rand.nextInt(SCORE_RANGE));\n Bin tests = new Bin(new String(\"tests\"), testScores);\n client.put(wpolicy, key, id, tests);\n}\nSystem.out.println(\"Test data populated.\");;\n\n// 2. The data is updated by writing two additional bins: \"class\" which represents the teacher's input (0-10) \n// based on class participation, and \"grade\" which is computed by adding \"classwork\" to average of test scores, \n// and using this formula: 50-70 -> C, 65==70-85 -> B, 85+ -> A.\n\n// define the expressions for average test score, total score, grade, min test score, and max test score\nExp avgScoreExp = Exp.let(\n Exp.def(\"testsBin\", Exp.listBin(\"tests\")),\n Exp.div(\n Exp.add(ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.var(\"testsBin\")),\n ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.INT, Exp.val(1), Exp.var(\"testsBin\")),\n ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.INT, Exp.val(2), Exp.var(\"testsBin\"))),\n Exp.val(3)));\nExpression avgScoreExpression = Exp.build(avgScoreExp);\n\nExp totalScoreExp = Exp.let(\n Exp.def(\"classBin\", Exp.intBin(\"class\")),\n Exp.add(avgScoreExp, Exp.var(\"classBin\")));\nExpression totalScoreExpression = Exp.build(totalScoreExp);\n\nExp gradeExp = Exp.let(\n Exp.def(\"total\", totalScoreExp),\n Exp.cond(\n Exp.lt(Exp.var(\"total\"), Exp.val(70)), Exp.val(\"C\"),\n Exp.le(Exp.var(\"total\"), Exp.val(85)), Exp.val(\"B\"),\n Exp.gt(Exp.var(\"total\"), Exp.val(85)), Exp.val(\"A\"),\n Exp.unknown()));\nExpression gradeExpression = Exp.build(gradeExp);\n\nExp minExp = ListExp.getByRank(ListReturnType.VALUE, Exp.Type.INT, Exp.val(0), Exp.listBin(\"tests\")); // min\nExpression minExpression = Exp.build(minExp);\n\nExp maxExp = ListExp.getByRank(ListReturnType.VALUE, Exp.Type.INT, Exp.val(-1), Exp.listBin(\"tests\")); // max\nExpression maxExpression = Exp.build(maxExp);\n\n// update class bin with a random 1-10, and the grade bin using gradeExpOp\nfor (int i = 1; i <= 20; i++) {\n Key key = new Key(Namespace, Set, \"id-\"+i);\n int classwork = rand.nextInt(SCORE_RANGE)/5;\n Bin classBin = new Bin(new String(\"class\"), classwork);\n \n // write gradeExp to the bin \"grade\"\n Operation gradeExpOp = ExpOperation.write(\"grade\",\n gradeExpression, \n ExpWriteFlags.DEFAULT);\n \n client.operate(wpolicy, key, Operation.put(classBin), gradeExpOp);\n}\nSystem.out.println(\"Updated class participation and computed grades.\");;\n\n// run a report for all students with id, grade, total, min, max, avg\n// using total, min, max, and avg expressions defined above\n\nOperation ops[] = { Operation.get(\"id\"), \n Operation.get(\"grade\"),\n ExpOperation.read(\"total\", totalScoreExpression, ExpReadFlags.DEFAULT),\n ExpOperation.read(\"testMin\", minExpression, ExpReadFlags.DEFAULT),\n ExpOperation.read(\"testMax\", maxExpression, ExpReadFlags.DEFAULT),\n ExpOperation.read(\"testAvg\", avgScoreExpression, ExpReadFlags.DEFAULT)\n};\n\nfor (int i = 1; i <= 20; i++) {\n Key key = new Key(Namespace, Set, \"id-\"+i);\n Record record = client.operate(null, key, ops);\n System.out.format(\"key=%s bins=%s\\n\", key.userKey, record.bins);\n}\n"
,BlockQuote
[CodeBlock ("",[],[]) "Test data populated.\nUpdated class participation and computed grades.\nkey=id-1 bins={id=1, grade=A, total=90, testMin=85, testMax=97, testAvg=90}\nkey=id-2 bins={id=2, grade=C, total=57, testMin=54, testMax=63, testAvg=57}\nkey=id-3 bins={id=3, grade=B, total=79, testMin=56, testMax=84, testAvg=72}\nkey=id-4 bins={id=4, grade=A, total=86, testMin=69, testMax=98, testAvg=80}\nkey=id-5 bins={id=5, grade=B, total=73, testMin=62, testMax=67, testAvg=64}\nkey=id-6 bins={id=6, grade=A, total=88, testMin=62, testMax=92, testAvg=79}\nkey=id-7 bins={id=7, grade=A, total=88, testMin=76, testMax=96, testAvg=87}\nkey=id-8 bins={id=8, grade=B, total=82, testMin=60, testMax=99, testAvg=80}\nkey=id-9 bins={id=9, grade=B, total=80, testMin=59, testMax=98, testAvg=77}\nkey=id-10 bins={id=10, grade=C, total=69, testMin=52, testMax=87, testAvg=64}\nkey=id-11 bins={id=11, grade=C, total=54, testMin=50, testMax=55, testAvg=53}\nkey=id-12 bins={id=12, grade=C, total=61, testMin=55, testMax=63, testAvg=58}\nkey=id-13 bins={id=13, grade=B, total=81, testMin=70, testMax=89, testAvg=78}\nkey=id-14 bins={id=14, grade=B, total=70, testMin=60, testMax=84, testAvg=69}\nkey=id-15 bins={id=15, grade=B, total=84, testMin=77, testMax=87, testAvg=80}\nkey=id-16 bins={id=16, grade=A, total=90, testMin=70, testMax=92, testAvg=83}\nkey=id-17 bins={id=17, grade=C, total=61, testMin=50, testMax=57, testAvg=53}\nkey=id-18 bins={id=18, grade=B, total=77, testMin=55, testMax=83, testAvg=71}\nkey=id-19 bins={id=19, grade=B, total=79, testMin=58, testMax=95, testAvg=79}\nkey=id-20 bins={id=20, grade=B, total=81, testMin=54, testMax=84, testAvg=72}\n"]
,Para [Str "You",Space,Str "may",Space,Str "view",Space,Str "the",Space,Str "state",Space,Str "of",Space,Str "the",Space,Str "database",Space,Str "and",Space,Str "ensure",Space,Str "correctness",Space,Str "of",Space,Str "the",Space,Str "output",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "following",Space,Str "command",Space,Str "in",Space,Str "the",Space,Str "terminal",Space,Str "tab:"]
,Para [Code ("",[],[]) "aql -c \"select * from test.expressions\""]
,Header 1 ("using-expression-operations-vs-r-m-w-or-udfs",[],[]) [Str "Using",Space,Str "Expression",Space,Str "Operations",Space,Str "vs",Space,Str "R-M-W",Space,Str "or",Space,Str "UDFs"]
,Para [Str "Aerospike",Space,Str "developers",Space,Str "have",Space,Str "multiple",Space,Str "ways",Space,Str "to",Space,Str "perform",Space,Str "a",Space,Str "record",Space,Str "oriented",Space,Str "read-write",Space,Str "logic."]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "Read",Space,Str "record",Space,Str "data",Space,Str "to",Space,Str "the",Space,Str "client,",Space,Str "modify,",Space,Str "and",Space,Str "write",Space,Str "back",Space,Str "(\"R-M-W\")."]]
,[Plain [Str "Create",Space,Str "a",Space,Str "UDF",Space,Str "for",Space,Str "the",Space,Str "logic",Space,Str "and",Space,Str "invoke",Space,Str "it",Space,Str "on",Space,Str "the",Space,Str "record."]]
,[Plain [Str "Use",Space,Str "expression",Space,Str "operations",Space,Str "in",Space,Str "a",Space,Str "mulit-op",Space,Str "request."]]]
,Para [Str "For",Space,Str "read-write",Space,Str "transactions,",Space,Str "fetching",Space,Str "the",Space,Str "data",Space,Str "to",Space,Str "the",Space,Str "client",Space,Str "and",Space,Str "writing",Space,Str "back",Space,Str "is",Space,Str "expensive",Space,Str "and",Space,Str "requires",Space,Str "special",Space,Str "care",Space,Str "to",Space,Str "ensure",Space,Str "read-write",Space,Str "isolation.",Space,Str "Lua",Space,Str "UDFs",Space,Str "can",Space,Str "be",Space,Str "difficult",Space,Str "to",Space,Str "implement,",Space,Str "less",Space,Str "flexible",Space,Str "to",Space,Str "change,",Space,Str "and",Space,Str "can",Space,Str "be",Space,Str "slower.",Space,Str "So",Space,Str "it",Space,Str "is",Space,Str "generally",Space,Str "beneficial",Space,Str "to",Space,Str "use",Space,Str "expression",Space,Str "operations",Space,Str "when",Space,Str "possible."]
,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "suggested",Space,Str "decision",Space,Str "process:"]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "Use",Space,Str "expression",Space,Str "operations.",Space,Str "However",Space,Str "if",Space,Str "expression",Space,Str "operations",Space,Str "cannot",Space,Str "be",Space,Str "used",Space,Str "because",Space,Str "the",Space,Str "task,",Space,Str "for",Space,Str "example,",Space,Str "requires",Space,Str "unsupported",Space,Str "features",Space,Str "such",Space,Str "as",Space,Str "iterators",Space,Str "and",Space,Str "loops,",Space,Str "then:"]]
,[Plain [Str "Use",Space,Str "client-side",Space,Str "Read-Modify-Write",Space,Str "(R-M-W)",Space,Str "with",Space,Str "version",Space,Str "check",Space,Str "if",Space,Str "amount",Space,Str "of",Space,Str "data",Space,Str "transfer",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "possibility",Space,Str "of",Space,Str "conflict",Space,Str "due",Space,Str "to",Space,Str "concurrency",Space,Str "is",Space,Str "limited.",Space,Str "Otherwise:"]]
,[Plain [Str "Use",Space,Str "UDFs",Space,Str "if",Space,Str "Lua",Space,Str "server",Space,Str "side",Space,Str "programming",Space,Str "model",Space,Str "and",Space,Str "performance",Space,Str "meet",Space,Str "the",Space,Str "needs.",Space,Str "Otherwise",Space,Str "must",Space,Str "use",Space,Str "2."]]]
,Para [Str "Note,",Space,Str "Aerospike",Space,Str "provides",Space,Str "many",Space,Str "ways",Space,Str "to",Space,Str "implement",Space,Str "a",Space,Str "given",Space,Str "data",Space,Str "task",Space,Str "on",Space,Str "one",Space,Str "or",Space,Str "multiple",Space,Str "records.",Space,Str "To",Space,Str "determine",Space,Str "the",Space,Str "optimal",Space,Str "way",Space,Str "for",Space,Str "a",Space,Str "given",Space,Str "task,",Space,Str "one",Space,Str "should",Space,Str "consider",Space,Str "and",Space,Str "evaluate",Space,Str "the",Space,Str "options",Space,Str "available",Space,Str "including",Space,Str "the",Space,Str "various",Space,Str "execution",Space,Str "modes",Space,Str "(synchronous,",Space,Str "asynchronous,",Space,Str "background,",Space,Str "etc)."]
,Header 1 ("usage-notes",[],[]) [Str "Usage",Space,Str "Notes"]
,BulletList
[[Para [Str "Policy",Space,Str "currently",Space,Str "allows",Space,Str "both",Space,Str "the",Space,Str "deprecated",Space,Str "predExp",Space,Str "and",Space,Str "new",Space,Code ("",[],[]) "filterExp",Str ",",Space,Str "but",Space,Str "they",Space,Str "are",Space,Str "mutually",Space,Str "exclusive.",Space,Str "If",Space,Str "both",Space,Str "are",Space,Str "specified,",Space,Str "only",Space,Code ("",[],[]) "filterExp",Space,Str "will",Space,Str "be",Space,Str "used",Space,Str "and",Space,Code ("",[],[]) "predExp",Space,Str "will",Space,Str "be",Space,Str "ignored."]]
,[Para [Str "Errors",Space,Str "during",Space,Str "evaluation:"]
,BulletList
[[Plain [Str "Type",Space,Str "match,",Space,Str "bin",Space,Str "existence,",Space,Str "etc,",Space,Str "can",Space,Str "be",Space,Str "checked",Space,Str "using",Space,Code ("",[],[]) "cond",Space,Str "to",Space,Str "avoid",Space,Str "run",Space,Str "time",Space,Str "evaluation",Space,Str "errors.",SoftBreak,RawInline (Format "markdown") "\n```\n",SoftBreak,Str "Exp.cond(",SoftBreak,Str "Exp.eq(",Space,Str "//",Space,Str "check",Space,Str "if",Space,Str "the",Space,Str "bin",Space,Str "is",Space,Str "of",Space,Str "type",Space,Str "int",SoftBreak,Str "Exp.binType(\"a\"),",SoftBreak,Str "Exp.val(ParticleType.INTEGER)),",SoftBreak,Str "Exp.eq(",Space,Str "//",Space,Str "perform",Space,Str "int",Space,Str "comparison",SoftBreak,Str "Exp.intBin(\"a\"),",SoftBreak,Str "Exp.val(1)),",SoftBreak,Str "Exp.val(false));",Space,Str "//",Space,Str "default",Space,Str "is",Space,Str "false",SoftBreak,RawInline (Format "markdown") "\n```\n"]]
,[Plain [Str "Filter",Space,Str "expressions",Space,Str "treat",Space,Str "the",Space,Str "final",Space,Str "unknown",Space,Str "value",Space,Str "as",Space,Str "false,",Space,Str "whereas",Space,Str "in",Space,Str "operation",Space,Str "expressions",Space,Str "it",Space,Str "results",Space,Str "in",Space,Str "an",Space,Str "error."]]
,[Plain [Str "If",Space,Str "appropriate,",Space,Str "evaluation",Space,Str "failure",Space,Str "can",Space,Str "be",Space,Str "ignored",Space,Str "while",Space,Str "performing",Space,Str "multiple",Space,Code ("",[],[]) "operate",Space,Str "operations",Space,Str "by",Space,Str "setting",Space,Str "the",Space,Str "flags",Space,Str "argument",Space,Str "in",Space,Code ("",[],[]) "ExpOperation.read",Space,Str "or",Space,Code ("",[],[]) ".write",Space,Str "to",Space,Code ("",[],[]) "ExpReadFlags.EVAL_NO_FAIL",Space,Str "or",Space,Code ("",[],[]) "ExpWriteFlags.EVAL_NO_FAIL",Space,Str "respectively."]]]]
,[Para [Str "Constructs",Space,Str "like",Space,Str "loops",Space,Str "and",Space,Str "iterators",Space,Str "over",Space,Str "record",Space,Str "bins",Space,Str "or",Space,Str "CDT",Space,Str "elements",Space,Str "are",Space,Str "not",Space,Str "currently",Space,Str "supported.",Space,Str "General",Space,Str "manipulation",Space,Str "of",Space,Str "data",Space,Str "beyond",Space,Str "what",Space,Str "is",Space,Str "available",Space,Str "in",Space,Str "the",Space,Str "APIs",Space,Str "also",Space,Str "is",Space,Str "not",Space,Str "supported."]]]
,Header 1 ("takeaways-and-conclusion",[],[]) [Str "Takeaways",Space,Str "and",Space,Str "Conclusion"]
,Para [Str "The",Space,Str "tutorial",Space,Str "described",Space,Str "expressions",Space,Str "capabilities",Space,Str "in",Space,Str "Aerospike.",Space,Str "It",Space,Str "explained",Space,Str "the",Space,Str "scope",Space,Str "and",Space,Str "syntax,",Space,Str "and",Space,Str "described",Space,Str "the",Space,Str "key",Space,Str "components",Space,Str "and",Space,Str "constructs.",Space,Str "It",Space,Str "provided",Space,Str "code",Space,Str "examples",Space,Str "for",Space,Str "how",Space,Str "to",Space,Str "work",Space,Str "with",Space,Str "expressions",Space,Str "in",Space,Str "two",Space,Str "client",Space,Str "uses:",Space,Str "filter",Space,Str "expressions",Space,Str "and",Space,Str "operation",Space,Str "expressions."]
,Para [Str "The",Space,Str "enhanced",Space,Str "capabilities",Space,Str "in",Space,Str "filtering",Space,Str "expressions",Space,Str "allow",Space,Str "records",Space,Str "to",Space,Str "be",Space,Str "processed",Space,Str "more",Space,Str "efficiently",Space,Str "by",Space,Str "avoiding",Space,Str "the",Space,Str "need",Space,Str "for",Space,Str "more",Space,Str "expensive",Space,Str "client",Space,Str "or",Space,Str "udf",Space,Str "based",Space,Str "processing.",Space,Str "New",Space,Str "capabilities",Space,Str "indlude",Space,Str "access",Space,Str "to",Space,Str "metadata,",Space,Str "bin",Space,Str "data,",Space,Str "powerful",Space,Str "APIs,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "enhanced",Space,Str "arithmetic",Space,Str "and",Space,Str "other",Space,Str "operators."]
,Para [Str "Operation",Space,Str "expressions",Space,Str "can",Space,Str "eliminate",Space,Str "the",Space,Str "need",Space,Str "to",Space,Str "read",Space,Str "before",Space,Str "update",Space,Str "by",Space,Str "allowing",Space,Str "read,",Space,Str "processing",Space,Str "for",Space,Str "update,",Space,Str "and",Space,Str "update",Space,Str "to",Space,Str "happen",Space,Str "on",Space,Str "the",Space,Str "server",Space,Str "side",Space,Str "in",Space,Str "the",Space,Str "same",Space,Str "request.",Space,Str "This",Space,Str "saves",Space,Str "a",Space,Str "round-trip",Space,Str "and",Space,Str "transfer",Space,Str "of",Space,Str "potentially",Space,Str "large",Space,Str "data."]
,Para [Str "Expressions",Space,Str "provide",Space,Str "powerful",Space,Str "capabilities;",Space,Str "evaluate",Space,Str "and",Space,Str "use",Space,Str "them",Space,Str "if",Space,Str "they",Space,Str "are",Space,Str "suitable",Space,Str "and",Space,Str "provide",Space,Str "better",Space,Str "performance",Space,Str "for",Space,Str "your",Space,Str "use",Space,Str "case",Space,Str "over",Space,Str "UDFs",Space,Str "and",Space,Str "client-side",Space,Str "processing."]
,Header 1 ("cleaning-up",[],[]) [Str "Cleaning",Space,Str "Up"]
,Para [Str "Remove",Space,Str "tutorial",Space,Str "data",Space,Str "and",Space,Str "close",Space,Str "connection."]
,CodeBlock ("",["java"],[]) "truncateTestData();\nclient.close();\nSystem.out.println(\"Removed tutorial data and closed server connection.\");"
,BlockQuote
[CodeBlock ("",[],[]) "Removed tutorial data and closed server connection.\n"]
,Header 1 ("further-exploration-and-resources",[],[]) [Str "Further",Space,Str "Exploration",Space,Str "and",Space,Str "Resources"]
,Para [Str "Here",Space,Str "are",Space,Str "some",Space,Str "links",Space,Str "for",Space,Str "further",Space,Str "exploration."]
,Header 2 ("resources",[],[]) [Str "Resources"]
,BulletList
[[Plain [Str "Workshop",Space,Str "video"]
,BulletList
[[Plain [Link ("",[],[]) [Str "Unleashing",Space,Str "the",Space,Str "Power",Space,Str "of",Space,Str "Expressions",Space,Str "Workshop",Space,Str "(Digital",Space,Str "Summit",Space,Str "2021)"] ("https://www.youtube.com/watch?v=ebRLnXvpWaI&list=PLGo1-Ya-AEQCdHtFeRpMEg6-1CLO-GI3G&index=8","")]]]]
,[Plain [Str "Docs"]
,BulletList
[[Plain [Link ("",[],[]) [Str "Aerospike",Space,Str "Expressions",Space,Str "Guide"] ("https://docs.aerospike.com/docs/guide/expressions/","")]]
,[Plain [Link ("",[],[]) [Str "Java",Space,Str "Expression",Space,Str "Classes"] ("https://docs.aerospike.com/apidocs/java/com/aerospike/client/exp/package-frame.html","")]]
,[Plain [Link ("",[],[]) [Str "Aerospike",Space,Str "Documentation"] ("https://docs.aerospike.com/docs/","")]]]]
,[Plain [Str "Related",Space,Str "notebooks"]
,BulletList
[[Plain [Link ("",[],[]) [Str "Read-Write",Space,Str "Transactions",Space,Str "with",Space,Str "R-M-W",Space,Str "Pattern",Space,Str "(Python)"] ("../python/transactions_rmw_pattern.ipynb","")]]
,[Plain [Link ("",[],[]) [Str "Implementing",Space,Str "SQL",Space,Str "Operations:",Space,Str "SELECT"] ("sql_select.ipynb",""),Str ","]]
,[Plain [Link ("",[],[]) [Str "Implementing",Space,Str "SQL",Space,Str "Operations:",Space,Str "CREATE,",Space,Str "UPDATE,",Space,Str "DELETE"] ("sql_updates.ipynb","")]]
,[Plain [Link ("",[],[]) [Str "Working",Space,Str "with",Space,Str "Lists"] ("java-working_with_lists.ipynb","")]]
,[Plain [Link ("",[],[]) [Str "Working",Space,Str "with",Space,Str "Maps"] ("java-working_with_maps.ipynb","")]]]]
,[Plain [Str "Aerospike",Space,Str "Developer",Space,Str "Hub"]
,BulletList
[[Plain [Link ("",[],[]) [Str "Java",Space,Str "Developers",Space,Str "Resources"] ("https://developer.aerospike.com/java-developers","")]]]]
,[Plain [Str "Github",Space,Str "repos"]
,BulletList
[[Plain [Link ("",[],[]) [Str "Java",Space,Str "code",Space,Str "examples"] ("https://github.com/aerospike/aerospike-client-java/tree/master/examples/src/com/aerospike/examples","")]]
,[Plain [Link ("",[],[]) [Str "Java",Space,Str "Client"] ("https://www.aerospike.com/docs/client/java/index.html","")]]]]]
,Header 2 ("explore-other-notebooks",[],[]) [Str "Explore",Space,Str "Other",Space,Str "Notebooks"]
,Para [Str "Visit",Space,Link ("",[],[]) [Str "Aerospike",Space,Str "notebooks",Space,Str "repo"] ("https://github.com/aerospike-examples/interactive-notebooks",""),Space,Str "to",Space,Str "run",Space,Str "additional",Space,Str "Aerospike",Space,Str "notebooks.",Space,Str "To",Space,Str "run",Space,Str "a",Space,Str "different",Space,Str "notebook,",Space,Str "download",Space,Str "the",Space,Str "notebook",Space,Str "from",Space,Str "the",Space,Str "repo",Space,Str "to",Space,Str "your",Space,Str "local",Space,Str "machine,",Space,Str "and",Space,Str "then",Space,Str "click",Space,Str "on",Space,Str "File->Open",Space,Str "in",Space,Str "the",Space,Str "notebook",Space,Str "menu,",Space,Str "and",Space,Str "select",Space,Str "Upload."]]