Beispiel #1
0
 def __init__(self,
              session,
              df: DataFrame,
              name: str,
              categories: Mapping[str, str],
              value_type: str = 'int8',
              timestamp=None):
     self.byte_map = ops.get_byte_map(categories)
     self.freetext_index_accumulated = 0
     self.field = df.create_categorical(name, value_type, categories,
                                        timestamp, None)
     self.other_values_field = df.create_indexed_string(
         f"{name}_freetext", timestamp, None)
     self.other_values_field.indices.write_part([0])
Beispiel #2
0
    def __init__(self,
                 datastore,
                 group,
                 name,
                 categories,
                 timestamp=None,
                 write_mode='write'):
        if timestamp is None:
            timestamp = datastore.timestamp
        self.writer = CategoricalWriter(datastore, group, name, categories,
                                        timestamp, write_mode)
        self.field_size = max([len(k) for k in categories.keys()])

        self.byte_map = ops.get_byte_map(categories)
Beispiel #3
0
 def __init__(self,
              datastore,
              group,
              name,
              categories,
              out_of_range,
              timestamp=None,
              write_mode='write'):
     if timestamp is None:
         timestamp = datastore.timestamp
     self.writer = CategoricalWriter(datastore, group, name, categories,
                                     timestamp, write_mode)
     self.other_values = IndexedStringWriter(datastore, group,
                                             f"{name}_{out_of_range}",
                                             timestamp, write_mode)
     self.field_size = max([len(k) for k in categories.keys()])
     self.byte_map = ops.get_byte_map(categories)
     self.freetext_index_accumulated = 0
Beispiel #4
0
    def __init__(self,
                 session,
                 df: DataFrame,
                 name: str,
                 categories: Mapping[str, str],
                 value_type: str = 'int8',
                 timestamp=None):
        if not isinstance(categories, dict):
            raise ValueError(
                "'categories' must be of type dict but is {} in the field '{}'"
                .format(type(categories), name))
        elif len(categories) == 0:
            raise ValueError(
                "'categories' must not be empty in the field '{}'".format(
                    name))

        self.field = df.create_categorical(name, value_type, categories,
                                           timestamp, None)
        self.byte_map = ops.get_byte_map(categories)
        self.field_size = max([len(k) for k in categories])