Class: Cassandra
Defined Under Namespace
Modules: Protocol
Instance Method Summary collapse
-
#get_indexed_slices(column_family, index_clause, *columns_and_options) ⇒ Object
Monkey patch get_indexed_slices so that it returns OrderedHash, otherwise cannot determine next start key when getting in chunks.
-
#get_range_single(column_family, options = {}) ⇒ Object
Monkey patch get_range_single so that it can return a array of key slices rather than converting it to a Hash.
Instance Method Details
#get_indexed_slices(column_family, index_clause, *columns_and_options) ⇒ Object
Monkey patch get_indexed_slices so that it returns OrderedHash, otherwise cannot determine next start key when getting in chunks
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/right_support/db/cassandra_model.rb', line 83 def get_indexed_slices(column_family, index_clause, *) return false if Cassandra.VERSION.to_f < 0.7 column_family, columns, _, = extract_and_validate_params(column_family, [], , READ_DEFAULTS.merge(:key_count => 100, :key_start => "")) if index_clause.class != CassandraThrift::IndexClause index_expressions = index_clause.collect do |expression| create_index_expression(expression[:column_name], expression[:value], expression[:comparison]) end index_clause = create_index_clause(index_expressions, [:key_start], [:key_count]) end key_slices = _get_indexed_slices(column_family, index_clause, columns, [:count], [:start], [:finish], [:reversed], [:consistency]) key_slices.inject(OrderedHash.new) { |h, key_slice| h[key_slice.key] = key_slice.columns; h } end |
#get_range_single(column_family, options = {}) ⇒ Object
Monkey patch get_range_single so that it can return a array of key slices rather than converting it to a Hash
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/right_support/db/cassandra_model.rb', line 49 def get_range_single(column_family, = {}) return_empty_rows = .delete(:return_empty_rows) || false slices_please = .delete(:slices_not_hash) || false column_family, _, _, = extract_and_validate_params(column_family, "", [], READ_DEFAULTS.merge(:start_key => '', :finish_key => '', :key_count => 100, :columns => nil, :reversed => false ) ) results = _get_range(column_family, [:start_key].to_s, [:finish_key].to_s, [:key_count], [:columns], [:start].to_s, [:finish].to_s, [:count], [:consistency], [:reversed]) unless slices_please multi_key_slices_to_hash(column_family, results, return_empty_rows) else results end end |