]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/r/R/dictionary.R
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / r / R / dictionary.R
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 #' @include type.R
19
20 #' @title class DictionaryType
21 #'
22 #' @usage NULL
23 #' @format NULL
24 #' @docType class
25 #'
26 #' @section Methods:
27 #'
28 #' TODO
29 #'
30 #' @rdname DictionaryType
31 #' @name DictionaryType
32 DictionaryType <- R6Class("DictionaryType",
33 inherit = FixedWidthType,
34 public = list(
35 ToString = function() {
36 prettier_dictionary_type(DataType__ToString(self))
37 }
38 ),
39 active = list(
40 index_type = function() DictionaryType__index_type(self),
41 value_type = function() DictionaryType__value_type(self),
42 name = function() DictionaryType__name(self),
43 ordered = function() DictionaryType__ordered(self)
44 )
45 )
46 DictionaryType$create <- function(index_type = int32(),
47 value_type = utf8(),
48 ordered = FALSE) {
49 assert_is(index_type, "DataType")
50 assert_is(value_type, "DataType")
51 DictionaryType__initialize(index_type, value_type, ordered)
52 }
53
54 #' Create a dictionary type
55 #'
56 #' @param index_type A DataType for the indices (default [int32()])
57 #' @param value_type A DataType for the values (default [utf8()])
58 #' @param ordered Is this an ordered dictionary (default `FALSE`)?
59 #'
60 #' @return A [DictionaryType]
61 #' @seealso [Other Arrow data types][data-type]
62 #' @export
63 dictionary <- DictionaryType$create
64
65 prettier_dictionary_type <- function(x) {
66 # Prettier format the "ordered" attribute
67 x <- sub(", ordered=0", "", x)
68 sub("ordered=1", "ordered", x)
69 }