class Cassandra::Cluster::Schema::Fetchers::V2_2_x
Constants
- SELECT_AGGREGATE
- SELECT_AGGREGATES
- SELECT_FUNCTION
- SELECT_FUNCTIONS
- SELECT_KEYSPACE_AGGREGATES
- SELECT_KEYSPACE_FUNCTIONS
Public Instance Methods
parse_argument_types(connection, keyspace_name, argument_types)
click to toggle source
parse an array of string argument types and return an array of [Cassandra::Type]s. @param connection a connection to a Cassandra
node. @param keyspace_name [String] name of the keyspace. @param argument_types [Array<String>] array of argument types. @return [Array<Cassandra::Type>] array of parsed types.
# File lib/cassandra/cluster/schema/fetchers.rb 851 def parse_argument_types(connection, keyspace_name, argument_types) 852 argument_types.map do |argument_type| 853 @type_parser.parse(argument_type).results.first.first 854 end 855 end
Private Instance Methods
create_aggregate(aggregate_data, functions)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 885 def create_aggregate(aggregate_data, functions) 886 keyspace_name = aggregate_data['keyspace_name'] 887 aggregate_name = aggregate_data['aggregate_name'] 888 aggregate_type = 889 @type_parser.parse(aggregate_data['return_type']).results.first.first 890 argument_types = aggregate_data['argument_types'].map do |fqcn| 891 @type_parser.parse(fqcn).results.first.first 892 end.freeze 893 state_type = 894 @type_parser.parse(aggregate_data['state_type']).results.first.first 895 initial_state = Util.encode_object( 896 Protocol::Coder.read_value_v4( 897 Protocol::CqlByteBuffer.new.append_bytes(aggregate_data['initcond']), 898 state_type, nil 899 ) 900 ) 901 902 # The state-function takes arguments: first the stype, then the args of the aggregate. 903 state_function = functions.get(aggregate_data['state_func'], 904 [state_type].concat(argument_types)) 905 906 # The final-function takes an stype argument. 907 final_function = functions.get(aggregate_data['final_func'], 908 [state_type]) 909 910 Aggregate.new(keyspace_name, 911 aggregate_name, 912 aggregate_type, 913 argument_types, 914 state_type, 915 initial_state, 916 state_function, 917 final_function) 918 end
create_function(function_data)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 859 def create_function(function_data) 860 keyspace_name = function_data['keyspace_name'] 861 function_name = function_data['function_name'] 862 function_lang = function_data['language'] 863 function_type = 864 @type_parser.parse(function_data['return_type']).results.first.first 865 function_body = function_data['body'] 866 called_on_null = function_data['called_on_null_input'] 867 868 arguments = [] 869 870 Array(function_data['argument_names']) 871 .zip(Array(function_data['argument_types'])) do |argument_name, fqcn| 872 argument_type = @type_parser.parse(fqcn).results.first.first 873 arguments << Argument.new(argument_name, argument_type) 874 end 875 876 Cassandra::Function.new(keyspace_name, 877 function_name, 878 function_lang, 879 function_type, 880 arguments, 881 function_body, 882 called_on_null) 883 end
select_aggregate(connection, keyspace_name, aggregate_name, aggregate_args)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 946 def select_aggregate(connection, keyspace_name, aggregate_name, aggregate_args) 947 params = [keyspace_name, aggregate_name, aggregate_args.map(&:to_s)] 948 hints = [Types.varchar, Types.varchar, Types.list(Types.varchar)] 949 send_select_request(connection, SELECT_AGGREGATE, params, hints) 950 end
select_aggregates(connection)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 924 def select_aggregates(connection) 925 send_select_request(connection, SELECT_AGGREGATES) 926 end
select_function(connection, keyspace_name, function_name, function_args)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 940 def select_function(connection, keyspace_name, function_name, function_args) 941 params = [keyspace_name, function_name, function_args.map(&:to_s)] 942 hints = [Types.varchar, Types.varchar, Types.list(Types.varchar)] 943 send_select_request(connection, SELECT_FUNCTION, params, hints) 944 end
select_functions(connection)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 920 def select_functions(connection) 921 send_select_request(connection, SELECT_FUNCTIONS) 922 end
select_keyspace_aggregates(connection, keyspace_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 934 def select_keyspace_aggregates(connection, keyspace_name) 935 params = [keyspace_name] 936 hints = [Types.varchar] 937 send_select_request(connection, SELECT_KEYSPACE_AGGREGATES, params, hints) 938 end
select_keyspace_functions(connection, keyspace_name)
click to toggle source
# File lib/cassandra/cluster/schema/fetchers.rb 928 def select_keyspace_functions(connection, keyspace_name) 929 params = [keyspace_name] 930 hints = [Types.varchar] 931 send_select_request(connection, SELECT_KEYSPACE_FUNCTIONS, params, hints) 932 end