In Files

Class/Module Index [+]

Quicksearch

TokyoTyrant::RDBTBL

This class inherits the class “TokyoTyrant::RDB”. All methods are specific to servers of the table database.%%

Constants

ITDECIMAL

index type: decimal string

ITKEEP

index type: keep existing index

ITLEXICAL

index type: lexical string

ITOPT

index type: optimize

ITQGRAM

index type: q-gram inverted index

ITTOKEN

index type: token inverted index

ITVOID

index type: void

Public Instance Methods

genuid() click to toggle source

Generate a unique ID number.%% The return value is the new unique ID number or -1 on failure.%%

# File tokyotyrant.rb, line 1254
def genuid()
  rv = misc("genuid", Array::new, 0)
  return -1 if !rv
  return rv[0]
end
get(pkey) click to toggle source

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
def get(pkey)
  pkey = _argstr(pkey)
  args = Array::new
  args.push(pkey)
  rv = misc("get", args)
  if !rv
    @ecode = ENOREC if @ecode == EMISC
    return nil
  end
  cols = Hash::new()
  cnum = rv.length
  cnum -= 1
  i = 0
  while i < cnum
    cols[rv[i]] = rv[i+1]
    i += 2
  end
  return cols
end
mget(recs) click to toggle source

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
def mget(recs)
  rv = super(recs)
  return -1 if rv < 0
  recs.each do |pkey, value|
    cols = Hash::new
    cary = value.split("\00"")
    cnum = cary.size - 1
    i = 0
    while i < cnum
      cols[cary[i]] = cary[i+1]
      i += 2
    end
    recs[pkey] = cols
  end
  return rv
end
out(pkey) click to toggle source

Remove a record.%% `pkey’ specifies the primary key.%% If successful, the return value is true, else, it is false.%%

# File tokyotyrant.rb, line 1186
def out(pkey)
  pkey = _argstr(pkey)
  args = Array::new
  args.push(pkey)
  rv = misc("out", args, 0)
  if !rv
    @ecode = ENOREC if @ecode == EMISC
    return false
  end
  return true
end
put(pkey, cols) click to toggle source

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
def put(pkey, cols)
  pkey = _argstr(pkey)
  raise ArgumentError if !cols.is_a?(Hash)
  args = Array::new
  args.push(pkey)
  cols.each do |ckey, cvalue|
    args.push(ckey)
    args.push(cvalue)
  end
  rv = misc("put", args, 0)
  return rv ? true : false
end
putcat(pkey, cols) click to toggle source

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
def putcat(pkey, cols)
  pkey = _argstr(pkey)
  raise ArgumentError if !cols.is_a?(Hash)
  args = Array::new
  args.push(pkey)
  cols.each do |ckey, cvalue|
    args.push(ckey)
    args.push(cvalue)
  end
  rv = misc("putcat", args, 0)
  return rv ? true : false
end
putkeep(pkey, cols) click to toggle source

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
def putkeep(pkey, cols)
  pkey = _argstr(pkey)
  raise ArgumentError if !cols.is_a?(Hash)
  args = Array::new
  args.push(pkey)
  cols.each do |ckey, cvalue|
    args.push(ckey)
    args.push(cvalue)
  end
  rv = misc("putkeep", args, 0)
  if !rv
    @ecode = EKEEP if @ecode == EMISC
    return false
  end
  return true
end
setindex(name, type) click to toggle source

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
def setindex(name, type)
  name = _argstr(name)
  type = _argnum(type)
  args = Array::new
  args.push(name)
  args.push(type)
  rv = misc("setindex", args, 0)
  return rv ? true : false
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.