Abstract
This section discusses the NdbInterpretedCode
class, which can be used to prepare and execute an NDB interpreted
program.
Beginning with MySQL Cluster NDB 6.2.14 and MySQL Cluster 6.3.12,
you must use the
NdbInterpretedCode
class (rather than
NdbScanOperation
) to write interpreted programs
used for scans.
Parent class. None.
Child classes. None.
Description.
NdbInterpretedCode
represents an interpreted
program for use in operations created using
NdbRecord
(see
Section 2.3.25, “The NdbRecord
Interface”), or with scans created using the
old API. The NdbScanFilter
class can also be
used to generate an NDB interpreted program using this class. (See
Section 2.3.17, “The NdbScanFilter
Class”.) This class was added in
MySQL Cluster NDB 6.2.14 and 6.3.12.
This interface is still under development, and so is subject to
change without notice. The NdbScanFilter
API is
a more stable API for defining scanning and filtering programs.
See Section 2.3.17, “The NdbScanFilter
Class”, for more information.
Using NdbInterpretedCode
.
To create an NdbInterpretedCode
object, invoke
the constructor, optionally supplying a table for the program to
operate on, and a buffer for program storage and finalization. If
no table is supplied, then only instructions which do not access
table attributes can be used.
Each NDB API operation applies to one table, and so does any
NdbInterpretedCode
program attached to that
operation.
If no buffer is supplied, then an internal buffer is dynamically
allocated and extended as necessary. Once the
NdbInterpretedCode
object is created, you can
add instructions and labels to it by calling the appropriate
methods as described later in this section. When the program has
completed, finalize it by calling the
finalise()
method, which resolves any remaining
internal branches and calls to label and subroutine offsets.
A single finalized NdbInterpretedCode
program can be used by more than one operation. It need not be
re-prepared for successive operations.
To use the program with NdbRecord
operations
and scans, pass it at operation definition time via the
OperationOptions
or
ScanOptions
parameter. Alternatively, you can
use the program with old-style API scans by passing it via the
setInterpretedProgram()
method. When the
program is no longer required, the
NdbInterpretedCode
object can be deleted, along
with any user-supplied buffer.
Error checking. For reasons of efficiency, methods of this class provide minimal error checking.
Methods. The following table lists the public methods of this class and the purpose or use of each method:
Method | Purpose / Use |
---|---|
NdbInterpretedCode() |
Class constructor |
load_const_null() |
Load a NULL value into a register |
load_const_u16() |
Load a 16-bit numeric value into a register |
load_const_u32() |
Load a 32-bit numeric value into a register |
load_const_u64() |
Load a 64-bit numeric value into a register |
read_attr() |
Read a register value into a table column |
write_attr() |
Write a table column value into a register |
add_reg() |
Add two register values and store the result in a third register |
sub_reg() |
Subtract two register values and store the result in a third register |
def_label() |
Create a label for use within the interpreted program |
branch_label() |
Unconditional jump to a label |
branch_ge() |
Jump if one register value is greater than or equal to another |
branch_gt() |
Jump if one register value is greater than another |
branch_le() |
Jump if one register value is less than or equal to another |
branch_lt() |
Jump if one register value is less than another |
branch_eq() |
Jump if one register value is equal to another |
branch_ne() |
Jump if one register value is not equal to another |
branch_ne_null() |
Jump if a register value is not NULL
|
branch_eq_null() |
Jump if a register value is NULL
|
branch_col_eq() |
Jump if a column value is equal to another |
branch_col_ne() |
Jump if a column value is not equal to another |
branch_col_lt() |
Jump if a column value is less than another |
branch_col_le() |
Jump if a column value is less than or equal to another |
branch_col_gt() |
Jump if a column value is greater than another |
branch_col_ge() |
Jump if a column value is greater than or equal to another |
branch_col_eq_null() |
Jump if a column value is NULL
|
branch_col_ne_null() |
Jump if a column value is not NULL
|
branch_col_like() |
Jump if a column value matches a pattern |
branch_col_notlike() |
Jump if a column value does not match a pattern |
branch_col_and_mask_eq_mask() |
Jump if a column value AND ed with a bitmask is equal
to the bitmask |
branch_col_and_mask_ne_mask() |
Jump if a column value AND ed with a bitmask is not
equal to the bitmask |
branch_col_and_mask_eq_zero() |
Jump if a column value AND ed with a bitmask is equal
to 0
|
branch_col_and_mask_ne_zero() |
Jump if a column value AND ed with a bitmask is not
equal to 0
|
interpret_exit_ok() |
Return a row as part of the result |
interpret_exit_nok() |
Do not return a row as part of the result |
interpret_last_row() |
Return a row as part of the result, and do not check any more rows in this fragment |
add_val() |
Add a value to a table column value |
sub_val() |
Subtract a value from a table column value |
def_sub() |
Define a subroutine |
call_sub() |
Call a subroutine |
ret_sub() |
Return from a subroutine |
finalise() |
Completes interpreted program and prepares it for use |
getTable() |
Gets the table on which the program is defined |
getNdbError() |
Gets the most recent error associated with this
NdbInterpretedCode object |
getWordsUsed() |
Gets the number of words used in the buffer |
For detailed descriptions, signatures, and examples of use for each
of these methods, see
Section 2.3.14.1, “NdbInterpretedCode
Methods”.
Types. This class defines no public types.
Class diagram.
This diagram shows all the available methods of the
NdbInterpretedCode
class: