class Cassandra::Cluster::Schema::Fetchers::V2_0_x
Constants
- SELECT_KEYSPACE
- SELECT_KEYSPACE_COLUMNS
- SELECT_KEYSPACE_TABLES
- SELECT_KEYSPACE_TRIGGERS
- SELECT_TABLE
- SELECT_TABLE_COLUMNS
- SELECT_TABLE_TRIGGERS
- SELECT_TRIGGERS
Private Instance Methods
create_table(table_data, rows_columns, rows_indexes, rows_triggers)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 609 def create_table(table_data, rows_columns, rows_indexes, rows_triggers) 610 keyspace_name = table_data['keyspace_name'] 611 table_name = table_data['columnfamily_name'] 612 comparator = @type_parser.parse(table_data['comparator']) 613 clustering_size = 0 614 615 # Separate out partition-key, clustering columns, other columns. 616 partition_key = [] 617 clustering_columns = [] 618 clustering_order = [] 619 other_columns = [] 620 621 index_rows = [] 622 rows_columns.each do |row| 623 next if row['column_name'].empty? 624 625 column = create_column(row) 626 type = row['type'].to_s 627 ind = row['component_index'] || 0 628 629 case type.upcase 630 when 'PARTITION_KEY' 631 partition_key[ind] = column 632 when 'CLUSTERING_KEY' 633 clustering_columns[ind] = column 634 clustering_order[ind] = column.order 635 636 clustering_size += 1 637 else 638 other_columns << column 639 end 640 641 # In C* 2.0.x, index info is in the column metadata; rows_indexes is nil. 642 index_rows << [column, row] unless row['index_type'].nil? 643 end 644 645 compaction_strategy = create_compaction_strategy(table_data) 646 is_compact = (clustering_size != comparator.results.size - 1) || 647 !comparator.collections 648 table_options = 649 create_table_options(table_data, compaction_strategy, is_compact) 650 651 table = Cassandra::Table.new(@schema.keyspace(keyspace_name), 652 table_name, 653 partition_key, 654 clustering_columns, 655 other_columns, 656 table_options, 657 clustering_order, 658 table_data['id']) 659 660 # Create Index objects and add them to the table. 661 index_rows.each do |column, row| 662 create_index(table, column, row) 663 end 664 665 # Create Trigger objects and add them to the table. 666 rows_triggers.each do |row_trigger| 667 table.add_trigger(Cassandra::Trigger.new(table, 668 row_trigger['trigger_name'], 669 row_trigger['trigger_options'])) 670 end 671 672 table 673 end
create_table_options(table_data, compaction_strategy, is_compact)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 721 def create_table_options(table_data, compaction_strategy, is_compact) 722 compression_parameters = ::JSON.load(table_data['compression_parameters']) 723 if compression_parameters['sstable_compression'] 724 compression_parameters['sstable_compression'] 725 .slice!(COMPRESSION_PACKAGE_PREFIX) 726 end 727 Cassandra::ColumnContainer::Options.new( 728 table_data['comment'], 729 table_data['read_repair_chance'], 730 table_data['local_read_repair_chance'], 731 table_data['gc_grace_seconds'], 732 table_data['caching'], 733 table_data['bloom_filter_fp_chance'], 734 table_data['populate_io_cache_on_flush'], 735 table_data['memtable_flush_period_in_ms'], 736 table_data['default_time_to_live'], 737 table_data['speculative_retry'], 738 table_data['index_interval'], 739 table_data['replicate_on_write'], 740 nil, 741 nil, 742 compaction_strategy, 743 compression_parameters, 744 is_compact, 745 table_data['crc_check_chance'], 746 table_data['extensions'], 747 nil 748 ) 749 end
select_keyspace(connection, keyspace_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 679 def select_keyspace(connection, keyspace_name) 680 params = [keyspace_name] 681 hints = [Types.varchar] 682 send_select_request(connection, SELECT_KEYSPACE, params, hints) 683 end
select_keyspace_columns(connection, keyspace_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 691 def select_keyspace_columns(connection, keyspace_name) 692 params = [keyspace_name] 693 hints = [Types.varchar] 694 send_select_request(connection, SELECT_KEYSPACE_COLUMNS, params, hints) 695 end
select_keyspace_tables(connection, keyspace_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 685 def select_keyspace_tables(connection, keyspace_name) 686 params = [keyspace_name] 687 hints = [Types.varchar] 688 send_select_request(connection, SELECT_KEYSPACE_TABLES, params, hints) 689 end
select_keyspace_triggers(connection, keyspace_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 697 def select_keyspace_triggers(connection, keyspace_name) 698 params = [keyspace_name] 699 hints = [Types.varchar] 700 send_select_request(connection, SELECT_KEYSPACE_TRIGGERS, params, hints) 701 end
select_table(connection, keyspace_name, table_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 703 def select_table(connection, keyspace_name, table_name) 704 params = [keyspace_name, table_name] 705 hints = [Types.varchar, Types.varchar] 706 send_select_request(connection, SELECT_TABLE, params, hints) 707 end
select_table_columns(connection, keyspace_name, table_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 709 def select_table_columns(connection, keyspace_name, table_name) 710 params = [keyspace_name, table_name] 711 hints = [Types.varchar, Types.varchar] 712 send_select_request(connection, SELECT_TABLE_COLUMNS, params, hints) 713 end
select_table_triggers(connection, keyspace_name, table_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 715 def select_table_triggers(connection, keyspace_name, table_name) 716 params = [keyspace_name, table_name] 717 hints = [Types.varchar, Types.varchar] 718 send_select_request(connection, SELECT_TABLE_TRIGGERS, params, hints) 719 end
select_triggers(connection)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 675 def select_triggers(connection) 676 send_select_request(connection, SELECT_TRIGGERS) 677 end