motusReserveKeys: Reserve a block of consecutive primary keys in a motus...

Description Usage Arguments Value Note Author(s) Examples

Description

This function returns the first key value in a block of N consecutive key values for the specified table. These key values are atomically reserved, and guaranteed not to collide with key values for any other receiver, provided every process updating the database uses this function. This permits multiple processes to be pushing data to motus (via populating the transfer tables) at the same time.

Usage

1
motusReserveKeys(table, n, maxKeyTable = "maxKeys")

Arguments

table

name of the table in which to reserve keys.

n

number of consecutive keys to reserve. If negative, the keys are reserved in descending order, starting at the smallest (i.e. most negative) available value. For a given table, keys should always be reserved with n of the same sign; i.e. keys should always be allocated ascending order, or always allocated in descending order.

maxKeyTable

name of the table in which maximum key values are recorded; this must have (at least) these fields:

  • tableName UNIQUE CHAR name of table

  • maxKey BIGINT maximum magnitude of a key in the table

Default: "maxKeys"

Value

the first key value in the block. For positive n, this is the lowest key value in the block. For negative n, this is the highest key value. i.e. in both cases, keys are allocated in order from closest to 0 to farther from 0.

Note

this function uses the table maxKeys to track the maximum (magnitude of a) key in any table of interest. The implementation is cooperative: all keys in any table this function is used for must be obtained by using this function.

Author(s)

John Brzustowski jbrzusto@REMOVE_THIS_PART_fastmail.fm

Examples

1
2
## return the first key in a block of 200 reserved in the batches table
motusReserveKeys("batches", 200)

jbrzusto/motus-R-package documentation built on May 18, 2019, 7:03 p.m.