Building In-Memory Tables with Optic
- Last Updated: May 18, 2026
- 1 minute read
- MarkLogic Server
- Version 12.0
- Documentation
Building an in-memory table for data that needs to be generated at runtime is a simple task with Optic.
We want to build an in-memory table with some Human Resource (HR) data: roles and levels for three positions.
An Optic example like this one builds a table in memory with two columns,roleandlevel:
op.fromLiterals([
{ "role": "Software Engineer", "level": 1},
{ "role": "Team Lead", "level": 2},
{ "role": "Engineering Manager", "level": 3}
])
.result()
We used this example to create and retrieve the table:
- The Data Accessor Function
fromLiterals()constructs a row sequence with provided data.
- The Executor Function
result()executes the constructor and returns the results as a row sequence.
Here is the 3-row x 2-column result:
{
"level":1,
"role":"Software Engineer"
}
{
"level":2,
"role":"Team Lead"
}
{
"level":3,
"role":"Engineering Manager"
}