class Aerospike::Filter

Attributes

packed_ctx[R]

Public Class Methods

Contains(bin_name, value, col_type, ctx: nil)
Alias for: contains
Equal(bin_name, value, ctx: nil)

alias the old names for compatibility

Alias for: equal
Range(bin_name, from, to, col_type = nil, ctx: nil)
Alias for: range
contains(bin_name, value, col_type, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 27
def contains(bin_name, value, col_type, ctx: nil)
  Filter.new(bin_name, value, value, nil, col_type, ctx)
end
Also aliased as: Contains
equal(bin_name, value, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 23
def equal(bin_name, value, ctx: nil)
  Filter.new(bin_name, value, value, nil, nil, ctx)
end
Also aliased as: Equal
geoContainsGeoJSONPoint(bin_name, point, col_type = nil, ctx: nil)
geoContainsPoint(bin_name, lon, lat, col_type = nil, ctx: nil)
Alias for: geo_contains_point
geoWithinGeoJSONRegion(bin_name, region, col_type = nil, ctx: nil)
geoWithinRadius(bin_name, lon, lat, radius_meter, col_type = nil, ctx: nil)
Alias for: geo_within_radius
geo_contains_geo_point(bin_name, point, col_type = nil, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 45
def geo_contains_geo_point(bin_name, point, col_type = nil, ctx: nil)
  point = point.to_json
  Filter.new(bin_name, point, point, ParticleType::GEOJSON, col_type, ctx)
end
Also aliased as: geoContainsGeoJSONPoint
geo_contains_point(bin_name, lon, lat, col_type = nil, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 50
def geo_contains_point(bin_name, lon, lat, col_type = nil, ctx: nil)
  point = GeoJSON.new({ type: "Point", coordinates: [lon, lat] })
  geo_contains_geo_point(bin_name, point, col_type, ctx: ctx)
end
Also aliased as: geoContainsPoint
geo_within_geo_region(bin_name, region, col_type = nil, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 35
def geo_within_geo_region(bin_name, region, col_type = nil, ctx: nil)
  region = region.to_json
  Filter.new(bin_name, region, region, ParticleType::GEOJSON, col_type, ctx)
end
Also aliased as: geoWithinGeoJSONRegion
geo_within_radius(bin_name, lon, lat, radius_meter, col_type = nil, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 40
def geo_within_radius(bin_name, lon, lat, radius_meter, col_type = nil, ctx: nil)
  region = GeoJSON.new({ type: "AeroCircle", coordinates: [[lon, lat], radius_meter] })
  geo_within_geo_region(bin_name, region, col_type, ctx: ctx)
end
Also aliased as: geoWithinRadius
new(bin_name, begin_value, end_value, val_type = nil, col_type = nil, ctx = nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 113
def initialize(bin_name, begin_value, end_value, val_type = nil, col_type = nil, ctx = nil)
  @name = bin_name
  @begin = Aerospike::Value.of(begin_value)
  @end = Aerospike::Value.of(end_value)

  # The type of the filter values can usually be inferred automatically;
  # but in certain cases caller can override the type.
  @val_type = val_type || @begin.type
  @col_type = col_type

  @packed_ctx = CDT::Context.bytes(ctx)
end
range(bin_name, from, to, col_type = nil, ctx: nil) click to toggle source
# File lib/aerospike/query/filter.rb, line 31
def range(bin_name, from, to, col_type = nil, ctx: nil)
  Filter.new(bin_name, from, to, nil, col_type, ctx)
end
Also aliased as: Range

Public Instance Methods

collection_type() click to toggle source

for internal use

# File lib/aerospike/query/filter.rb, line 93
def collection_type
  case @col_type
  when :default then 0
  when :list then 1
  when :mapkeys then 2
  when :mapvalues then 3
  else 0
  end
end
estimate_size() click to toggle source
# File lib/aerospike/query/filter.rb, line 65
def estimate_size
  return @name.bytesize + @begin.estimate_size + @end.estimate_size + 10
end
to_s() click to toggle source

Show the filter as String. This is util to show filters in logs.

# File lib/aerospike/query/filter.rb, line 106
def to_s
  return "#{@name} = #{@begin}" if @begin == @end
  "#{@name} = #{@begin} - #{@end}"
end
write(buf, offset) click to toggle source
# File lib/aerospike/query/filter.rb, line 69
def write(buf, offset)
  # Write name.
  len = buf.write_binary(@name, offset + 1)
  buf.write_byte(len, offset)
  offset += len + 1

  # Write particle type.
  buf.write_byte(@val_type, offset)
  offset += 1

  # Write filter begin.
  len = @begin.write(buf, offset + 4)
  buf.write_int32(len, offset)
  offset += len + 4

  # Write filter end.
  len = @end.write(buf, offset + 4)
  buf.write_int32(len, offset)
  offset += len + 4

  offset
end