json/json.hpp
前往此文件的文档。
1 /*
2  * Copyright (c) 2021-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://apache.ac.cn/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
20 #include <cudf/utilities/export.hpp>
22 
23 namespace CUDF_EXPORT cudf {
24 
35  // allow single quotes to represent strings in JSON
36  bool allow_single_quotes = false;
37 
38  // individual string values are returned with quotes stripped.
39  bool strip_quotes_from_single_strings = true;
40 
41  // Whether to return nulls when an object does not contain the requested field.
42  bool missing_fields_as_nulls = false;
43 
44  public
48  explicit get_json_object_options() = default;
49 
56  [[nodiscard]] CUDF_HOST_DEVICE inline bool get_allow_single_quotes() const
57  {
58  return allow_single_quotes;
59  }
60 
85  [[nodiscard]] CUDF_HOST_DEVICE inline bool get_strip_quotes_from_single_strings() const
86  {
87  return strip_quotes_from_single_strings;
88  }
89 
111  [[nodiscard]] CUDF_HOST_DEVICE inline bool get_missing_fields_as_nulls() const
112  {
113  return missing_fields_as_nulls;
114  }
115 
121  void set_allow_single_quotes(bool _allow_single_quotes)
122  {
123  allow_single_quotes = _allow_single_quotes;
124  }
125 
131  void set_strip_quotes_from_single_strings(bool _strip_quotes_from_single_strings)
132  {
133  strip_quotes_from_single_strings = _strip_quotes_from_single_strings;
134  }
135 
141  void set_missing_fields_as_nulls(bool _missing_fields_as_nulls)
142  {
143  missing_fields_as_nulls = _missing_fields_as_nulls;
144  }
145 };
146 
165 std::unique_ptr<cudf::column> get_json_object(
166  cudf::strings_column_view const& col,
167  cudf::string_scalar const& json_path,
171  // end of doxygen group
173 } // namespace CUDF_EXPORT cudf
get_json_object() 的设置。
CUDF_HOST_DEVICE bool get_allow_single_quotes() const
根据是否允许使用单引号表示字符串来返回 true/false。
void set_strip_quotes_from_single_strings(bool _strip_quotes_from_single_strings)
设置返回的单个字符串值是否去除引号。
void set_allow_single_quotes(bool _allow_single_quotes)
设置是否允许使用单引号表示字符串。
get_json_object_options()=default
默认构造函数。
void set_missing_fields_as_nulls(bool _missing_fields_as_nulls)
设置缺失字段是否解释为 null。
CUDF_HOST_DEVICE bool get_strip_quotes_from_single_strings() const
根据返回的单个字符串值是否去除引号来返回 true/false...
CUDF_HOST_DEVICE bool get_missing_fields_as_nulls() const
对象中不包含的字段是否解释为 null。
用于表示设备内存中字符串的拥有类。
定义: scalar.hpp:421
给定一个字符串类型的列视图,此类的实例为此复合列提供了一个包装器...
rmm::cuda_stream_view const get_default_stream()
获取当前的默认流。
std::unique_ptr< cudf::column > get_json_object(cudf::strings_column_view const &col, cudf::string_scalar const &json_path, get_json_object_options options=get_json_object_options{}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
对输入字符串列中的所有行应用 JSONPath 字符串。
rmm::device_async_resource_ref get_current_device_resource_ref()
获取当前的设备内存资源引用。
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
cuDF 接口
定义: host_udf.hpp:37
cudf::strings_column_view 的类定义。
#define CUDF_HOST_DEVICE
表示函数或方法可在主机和设备上使用。
定义: types.hpp:32