<commit_before>#    Copyright 2020 Couchbase, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

require "couchbase/json_transcoder"
require "couchbase/common_options"
require "couchbase/subdoc"
require "couchbase/mutation_state"

module Couchbase
  class Collection
    class GetOptions < CommonOptions
      # @return [Boolean] if the expiration should also fetched with get
      attr_accessor :with_expiry

      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetOptions] self
      def initialize
        @transcoder = JsonTranscoder.new
        @preserve_array_indexes = false
        @with_expiry = nil
        @projections = nil
        yield self if block_given?
      end

      # Allows to specify a custom list paths to fetch from the document instead of the whole.
      #
      # Note that a maximum of 16 individual paths can be projected at a time due to a server limitation. If you need
      # more than that, think about fetching less-generic paths or the full document straight away.
      #
      # @param [String, Array<String>] paths a path that should be loaded if present.
      def project(*paths)
        @projections ||= []
        @projections |= paths.flatten # union with current projections
      end

      # @api private
      # @return [Boolean] whether to use sparse arrays (default false)
      attr_accessor :preserve_array_indexes

      # @api private
      # @return [Array<String>] list of paths to project
      attr_accessor :projections

      # @api private
      # @return [Boolean]
      def need_projected_get?
        @with_expiry || !@projections.nil?
      end
    end

    class GetAndLockOptions < CommonOptions
      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetAndLockOptions] self
      def initialize
        @transcoder = JsonTranscoder.new
        yield self if block_given?
      end
    end

    class GetAndTouchOptions < CommonOptions
      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetAndTouchOptions] self
      def initialize
        @transcoder = JsonTranscoder.new
        yield self if block_given?
      end
    end

    class GetResult
      # @return [Integer] holds the CAS value of the fetched document
      attr_accessor :cas

      # @return [Integer] the expiration if fetched and present
      attr_accessor :expiry

      # @return [String] The encoded content when loading the document
      attr_accessor :encoded

      # Decodes the content of the document using given (or default transcoder)
      #
      # @param [JsonTranscoder] transcoder custom transcoder
      #
      # @return [Object]
      def content(transcoder = self.transcoder)
        transcoder.decode(@encoded, @flags)
      end

      # @yieldparam [GetResult] self
      def initialize
        yield self if block_given?
      end

      # @return [Integer] The flags from the operation
      attr_accessor :flags

      # @return [JsonTranscoder] The default transcoder which should be used
      attr_accessor :transcoder
    end

    class GetAllReplicasOptions < CommonOptions
      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetAllReplicasOptions] self
      def initialize
        yield self if block_given?
      end
    end<commit_msg>📝 RCBC-259: mark parts of GetResult API as private<commit_after>#    Copyright 2020 Couchbase, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

require "couchbase/json_transcoder"
require "couchbase/common_options"
require "couchbase/subdoc"
require "couchbase/mutation_state"

module Couchbase
  class Collection
    class GetOptions < CommonOptions
      # @return [Boolean] if the expiration should also fetched with get
      attr_accessor :with_expiry

      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetOptions] self
      def initialize
        @transcoder = JsonTranscoder.new
        @preserve_array_indexes = false
        @with_expiry = nil
        @projections = nil
        yield self if block_given?
      end

      # Allows to specify a custom list paths to fetch from the document instead of the whole.
      #
      # Note that a maximum of 16 individual paths can be projected at a time due to a server limitation. If you need
      # more than that, think about fetching less-generic paths or the full document straight away.
      #
      # @param [String, Array<String>] paths a path that should be loaded if present.
      def project(*paths)
        @projections ||= []
        @projections |= paths.flatten # union with current projections
      end

      # @api private
      # @return [Boolean] whether to use sparse arrays (default false)
      attr_accessor :preserve_array_indexes

      # @api private
      # @return [Array<String>] list of paths to project
      attr_accessor :projections

      # @api private
      # @return [Boolean]
      def need_projected_get?
        @with_expiry || !@projections.nil?
      end
    end

    class GetAndLockOptions < CommonOptions
      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetAndLockOptions] self
      def initialize
        @transcoder = JsonTranscoder.new
        yield self if block_given?
      end
    end

    class GetAndTouchOptions < CommonOptions
      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetAndTouchOptions] self
      def initialize
        @transcoder = JsonTranscoder.new
        yield self if block_given?
      end
    end

    class GetResult
      # @return [Integer] holds the CAS value of the fetched document
      attr_accessor :cas

      # @return [Integer] the expiration if fetched and present
      attr_accessor :expiry

      # @return [String] The encoded content when loading the document
      # @api private
      attr_accessor :encoded

      # Decodes the content of the document using given (or default transcoder)
      #
      # @param [JsonTranscoder] transcoder custom transcoder
      #
      # @return [Object]
      def content(transcoder = self.transcoder)
        transcoder.decode(@encoded, @flags)
      end

      # @yieldparam [GetResult] self
      def initialize
        yield self if block_given?
      end

      # @return [Integer] The flags from the operation
      # @api private
      attr_accessor :flags

      # @return [JsonTranscoder] The default transcoder which should be used
      attr_accessor :transcoder
    end

    class GetAllReplicasOptions < CommonOptions
      # @return [JsonTranscoder] transcoder used for decoding
      attr_accessor :transcoder

      # @yieldparam [GetAllReplicasOptions] self
      def initialize
        yield self if block_given?
      end
    end
{'fraction_non_alphanumeric': 0.05942444250654043, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 2.769014084507042, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6521799', 'n_tokens_mistral': 2243, 'n_tokens_neox': 2141, 'n_words': 819}