Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor refactoring

  • Loading branch information...
commit e0a1e741733b23dbbf2a10c6de8bfbe7d57fa258 1 parent 4570dc3
@ryanking ryanking authored
Showing with 27 additions and 58 deletions.
  1. +1 −29 lib/cassandra/cassandra.rb
  2. +26 −29 lib/cassandra/columns.rb
View
30 lib/cassandra/cassandra.rb
@@ -110,35 +110,7 @@ def insert(column_family, key, hash, options = {})
@batch ? @batch << [mutation_map, options[:consistency]] : _mutate(mutation_map, options[:consistency])
end
- def _standard_insert_mutation(column_family, column_name, value, timestamp)
- CassandraThrift::Mutation.new(
- :column_or_supercolumn => CassandraThrift::ColumnOrSuperColumn.new(
- :column => CassandraThrift::Column.new(
- :name => column_name_class(column_family).new(column_name).to_s,
- :value => value,
- :timestamp => timestamp
- )
- )
- )
- end
-
- def _super_insert_mutation(column_family, super_column_name, sub_columns, timestamp)
- CassandraThrift::Mutation.new(:column_or_supercolumn =>
- CassandraThrift::ColumnOrSuperColumn.new(
- :super_column => CassandraThrift::SuperColumn.new(
- :name => column_name_class(column_family).new(super_column_name).to_s,
- :columns => sub_columns.collect { |sub_column_name, sub_column_value|
- CassandraThrift::Column.new(
- :name => sub_column_name_class(column_family).new(sub_column_name).to_s,
- :value => sub_column_value.to_s,
- :timestamp => timestamp
- )
- }
- )
- )
- )
- end
-
+
## Delete
# _mutate the element at the column_family:key:[column]:[sub_column]
View
55 lib/cassandra/columns.rb
@@ -71,39 +71,36 @@ def columns_to_hash_for_classes(columns, column_name_class, sub_column_name_clas
c.value
end
end
- hash
+ hash
end
- def hash_to_cfmap(column_family, hash, timestamp)
- h = Hash.new
- if is_super(column_family)
- h[column_family] = hash.collect do |super_column_name, sub_columns|
- CassandraThrift::ColumnOrSuperColumn.new(
- :super_column => CassandraThrift::SuperColumn.new(
- :name => column_name_class(column_family).new(super_column_name).to_s,
- :columns => sub_columns.collect { |sub_column_name, sub_column_value|
- CassandraThrift::Column.new(
- :name => sub_column_name_class(column_family).new(sub_column_name).to_s,
- :value => sub_column_value.to_s,
- :timestamp => timestamp
- )
- }
- )
+ def _standard_insert_mutation(column_family, column_name, value, timestamp)
+ CassandraThrift::Mutation.new(
+ :column_or_supercolumn => CassandraThrift::ColumnOrSuperColumn.new(
+ :column => CassandraThrift::Column.new(
+ :name => column_name_class(column_family).new(column_name).to_s,
+ :value => value,
+ :timestamp => timestamp
)
- end
- else
- h[column_family] = hash.collect do |column_name, value|
- CassandraThrift::ColumnOrSuperColumn.new(
- :column => CassandraThrift::Column.new(
- :name => column_name_class(column_family).new(column_name).to_s,
- :value => value,
- :timestamp => timestamp
- )
- )
- end
- end
- h
+ )
+ )
end
+ def _super_insert_mutation(column_family, super_column_name, sub_columns, timestamp)
+ CassandraThrift::Mutation.new(:column_or_supercolumn =>
+ CassandraThrift::ColumnOrSuperColumn.new(
+ :super_column => CassandraThrift::SuperColumn.new(
+ :name => column_name_class(column_family).new(super_column_name).to_s,
+ :columns => sub_columns.collect { |sub_column_name, sub_column_value|
+ CassandraThrift::Column.new(
+ :name => sub_column_name_class(column_family).new(sub_column_name).to_s,
+ :value => sub_column_value.to_s,
+ :timestamp => timestamp
+ )
+ }
+ )
+ )
+ )
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.