1

行キーがcolumnfamilyに存在するかどうかを確認する次の関数があります。次のコマンドを使用して、SELECTステートメントから結果を取得しました。インデックス=db.execute( "SELECT * FROM#{$ configuration} WHERE key ='#{index_config}'")

上記のselectステートメントで何も見つからないと言うには、インデックスの結果をどうすればよいですか?

以前は「indexes.size==0の場合はfalseを返す」を使用していましたが、機能しません。現在行が見つかりましたが、indexes.sizeは1です。

「index[1].to_s.empty?の場合はfalseを返す」をチェックしようとしています。しかし、それも機能しません。

def self.index_config_exists?(config, keyspace, columnfamily)
index_config = "#{keyspace}_#{columnfamily}_#{config}_idx"
db = CassandraCQL::Database.new($cassandra_host, {:keyspace => $indexing})
indexes = db.execute("SELECT * FROM #{$configuration} WHERE key = '#{index_config}'")
db.disconnect!()

indexes.fetch {|index|
  # check if the index configuration not empty
  puts index.to_s
  puts index[0]
  puts index[1].class
  return false if index[1].to_s.empty?
}

return true

終わり

4

0 に答える 0