iceberg-cpp
Loading...
Searching...
No Matches
partition_values.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
24
25#include <functional>
26#include <span>
27#include <utility>
28
29#include "iceberg/expression/literal.h"
30#include "iceberg/iceberg_export.h"
32
33namespace iceberg {
34
36class ICEBERG_EXPORT PartitionValues : public StructLike {
37 public:
38 PartitionValues() = default;
39 explicit PartitionValues(std::vector<Literal> values) : values_(std::move(values)) {}
40 explicit PartitionValues(Literal value) : values_({std::move(value)}) {}
41
42 PartitionValues(const PartitionValues& other) : values_(other.values_) {}
43 PartitionValues& operator=(const PartitionValues& other);
44
45 PartitionValues(PartitionValues&&) noexcept = default;
46 PartitionValues& operator=(PartitionValues&&) noexcept = default;
47
48 ~PartitionValues() override = default;
49
50 Result<Scalar> GetField(size_t pos) const override;
51
52 size_t num_fields() const override { return values_.size(); }
53
57 Result<std::reference_wrapper<const Literal>> ValueAt(size_t pos) const;
58
61 void AddValue(Literal value) { values_.emplace_back(std::move(value)); }
62
65 void Reset(std::vector<Literal> values) { values_ = std::move(values); }
66
67 std::span<const Literal> values() const { return values_; }
68
69 bool operator==(const PartitionValues& other) const;
70
71 private:
72 std::vector<Literal> values_;
73};
74
75} // namespace iceberg
Literal is a literal value that is associated with a primitive type.
Definition literal.h:39
StructLike wrapper for a vector of literals that represent partition values.
Definition partition_values.h:36
void Reset(std::vector< Literal > values)
Reset the partition values.
Definition partition_values.h:65
size_t num_fields() const override
Get the number of fields in the struct.
Definition partition_values.h:52
void AddValue(Literal value)
Add a value to the partition values.
Definition partition_values.h:61
An immutable struct-like wrapper.
Definition struct_like.h:62