Class: TokyoTyrant::RDBQRY

Class | TokyoTyrant::RDBQRY
In: | tokyotyrant.rb
Parent: | Object

This class is a helper for the class "TokyoTyrant::RDBTBL".

### Methods

_args addcond hint metasearch new search searchcount searchget searchout setlimit setorder

### Constants

QCSTREQ | = | 0 |  | query condition: string is equal to
QCSTRINC | = | 1 |  | query condition: string is included in
QCSTRBW | = | 2 |  | query condition: string begins with
QCSTREW | = | 3 |  | query condition: string ends with
QCSTRAND | = | 4 |  | query condition: string includes all tokens in
QCSTROR | = | 5 |  | query condition: string includes at least one token in
QCSTROREQ | = | 6 |  | query condition: string is equal to at least one token in
QCSTRRX | = | 7 |  | query condition: string matches regular expressions of
QCNUMEQ | = | 8 |  | query condition: number is equal to
QCNUMGT | = | 9 |  | query condition: number is greater than
QCNUMGE | = | 10 |  | query condition: number is greater than or equal to
QCNUMLT | = | 11 |  | query condition: number is less than
QCNUMLE | = | 12 |  | query condition: number is less than or equal to
QCNUMBT | = | 13 |  | query condition: number is between two tokens of
QCNUMOREQ | = | 14 |  | query condition: number is equal to at least one token in
QCFTSPH | = | 15 |  | query condition: full-text search with the phrase of
QCFTSAND | = | 16 |  | query condition: full-text search with all tokens in
QCFTSOR | = | 17 |  | query condition: full-text search with at least one token in
QCFTSEX | = | 18 |  | query condition: full-text search with the compound expression of
QCNEGATE | = | 1 << 24 |  | query condition: negation flag
QCNOIDX | = | 1 << 25 |  | query condition: no index flag
QOSTRASC | = | 0 |  | order type: string ascending
QOSTRDESC | = | 1 |  | order type: string descending
QONUMASC | = | 2 |  | order type: number ascending
QONUMDESC | = | 3 |  | order type: number descending
MSUNION | = | 0 |  | set operation type: union
MSISECT | = | 1 |  | set operation type: intersection
MSDIFF | = | 2 |  | set operation type: difference

### Public Class methods

new(rdb)

Create a query object.
`rdb' specifies the remote database object.
The return value is the new query object.

### Public Instance methods

addcond(name, op, expr)

Add a narrowing condition.
`name' specifies the name of a column. An empty string means the primary key.
`op' specifies an operation type: `TokyoTyrant::RDBQRY::QCSTREQ' for string which is equal to the expression, `TokyoTyrant::RDBQRY::QCSTRINC' for string which is included in the expression, `TokyoTyrant::RDBQRY::QCSTRBW' for string which begins with the expression, `TokyoTyrant::RDBQRY::QCSTREW' for string which ends with the expression, `TokyoTyrant::RDBQRY::QCSTRAND' for string which includes all tokens in the expression, `TokyoTyrant::RDBQRY::QCSTROR' for string which includes at least one token in the expression, `TokyoTyrant::RDBQRY::QCSTROREQ' for string which is equal to at least one token in the expression, `TokyoTyrant::RDBQRY::QCSTRRX' for string which matches regular expressions of the expression, `TokyoTyrant::RDBQRY::QCNUMEQ' for number which is equal to the expression, `TokyoTyrant::RDBQRY::QCNUMGT' for number which is greater than the expression, `TokyoTyrant::RDBQRY::QCNUMGE' for number which is greater than or equal to the expression, `TokyoTyrant::RDBQRY::QCNUMLT' for number which is less than the expression, `TokyoTyrant::RDBQRY::QCNUMLE' for number which is less than or equal to the expression, `TokyoTyrant::RDBQRY::QCNUMBT' for number which is between two tokens of the expression, `TokyoTyrant::RDBQRY::QCNUMOREQ' for number which is equal to at least one token in the expression, `TokyoTyrant::RDBQRY::QCFTSPH' for full-text search with the phrase of the expression, `TokyoTyrant::RDBQRY::QCFTSAND' for full-text search with all tokens in the expression, `TokyoTyrant::RDBQRY::QCFTSOR' for full-text search with at least one token in the expression, `TokyoTyrant::RDBQRY::QCFTSEX' for full-text search with the compound expression. All operations can be flagged by bitwise-or: `TokyoTyrant::RDBQRY::QCNEGATE' for negation, `TokyoTyrant::RDBQRY::QCNOIDX' for using no index.
`expr' specifies an operand exression.
The return value is always `nil'.

hint()

Get the hint string.
The return value is the hint string.

metasearch(others, type = MSUNION)

Retrieve records with multiple query objects and get the set of the result.
`others' specifies an array of the query objects except for the self object.
`type' specifies a set operation type: `TokyoTyrant::RDBQRY::MSUNION' for the union set, `TokyoTyrant::RDBQRY::MSISECT' for the intersection set, `TokyoTyrant::RDBQRY::MSDIFF' for the difference set. If it is not defined, `TokyoTyrant::RDBQRY::MSUNION' is specified.
The return value is an array of the primary keys of the corresponding records. This method does never fail. It returns an empty array even if no record corresponds.
If the first query object has the order setting, the result array is sorted by the order.

search()

Execute the search.
The return value is an array of the primary keys of the corresponding records. This method does never fail. It returns an empty array even if no record corresponds.

searchcount()

Get the count of corresponding records.
The return value is the count of corresponding records or 0 on failure.

searchget(names = nil)

Get records corresponding to the search.
`names' specifies an array of column names to be fetched. An empty string means the primary key. If it is not defined, every column is fetched.
The return value is an array of column hashes of the corresponding records. This method does never fail. It returns an empty list even if no record corresponds.
Due to the protocol restriction, this method can not handle records with binary columns including the "\0" chracter.

searchout()

Remove each corresponding record.
If successful, the return value is true, else, it is false.

setlimit(max = -1, skip = -1)

Set the maximum number of records of the result.
`max' specifies the maximum number of records of the result. If it is not defined or negative, no limit is specified.
`skip' specifies the maximum number of records of the result. If it is not defined or not more than 0, no record is skipped.
The return value is always `nil'.

setorder(name, type = QOSTRASC)

Set the order of the result.
`name' specifies the name of a column. An empty string means the primary key.
`type' specifies the order type: `TokyoTyrant::RDBQRY::QOSTRASC' for string ascending, `TokyoTyrant::RDBQRY::QOSTRDESC' for string descending, `TokyoTyrant::RDBQRY::QONUMASC' for number ascending, `TokyoTyrant::RDBQRY::QONUMDESC' for number descending. If it is not defined, `TokyoTyrant::RDBQRY::QOSTRASC' is specified.
The return value is always `nil'.

### Protected Instance methods

_args()

Get the internal arguments.