Skip to content

Commit

Permalink
[CLIENT-1362]Replace predicate expressions with new Aerospike Express…
Browse files Browse the repository at this point in the history
…ion filters

[CLIENT-1479]  Support new expressions introduced in server version 5.6.
Predicate Expressions are not yet removed due to semver.

Expression filters are now supported on all commands, including `Client#get`, `Client#put`, `Client#delete`, `Client#operate`, `Client#scan`, `Client#query`, `Client#execute_udf`, etc.

    - Adds `Policy#filter_exp` and `Policy#fail_on_filtered_out`

    - Bit expressions: `Exp::Bit::` `#resize`, `#insert`, `#remove`, `#set`, `#or`, `#xor`, `#and`, `#not`, `#lshift`, `#rshift`, `#add`, `#subtract`, `#set_int`, `#get`, `#count`, `#lscan`, `#rscan`, `#get_int`, `#pack_math`, `#pack_get_int`, `#add_write`, `#add_read`

    - HLL Expressions: `Exp::HLL::` `#init`, `#add`, `#get_count`, `#get_union`, `#get_union_count`, `#get_intersect_count`, `#get_similarity`, `#describe`, `#may_contain`, `#add_write`, `#add_read`

    - Map Expressions: `Exp::Map::` `#put`, `#put_items`, `#increment`, `#clear`, `#remove_by_key`, `#remove_by_key_list`, `#remove_by_key_range`, `#remove_by_key_relative_index_range`, `#remove_by_value`, `#remove_by_value_list`, `#remove_by_value_range`, `#remove_by_value_relative_rank_range`, `#remove_by_value_relative_rank_range`, `#remove_by_index`, `#remove_by_index_range`, `#remove_by_rank`, `#remove_by_rank_range`, `#size`, `#get_by_key`, `#get_by_key_range`, `#get_by_key_list`, `#get_by_key_relative_index_range`, `#get_by_key_relative_index_range`, `#get_by_value`, `#get_by_value_range`, `#get_by_value_list`, `#get_by_value_relative_rank_range`, `#get_by_index`, `#get_by_index_range`, `#get_by_rank`, `#get_by_rank_range`, `#add_write`, `#add_read`, `#get_value_type`

    - List Expressions: `Exp::List::` `#append`, `#append_items`, `#insert`, `#insert_items`, `#increment`, `#set`, `#clear`, `#sort`, `#remove_by_value`, `#remove_by_value_list`, `#remove_by_value_range`, `#remove_by_value_relative_rank_range`, `#remove_by_index`, `#remove_by_index_range`, `#remove_by_rank`, `#remove_by_rank_range`, `#size`, `#get_by_value`, `#get_by_value_range`, `#get_by_value_list`, `#get_by_value_relative_rank_range`, `#get_by_index`, `#get_by_index_range`, `#get_by_index_range`, `#get_by_rank`, `#get_by_rank_range`, `#get_by_rank_range`, `#add_write`, `#add_read`, `#get_value_type`, `#pack_range_operation`

    - Read and Write operations: `Exp::Operation::` `#write`, `#read`
  • Loading branch information
khaf committed Nov 28, 2022
1 parent c43efee commit 6f05962
Show file tree
Hide file tree
Showing 32 changed files with 6,295 additions and 684 deletions.
26 changes: 15 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
source "https://rubygems.org"

group :test do
gem 'rspec', '~> 3.4'
gem 'codecov', require: false
gem "rspec", "~> 3.4"
gem "codecov", require: false
end

group :development do
gem "pry"
gem "stackprof", "~> 0.2.22"
gem "rspec-stackprof"
gem "hexdump", "~> 1.0"
gem "ruby-lsp", require: false
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rake', require: false
gem 'rubocop-rspec', require: false
gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false
end

gem 'bcrypt'
gem 'msgpack', '~> 1.2'
gem 'rake'
gem "bcrypt"
gem "msgpack", "~> 1.2"
gem "rake"

platforms :mri, :rbx do
gem 'openssl'
gem "openssl"
end

platforms :jruby do
gem 'jruby-openssl', '~> 0.10', require: 'openssl'
gem "jruby-openssl", "~> 0.10", require: "openssl"
end

gemspec
304 changes: 156 additions & 148 deletions lib/aerospike.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,163 +19,171 @@
require "stringio"
require "monitor"
require "timeout"
require 'resolv'
require 'msgpack'
require 'bcrypt'
require 'zlib'
require "resolv"
require "msgpack"
require "bcrypt"
require "zlib"

require 'aerospike/atomic/atomic'
require "aerospike/atomic/atomic"

require 'aerospike/client'
require 'aerospike/features'
require 'aerospike/utils/pool'
require 'aerospike/utils/connection_pool'
require 'aerospike/utils/packer'
require 'aerospike/utils/unpacker'
require 'aerospike/utils/buffer'
require 'aerospike/utils/string_parser'
require 'aerospike/host'
require 'aerospike/host/parse'
require 'aerospike/loggable'
require 'aerospike/record'
require 'aerospike/result_code'
require 'aerospike/version'
require 'aerospike/value/particle_type'
require 'aerospike/value/value'
require 'aerospike/command/single_command'
require 'aerospike/command/batch_direct_node'
require 'aerospike/command/batch_index_node'
require 'aerospike/command/field_type'
require 'aerospike/command/command'
require 'aerospike/command/execute_command'
require 'aerospike/command/write_command'
require 'aerospike/command/batch_item'
require 'aerospike/command/operate_command'
require 'aerospike/command/exists_command'
require 'aerospike/command/multi_command'
require 'aerospike/command/batch_direct_command'
require 'aerospike/command/batch_direct_exists_command'
require 'aerospike/command/batch_index_command'
require 'aerospike/command/batch_index_exists_command'
require 'aerospike/command/read_header_command'
require 'aerospike/command/touch_command'
require 'aerospike/command/read_command'
require 'aerospike/command/delete_command'
require 'aerospike/command/admin_command'
require 'aerospike/command/login_command'
require 'aerospike/command/unsupported_particle_type_validator'
require 'aerospike/key'
require 'aerospike/operation'
require 'aerospike/cdt/context'
require 'aerospike/cdt/list_operation'
require 'aerospike/cdt/list_order'
require 'aerospike/cdt/list_return_type'
require 'aerospike/cdt/list_sort_flags'
require 'aerospike/cdt/list_write_flags'
require 'aerospike/cdt/list_policy'
require 'aerospike/cdt/map_operation'
require 'aerospike/cdt/map_order'
require 'aerospike/cdt/map_return_type'
require 'aerospike/cdt/map_write_flags'
require 'aerospike/cdt/map_write_mode'
require 'aerospike/cdt/map_policy'
require 'aerospike/cdt/hll_operation'
require 'aerospike/cdt/hll_write_flags'
require 'aerospike/cdt/hll_policy'
require 'aerospike/cdt/bit_operation'
require 'aerospike/cdt/bit_overflow_action'
require 'aerospike/cdt/bit_resize_flags'
require 'aerospike/cdt/bit_write_flags'
require 'aerospike/cdt/bit_policy'
require 'aerospike/geo_json'
require 'aerospike/ttl'
require "aerospike/client"
require "aerospike/features"
require "aerospike/utils/pool"
require "aerospike/utils/connection_pool"
require "aerospike/utils/packer"
require "aerospike/utils/unpacker"
require "aerospike/utils/buffer"
require "aerospike/utils/string_parser"
require "aerospike/host"
require "aerospike/host/parse"
require "aerospike/loggable"
require "aerospike/record"
require "aerospike/result_code"
require "aerospike/version"
require "aerospike/value/particle_type"
require "aerospike/value/value"
require "aerospike/command/single_command"
require "aerospike/command/batch_direct_node"
require "aerospike/command/batch_index_node"
require "aerospike/command/field_type"
require "aerospike/command/command"
require "aerospike/command/execute_command"
require "aerospike/command/write_command"
require "aerospike/command/batch_item"
require "aerospike/command/operate_command"
require "aerospike/command/exists_command"
require "aerospike/command/multi_command"
require "aerospike/command/batch_direct_command"
require "aerospike/command/batch_direct_exists_command"
require "aerospike/command/batch_index_command"
require "aerospike/command/batch_index_exists_command"
require "aerospike/command/read_header_command"
require "aerospike/command/touch_command"
require "aerospike/command/read_command"
require "aerospike/command/delete_command"
require "aerospike/command/admin_command"
require "aerospike/command/login_command"
require "aerospike/command/unsupported_particle_type_validator"
require "aerospike/command/operate_args"
require "aerospike/key"
require "aerospike/operation"
require "aerospike/cdt/context"
require "aerospike/cdt/list_operation"
require "aerospike/cdt/list_order"
require "aerospike/cdt/list_return_type"
require "aerospike/cdt/list_sort_flags"
require "aerospike/cdt/list_write_flags"
require "aerospike/cdt/list_policy"
require "aerospike/cdt/map_operation"
require "aerospike/cdt/map_order"
require "aerospike/cdt/map_return_type"
require "aerospike/cdt/map_write_flags"
require "aerospike/cdt/map_write_mode"
require "aerospike/cdt/map_policy"
require "aerospike/cdt/hll_operation"
require "aerospike/cdt/hll_write_flags"
require "aerospike/cdt/hll_policy"
require "aerospike/cdt/bit_operation"
require "aerospike/cdt/bit_overflow_action"
require "aerospike/cdt/bit_resize_flags"
require "aerospike/cdt/bit_write_flags"
require "aerospike/cdt/bit_policy"
require "aerospike/geo_json"
require "aerospike/ttl"

require 'aerospike/policy/client_policy'
require 'aerospike/policy/priority'
require 'aerospike/policy/record_exists_action'
require 'aerospike/policy/generation_policy'
require 'aerospike/policy/policy'
require 'aerospike/policy/batch_policy'
require 'aerospike/policy/write_policy'
require 'aerospike/policy/scan_policy'
require 'aerospike/policy/query_policy'
require 'aerospike/policy/consistency_level'
require 'aerospike/policy/commit_level'
require 'aerospike/policy/admin_policy'
require 'aerospike/policy/auth_mode'
require "aerospike/policy/client_policy"
require "aerospike/policy/priority"
require "aerospike/policy/record_exists_action"
require "aerospike/policy/generation_policy"
require "aerospike/policy/policy"
require "aerospike/policy/batch_policy"
require "aerospike/policy/write_policy"
require "aerospike/policy/scan_policy"
require "aerospike/policy/query_policy"
require "aerospike/policy/consistency_level"
require "aerospike/policy/commit_level"
require "aerospike/policy/admin_policy"
require "aerospike/policy/auth_mode"

require 'aerospike/socket/base'
require 'aerospike/socket/ssl'
require 'aerospike/socket/tcp'
require "aerospike/socket/base"
require "aerospike/socket/ssl"
require "aerospike/socket/tcp"

require 'aerospike/connection/authenticate'
require 'aerospike/connection/create'
require "aerospike/connection/authenticate"
require "aerospike/connection/create"

require 'aerospike/cluster'
require 'aerospike/cluster/create_connection'
require 'aerospike/cluster/find_nodes_to_remove'
require 'aerospike/cluster/find_node'
require 'aerospike/cluster/partition'
require 'aerospike/cluster/partition_parser'
require 'aerospike/cluster/rack_parser'
require 'aerospike/node'
require 'aerospike/node/generation'
require 'aerospike/node/rebalance'
require 'aerospike/node/refresh/failed'
require 'aerospike/node/refresh/friends'
require 'aerospike/node/refresh/info'
require 'aerospike/node/refresh/partitions'
require 'aerospike/node/refresh/racks'
require 'aerospike/node/refresh/peers'
require 'aerospike/node/refresh/reset'
require 'aerospike/node/verify/cluster_name'
require 'aerospike/node/verify/name'
require 'aerospike/node/verify/partition_generation'
require 'aerospike/node/verify/rebalance_generation'
require 'aerospike/node/verify/peers_generation'
require 'aerospike/node_validator'
require 'aerospike/peer'
require 'aerospike/peers'
require 'aerospike/peers/fetch'
require 'aerospike/peers/parse'
require 'aerospike/info'
require 'aerospike/udf'
require 'aerospike/bin'
require 'aerospike/aerospike_exception'
require 'aerospike/user_role'
require 'aerospike/privilege'
require 'aerospike/role'
require "aerospike/cluster"
require "aerospike/cluster/create_connection"
require "aerospike/cluster/find_nodes_to_remove"
require "aerospike/cluster/find_node"
require "aerospike/cluster/partition"
require "aerospike/cluster/partition_parser"
require "aerospike/cluster/rack_parser"
require "aerospike/node"
require "aerospike/node/generation"
require "aerospike/node/rebalance"
require "aerospike/node/refresh/failed"
require "aerospike/node/refresh/friends"
require "aerospike/node/refresh/info"
require "aerospike/node/refresh/partitions"
require "aerospike/node/refresh/racks"
require "aerospike/node/refresh/peers"
require "aerospike/node/refresh/reset"
require "aerospike/node/verify/cluster_name"
require "aerospike/node/verify/name"
require "aerospike/node/verify/partition_generation"
require "aerospike/node/verify/rebalance_generation"
require "aerospike/node/verify/peers_generation"
require "aerospike/node_validator"
require "aerospike/peer"
require "aerospike/peers"
require "aerospike/peers/fetch"
require "aerospike/peers/parse"
require "aerospike/info"
require "aerospike/udf"
require "aerospike/bin"
require "aerospike/aerospike_exception"
require "aerospike/user_role"
require "aerospike/privilege"
require "aerospike/role"

require 'aerospike/task/index_task'
require 'aerospike/task/execute_task'
require 'aerospike/task/udf_remove_task'
require 'aerospike/task/udf_register_task'
require 'aerospike/task/task'
require 'aerospike/language'
require "aerospike/task/index_task"
require "aerospike/task/execute_task"
require "aerospike/task/udf_remove_task"
require "aerospike/task/udf_register_task"
require "aerospike/task/task"
require "aerospike/language"

require 'aerospike/query/recordset'
require 'aerospike/query/filter'
require 'aerospike/query/stream_command'
require 'aerospike/query/query_command'
require 'aerospike/query/scan_command'
require 'aerospike/query/statement'
require 'aerospike/query/pred_exp'
require 'aerospike/query/partition_tracker'
require 'aerospike/query/partition_status'
require 'aerospike/query/partition_filter'
require 'aerospike/query/node_partitions'
require 'aerospike/query/scan_executor'
require 'aerospike/query/scan_partition_command'
require 'aerospike/query/query_executor'
require 'aerospike/query/query_partition_command'
require "aerospike/query/recordset"
require "aerospike/query/filter"
require "aerospike/query/stream_command"
require "aerospike/query/query_command"
require "aerospike/query/scan_command"
require "aerospike/query/statement"
require "aerospike/query/pred_exp"
require "aerospike/query/partition_tracker"
require "aerospike/query/partition_status"
require "aerospike/query/partition_filter"
require "aerospike/query/node_partitions"
require "aerospike/query/scan_executor"
require "aerospike/query/scan_partition_command"
require "aerospike/query/query_executor"
require "aerospike/query/query_partition_command"

require 'aerospike/query/pred_exp/and_or'
require 'aerospike/query/pred_exp/geo_json_value'
require 'aerospike/query/pred_exp/integer_value'
require 'aerospike/query/pred_exp/op'
require 'aerospike/query/pred_exp/regex'
require 'aerospike/query/pred_exp/regex_flags'
require 'aerospike/query/pred_exp/string_value'
require "aerospike/exp/exp"
require "aerospike/exp/exp_map"
require "aerospike/exp/exp_list"
require "aerospike/exp/exp_bit"
require "aerospike/exp/exp_hll"
require "aerospike/exp/operation"

require "aerospike/query/pred_exp/and_or"
require "aerospike/query/pred_exp/geo_json_value"
require "aerospike/query/pred_exp/integer_value"
require "aerospike/query/pred_exp/op"
require "aerospike/query/pred_exp/regex"
require "aerospike/query/pred_exp/regex_flags"
require "aerospike/query/pred_exp/string_value"

module Aerospike
extend Loggable
Expand Down
18 changes: 16 additions & 2 deletions lib/aerospike/cdt/map_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
module Aerospike
module CDT
class MapPolicy

attr_accessor :order, :write_mode, :flags
attr_accessor :item_command, :items_command, :attributes

def initialize(order: nil, write_mode: nil, flags: nil)
if write_mode && flags
Expand All @@ -28,10 +28,24 @@ def initialize(order: nil, write_mode: nil, flags: nil)
@order = order || MapOrder::DEFAULT
@write_mode = write_mode || MapWriteMode::DEFAULT
@flags = flags || MapWriteFlags::DEFAULT
@attributes = order ? order[:attr] : 0

case @write_mode
when CDT::MapWriteMode::DEFAULT
@item_command = CDT::MapOperation::PUT
@items_command = CDT::MapOperation::PUT_ITEMS
when CDT::MapWriteMode::UPDATE_ONLY
@item_command = CDT::MapOperation::REPLACE
@items_command = CDT::MapOperation::REPLACE_ITEMS
when CDT::MapWriteMode::CREATE_ONLY
@item_command = CDT::MapOperation::ADD
@items_command = CDT::MapOperation::ADD_ITEMS
else
raise Exceptions.new(ResultCode::PARAMETER_ERROR, "invalid value for MapWriteMode #{write_mode}")
end
end

DEFAULT = MapPolicy.new

end
end
end
Loading

0 comments on commit 6f05962

Please sign in to comment.