Class: Couchbase::SamplingScan

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/key_value_scan.rb

Overview

A sampling scan performs a scan that randomly selects documents up to a configured limit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit, seed = nil) ⇒ SamplingScan

Creates an instance of a SamplingScan scan type

Parameters:

  • limit (Integer)

    the maximum number of documents the sampling scan can return

  • seed (Integer, nil) (defaults to: nil)

    the seed used for the random number generator that selects the documents. If not set, a seed is generated at random



105
106
107
108
# File 'lib/couchbase/key_value_scan.rb', line 105

def initialize(limit, seed = nil)
  @limit = limit
  @seed = seed
end

Instance Attribute Details

#limitInteger

Returns:

  • (Integer)


97
98
99
# File 'lib/couchbase/key_value_scan.rb', line 97

def limit
  @limit
end

#seedInteger?

Returns:

  • (Integer, nil)


98
99
100
# File 'lib/couchbase/key_value_scan.rb', line 98

def seed
  @seed
end

Instance Method Details

#to_backendObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



111
112
113
114
115
116
117
# File 'lib/couchbase/key_value_scan.rb', line 111

def to_backend
  {
    scan_type: :sampling,
    limit: @limit,
    seed: @seed,
  }
end