This class inherits the class “TokyoTyrant::RDB”. All methods are specific to servers of the table database.%%
Generate a unique ID number.%% The return value is the new unique ID number or -1 on failure.%%
# File tokyotyrant.rb, line 1254 1254: def genuid() 1255: rv = misc("genuid", Array::new, 0) 1256: return 1 if !rv 1257: return rv[0] 1258: end
Retrieve a record.%% `pkey’ specifies the primary key.%% If successful, the return value is a hash of the columns of the corresponding record. `nil’ is returned if no record corresponds.%%
# File tokyotyrant.rb, line 1200 1200: def get(pkey) 1201: pkey = _argstr(pkey) 1202: args = Array::new 1203: args.push(pkey) 1204: rv = misc("get", args) 1205: if !rv 1206: @ecode = ENOREC if @ecode == EMISC 1207: return nil 1208: end 1209: cols = Hash::new() 1210: cnum = rv.length 1211: cnum -= 1 1212: i = 0 1213: while i < cnum 1214: cols[rv[i]] = rv[i+1] 1215: i += 2 1216: end 1217: return cols 1218: end
Retrieve records.%% `recs’ specifies a hash containing the retrieval keys. As a result of this method, keys existing in the database have the corresponding columns and keys not existing in the database are removed.%% If successful, the return value is the number of retrieved records or -1 on failure.%% Due to the protocol restriction, this method can not handle records with binary columns including the “0“ chracter.%%
# File tokyotyrant.rb, line 1223 1223: def mget(recs) 1224: rv = super(recs) 1225: return 1 if rv < 0 1226: recs.each do |pkey, value| 1227: cols = Hash::new 1228: cary = value.split("\00"") 1229: cnum = cary.size - 1 1230: i = 0 1231: while i < cnum 1232: cols[cary[i]] = cary[i+1] 1233: i += 2 1234: end 1235: recs[pkey] = cols 1236: end 1237: return rv 1238: end
Remove a record.%% `pkey’ specifies the primary key.%% If successful, the return value is true, else, it is false.%%
# File tokyotyrant.rb, line 1186 1186: def out(pkey) 1187: pkey = _argstr(pkey) 1188: args = Array::new 1189: args.push(pkey) 1190: rv = misc("out", args, 0) 1191: if !rv 1192: @ecode = ENOREC if @ecode == EMISC 1193: return false 1194: end 1195: return true 1196: end
Store a record.%% `pkey’ specifies the primary key.%% `cols’ specifies a hash containing columns.%% If successful, the return value is true, else, it is false.%% If a record with the same key exists in the database, it is overwritten.%%
# File tokyotyrant.rb, line 1133 1133: def put(pkey, cols) 1134: pkey = _argstr(pkey) 1135: raise ArgumentError if !cols.is_a?(Hash) 1136: args = Array::new 1137: args.push(pkey) 1138: cols.each do |ckey, cvalue| 1139: args.push(ckey) 1140: args.push(cvalue) 1141: end 1142: rv = misc("put", args, 0) 1143: return rv ? true : false 1144: end
Concatenate columns of the existing record.%% `pkey’ specifies the primary key.%% `cols’ specifies a hash containing columns.%% If successful, the return value is true, else, it is false.%% If there is no corresponding record, a new record is created.%%
# File tokyotyrant.rb, line 1171 1171: def putcat(pkey, cols) 1172: pkey = _argstr(pkey) 1173: raise ArgumentError if !cols.is_a?(Hash) 1174: args = Array::new 1175: args.push(pkey) 1176: cols.each do |ckey, cvalue| 1177: args.push(ckey) 1178: args.push(cvalue) 1179: end 1180: rv = misc("putcat", args, 0) 1181: return rv ? true : false 1182: end
Store a new record.%% `pkey’ specifies the primary key.%% `cols’ specifies a hash containing columns.%% If successful, the return value is true, else, it is false.%% If a record with the same key exists in the database, this method has no effect.%%
# File tokyotyrant.rb, line 1150 1150: def putkeep(pkey, cols) 1151: pkey = _argstr(pkey) 1152: raise ArgumentError if !cols.is_a?(Hash) 1153: args = Array::new 1154: args.push(pkey) 1155: cols.each do |ckey, cvalue| 1156: args.push(ckey) 1157: args.push(cvalue) 1158: end 1159: rv = misc("putkeep", args, 0) 1160: if !rv 1161: @ecode = EKEEP if @ecode == EMISC 1162: return false 1163: end 1164: return true 1165: end
Set a column index.%% `name’ specifies the name of a column. If the name of an existing index is specified, the index is rebuilt. An empty string means the primary key.%% `type’ specifies the index type: `TokyoTyrant::RDBTBL::ITLEXICAL’ for lexical string, `TokyoTyrant::RDBTBL::ITDECIMAL’ for decimal string, `TokyoTyrant::RDBTBL::ITTOKEN’ for token inverted index, `TokyoTyrant::RDBTBL::ITQGRAM’ for q-gram inverted index. If it is `TokyoTyrant::RDBTBL::ITOPT’, the index is optimized. If it is `TokyoTyrant::RDBTBL::ITVOID’, the index is removed. If `TokyoTyrant::RDBTBL::ITKEEP’ is added by bitwise-or and the index exists, this method merely returns failure.%% If successful, the return value is true, else, it is false.%%
# File tokyotyrant.rb, line 1243 1243: def setindex(name, type) 1244: name = _argstr(name) 1245: type = _argnum(type) 1246: args = Array::new 1247: args.push(name) 1248: args.push(type) 1249: rv = misc("setindex", args, 0) 1250: return rv ? true : false 1251: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.