bizstation / transactd

The high-speed and advanced NoSQL interface plugin for MySQL / MariaDB.
GNU General Public License v2.0
18 stars 1 forks source link

What's exactly mean reject(x) ? #33

Open rush2ko opened 8 years ago

rush2ko commented 8 years ago

sample data is below.

UserSN RegID Skin Exp 100000000 alpha 0 10000 100000001 drago 1 15000 100000002 major 0 12000 100000003 rush 3 11000 100000001 tenshot 0 10000 100000004 test01 0 20000 100000005 test02 2 18000 100000006 test03 0 10000

query.

q.select(_T("RegID")).where(_T("UserSN"), _T("="), 100000001).reject(1);

reject(0) ? or reject(1) ?

What is different reject(1) and reject(0) ?

bizstation commented 8 years ago

In this case, the result depends to two conditions.

reject is the termination condition of searching. If the number of non-matching records reaches to the number that is specified reject, searching will be finished.

Case 1: UserSN is the index, and use it for searching.

at.index(n).keyValue(100000001);

If you start searching with this code, searching will start at 100000001, in the order of index UserSN. Records other than 100000001 is not matched to the condition where(_T("UserSN"), _T("="), 100000001). The searching of Transactd detects that are there more records which matches to the condition, with specified index field. Then if the record other than 100000001 is found, searching will be finished regardless of reject value. In this case, reject value does not matter. But, reject(1) is better because the code will be easy-to-read.

Case 2: UserSN is not the index.

at.index(PrimaryKey).keyValue(0);

In this case, Transactd scan all records after the current record (keyValue(0)), in the order of PrimaryKey, until the termination condition of searching. If reject(1), and if the first record does not match to the condition, the searching will be finished. If reject(0), the termination condition of searching is disabled. Then Transactd scan all record to last of the table, and find matching records.

Difference of reject(0) and reject(0xffff)

Both of them mean that the termination condition of searching is disabled. Searching will be continued until last of the records. reject(0) returns the control to client regularly. reject(0xffff) does not do so.

documentation (in Japanese)