Class TupleBuilder
This class manages the creation of a Tuple Tuple. It is advise to reuse it for massive data management to gain a better perfomance.
To create an instance of this class, either a Table or a plain tuple format must be provided.
This class allows the creation of all kinds of Tuples. These are Table tuplesbuild(Table), Index tuplesbuild(Index), key tuples buildKey(Table) and delta tuples buildDelta(Table).
This class provides the neccesary methods to set the field values
TupleBuilder builder = new TupleBuilder(table);
builder.add(0, "my location").add(1, 555).add(2, "aname").add(3, 555);
lxapi.Tuple tuple = builder.build(table);
builder.addIgnore(0).add(1, 666).add(2, "aname").addNull(3);
tuple = builder.build(table);</code></pre>
TupleBuilder keybuilder = new TupleBuilder("i[k]");
keybuilder.add(0, 666);
lxapi.Tuple key = keybuilder.buildKey(table);
table = new Table(session, "delta table");
builder.add(1, -100);
table.upsert(builder.buildDelta(table));
builder.add(1, 50);</code></pre>
Inheritance
Inherited Members
Namespace: lxapi
Assembly: lxapi.dll
Syntax
public class TupleBuilder
Constructors
TupleBuilder(Table)
Create a tuple builder using table's format. Mainly used to build Table and Delta Tuples
Declaration
public TupleBuilder(Table lxtbl)
Parameters
Type | Name | Description |
---|---|---|
Table | lxtbl | table to get the format from |
TupleBuilder(String)
Create a tuple according to kivi format string. Mainly used to build Key and Index Tuples
A format string uses one character per field, showing its type, perhaps followed with options enclosed in '[]'. Known user field types are defined by these symbols and the character shown can be used to define them in a user format string.
type char spec
Tbool b int8_t (boolean)
Tbyte c int8_t
Tshort h int16_t
Tenum e int16_t (static name enumeration)
Tint i int32_t
Ttime t int32_t (total nb of seconds)
Tdate y int32_t (days since epoch)
Tfloat f float
Tstr s string field
Tdec r decimals (and big integers)
Tjson j JSON text
Tmem m raw bytes
Tlong l int64_t
Tts w int64_t, (time stamp in microseconds since epoch)
Tdouble d double
Field options can be written together (within '[]') or separated by commas or a space:
! adds the following text up to the end of the options as a user spec for the field. Its meaning is up to the user. Must be the last option.
B use the field for bloom filtering in the table.
b ask for a blob field. Valid only for string, memory, and JSON fields. Data may be placed in external storage, or not. See also x.
c flags the field as desired for column formats.
D flags the field as gone; implementation might actually remove the data for the field, or not. Tuples still carry the field, perhaps as a null value, for consistency.
d flags the field as a delta field for adding values. Delta decimals require a number.number option too.
dm flags the field as a delta field for min value.
dM flags the field as a delta field for max value.
e flags the (string) field as enumerable at run time (dictionary)
i flags the (string) field as case insensitive
k flags the field as a key field. The position in the key (counting from 0) should follow right after the option (no spaces). If no position is given, the first unused one is used.
ks flags the field as a key field that is a split-point field. The position in the key (counting from 0) should follow right after the option (no spaces). Split fields must be at the end of
the key.
h flags the field as hashed one to compute the value of a hash field. It must be a key field.
H flags the field as a hash field computed from hashed fields. It must be a key field.
l shows that a string field uses the locale with the name that follows from the flag up to the end of the options or the start of the user spec option. Thus, it must be the last option but
for the user spec. For timestamp fields, this flag shows that the user wants the local time.
n flags the field as non-null
u flags the (string) field as always upper case. But see the note below.
x ask for a blob field with external storage. Valid only for string, memory, and JSON fields. Like b, but data will always be placed in external storage.
=number
field corresponds to the given field number in previous formats in kv order. But see metachgfmt(3) for further details.
number a number sets the maximum size desired for a string or memory field, or the number of decimal positions for decimals. The first character not a digit terminates this option.
number.number
A number with a decimal sets the maximum number of digits for a decimal and the desired number of decimal positions. This is to be used for delta decimal fields, in most other cases deci‐
mals may shrink and grow in size without much trouble.
Declaration
public TupleBuilder(string ufmt)
Parameters
Type | Name | Description |
---|---|---|
System.String | ufmt | kivi format string |
Fields
kvTplBuilder
Tuple Builder Handle
Declaration
public readonly IntPtr kvTplBuilder
Field Value
Type | Description |
---|---|
System.IntPtr |
table
table the format belongs to when any
Declaration
public readonly Table table
Field Value
Type | Description |
---|---|
Table |
Methods
add(Tuple)
Add the tuple's columns values
Declaration
public TupleBuilder add(Tuple tuple)
Parameters
Type | Name | Description |
---|---|---|
Tuple | tuple | tuple |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, Decimal)
Add decimal value to column
Declaration
public TupleBuilder add(int userposition, Decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
Decimal | value | value |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, Double, Int32)
Add double value to column
Declaration
public TupleBuilder add(int userposition, double value, int ndec = 2)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
System.Double | value | value |
System.Int32 | ndec | number of decimals when decimal column |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, Int16)
Add short value to column
Declaration
public TupleBuilder add(int userposition, short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
System.Int16 | value | value |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, Int32)
Add integer value to column
Declaration
public TupleBuilder add(int userposition, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
System.Int32 | value | value |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, Int64)
Add long value to column
Declaration
public TupleBuilder add(int userposition, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
System.Int64 | value | value |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, Single, Int32)
Add float value to column
Declaration
public TupleBuilder add(int userposition, float value, int ndec = 2)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
System.Single | value | value |
System.Int32 | ndec | number of decimals when decimal column |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Int32, String, Int32)
Add double value to column
Declaration
public TupleBuilder add(int userposition, string value, int ndec = 2)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
System.String | value | value |
System.Int32 | ndec | number of decimals when decimal column |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
add(Object[])
Add an array of values
Declaration
public TupleBuilder add(object[] arr)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | arr | values |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
addIgnore(Int32)
Add ignore value to column
Declaration
public TupleBuilder addIgnore(int userposition)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
addInitValue(Int32)
Add default value to column
Declaration
public TupleBuilder addInitValue(int userposition)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
addNull(Int32)
Add null value to column
Declaration
public TupleBuilder addNull(int userposition)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userposition | column position |
Returns
Type | Description |
---|---|
TupleBuilder | modified TupleBuilder |
build(Index)
Build tuple for index
Declaration
public Tuple build(Index index)
Parameters
Type | Name | Description |
---|---|---|
Index | index |
Returns
Type | Description |
---|---|
Tuple |
build(Table)
Build tuple for table
Declaration
public Tuple build(Table table)
Parameters
Type | Name | Description |
---|---|---|
Table | table |
Returns
Type | Description |
---|---|
Tuple |
buildDelta(Table)
Build delta tuple for table
Declaration
public Tuple buildDelta(Table table)
Parameters
Type | Name | Description |
---|---|---|
Table | table |
Returns
Type | Description |
---|---|
Tuple |
buildKey(Table)
Build key tuple for table
Declaration
public Tuple buildKey(Table table)
Parameters
Type | Name | Description |
---|---|---|
Table | table |
Returns
Type | Description |
---|---|
Tuple |
fieldType(Int32)
Column type
Declaration
public LxTypes fieldType(int fno)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fno | column position |
Returns
Type | Description |
---|---|
LxTypes |
Finalize()
Release builder Handle
Declaration
protected void Finalize()