Module: CassandraObject::Schema::Tasks

Included in:
CassandraObject::Schema
Defined in:
lib/cassandra_object/schema/tasks.rb

Instance Method Summary collapse

Instance Method Details

#dump(io) ⇒ Object



4
5
6
7
8
9
# File 'lib/cassandra_object/schema/tasks.rb', line 4

def dump(io)
  table_names.each do |column_family|
    io.puts run_command("DESCRIBE COLUMNFAMILY #{column_family}")
    io.puts
  end
end

#load(io) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cassandra_object/schema/tasks.rb', line 11

def load(io)
  current_cql = ''

  io.each_line do |line|
    next if line.blank?

    current_cql << line.rstrip

    if current_cql =~ /;$/
      keyspace_execute current_cql
      current_cql = ''
    end
  end
end

#table_namesObject



26
27
28
# File 'lib/cassandra_object/schema/tasks.rb', line 26

def table_names
  run_command('DESCRIBE COLUMNFAMILIES').split.sort
end