Class: ChDB::DataPath
- Inherits:
-
Object
- Object
- ChDB::DataPath
- Defined in:
- lib/chdb/data_path.rb
Overview
Represents the data path configuration for ChDB. This class is responsible for initializing and managing the data path including parsing URIs, handling query parameters, and ensuring directory existence.
Instance Attribute Summary collapse
-
#dir_path ⇒ Object
readonly
Returns the value of attribute dir_path.
-
#is_tmp ⇒ Object
readonly
Returns the value of attribute is_tmp.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#query_params ⇒ Object
readonly
Returns the value of attribute query_params.
Instance Method Summary collapse
- #close ⇒ Object
-
#generate_arguments ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#initialize(uri, options) ⇒ DataPath
constructor
A new instance of DataPath.
Constructor Details
#initialize(uri, options) ⇒ DataPath
Returns a new instance of DataPath.
16 17 18 19 20 21 22 |
# File 'lib/chdb/data_path.rb', line 16 def initialize(uri, ) initialize_instance_variables path = parse_uri(uri) () check_params directory_path(path) end |
Instance Attribute Details
#dir_path ⇒ Object (readonly)
Returns the value of attribute dir_path.
14 15 16 |
# File 'lib/chdb/data_path.rb', line 14 def dir_path @dir_path end |
#is_tmp ⇒ Object (readonly)
Returns the value of attribute is_tmp.
14 15 16 |
# File 'lib/chdb/data_path.rb', line 14 def is_tmp @is_tmp end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
14 15 16 |
# File 'lib/chdb/data_path.rb', line 14 def mode @mode end |
#query_params ⇒ Object (readonly)
Returns the value of attribute query_params.
14 15 16 |
# File 'lib/chdb/data_path.rb', line 14 def query_params @query_params end |
Instance Method Details
#close ⇒ Object
55 56 57 |
# File 'lib/chdb/data_path.rb', line 55 def close FileUtils.remove_entry(@dir_path, true) if @is_tmp && Dir.exist?(@dir_path) end |
#generate_arguments ⇒ Object
rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chdb/data_path.rb', line 24 def generate_arguments # rubocop:disable Metrics/MethodLength args = ['clickhouse', "--path=#{@dir_path}"] excluded_keys = %w[results_as_hash readonly readwrite flags] @query_params.each do |key, value| next if excluded_keys.include?(key) case key.to_s when 'udf_path' udf_value = value.to_s args += ['--', "--user_scripts_path=#{udf_value}", "--user_defined_executable_functions_config=#{udf_value}/*.xml"] next when '--' args << '--' next end key_str = key.to_s args << if value.nil? "--#{key_str}" else "--#{key_str}=#{value}" end end args << '--readonly=1' if @mode.anybits?(Constants::Open::READONLY) args end |