Skip to content

Commit d2948b5

Browse files
committed
updates
1 parent bbc18d5 commit d2948b5

File tree

7 files changed

+97
-101
lines changed

7 files changed

+97
-101
lines changed

src/iceberg/schema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ICEBERG_EXPORT Schema : public StructType {
4444

4545
/// \brief Get the schema ID.
4646
///
47-
/// Schemas are identified by a unique ID for the purposes of schema
47+
/// A schema is identified by a unique ID for the purposes of schema
4848
/// evolution.
4949
[[nodiscard]] int32_t schema_id() const;
5050

src/iceberg/type.cc

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,26 @@ bool BooleanType::Equals(const Type& other) const {
3333
return other.type_id() == TypeId::kBoolean;
3434
}
3535

36-
TypeId Int32Type::type_id() const { return TypeId::kInt32; }
37-
std::string Int32Type::ToString() const { return "int32"; }
38-
bool Int32Type::Equals(const Type& other) const {
39-
return other.type_id() == TypeId::kInt32;
40-
}
36+
TypeId IntType::type_id() const { return TypeId::kInt; }
37+
std::string IntType::ToString() const { return "int"; }
38+
bool IntType::Equals(const Type& other) const { return other.type_id() == TypeId::kInt; }
4139

42-
TypeId Int64Type::type_id() const { return TypeId::kInt64; }
43-
std::string Int64Type::ToString() const { return "int64"; }
44-
bool Int64Type::Equals(const Type& other) const {
45-
return other.type_id() == TypeId::kInt64;
40+
TypeId LongType::type_id() const { return TypeId::kLong; }
41+
std::string LongType::ToString() const { return "long"; }
42+
bool LongType::Equals(const Type& other) const {
43+
return other.type_id() == TypeId::kLong;
4644
}
4745

48-
TypeId Float32Type::type_id() const { return TypeId::kFloat32; }
49-
std::string Float32Type::ToString() const { return "float32"; }
50-
bool Float32Type::Equals(const Type& other) const {
51-
return other.type_id() == TypeId::kFloat32;
46+
TypeId FloatType::type_id() const { return TypeId::kFloat; }
47+
std::string FloatType::ToString() const { return "float"; }
48+
bool FloatType::Equals(const Type& other) const {
49+
return other.type_id() == TypeId::kFloat;
5250
}
5351

54-
TypeId Float64Type::type_id() const { return TypeId::kFloat64; }
55-
std::string Float64Type::ToString() const { return "float64"; }
56-
bool Float64Type::Equals(const Type& other) const {
57-
return other.type_id() == TypeId::kFloat64;
52+
TypeId DoubleType::type_id() const { return TypeId::kDouble; }
53+
std::string DoubleType::ToString() const { return "double"; }
54+
bool DoubleType::Equals(const Type& other) const {
55+
return other.type_id() == TypeId::kDouble;
5856
}
5957

6058
DecimalType::DecimalType(int32_t precision, int32_t scale)
@@ -265,7 +263,7 @@ StructType::StructType(std::vector<SchemaField> fields) : fields_(std::move(fiel
265263
field.field_id(), it->second, index));
266264
}
267265

268-
index++;
266+
++index;
269267
}
270268
}
271269

src/iceberg/type.h

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ class ICEBERG_EXPORT Type : public iceberg::util::Formattable {
6363
[[nodiscard]] virtual bool Equals(const Type& other) const = 0;
6464
};
6565

66-
/// \brief A data type that may not have child fields.
66+
/// \brief A data type that does not have child fields.
6767
class ICEBERG_EXPORT PrimitiveType : public Type {
6868
public:
6969
bool is_primitive() const override { return true; }
7070
bool is_nested() const override { return false; }
7171
};
7272

73-
/// \brief A data type that may have child fields.
73+
/// \brief A data type that has child fields.
7474
class ICEBERG_EXPORT NestedType : public Type {
7575
public:
7676
bool is_primitive() const override { return false; }
@@ -93,7 +93,7 @@ class ICEBERG_EXPORT NestedType : public Type {
9393
/// Primitive types do not have nested fields.
9494
/// @{
9595

96-
/// \brief A data type representing a boolean.
96+
/// \brief A data type representing a boolean (true or false).
9797
class ICEBERG_EXPORT BooleanType : public PrimitiveType {
9898
public:
9999
BooleanType() = default;
@@ -107,10 +107,10 @@ class ICEBERG_EXPORT BooleanType : public PrimitiveType {
107107
};
108108

109109
/// \brief A data type representing a 32-bit signed integer.
110-
class ICEBERG_EXPORT Int32Type : public PrimitiveType {
110+
class ICEBERG_EXPORT IntType : public PrimitiveType {
111111
public:
112-
Int32Type() = default;
113-
~Int32Type() = default;
112+
IntType() = default;
113+
~IntType() = default;
114114

115115
TypeId type_id() const override;
116116
std::string ToString() const override;
@@ -120,10 +120,10 @@ class ICEBERG_EXPORT Int32Type : public PrimitiveType {
120120
};
121121

122122
/// \brief A data type representing a 64-bit signed integer.
123-
class ICEBERG_EXPORT Int64Type : public PrimitiveType {
123+
class ICEBERG_EXPORT LongType : public PrimitiveType {
124124
public:
125-
Int64Type() = default;
126-
~Int64Type() = default;
125+
LongType() = default;
126+
~LongType() = default;
127127

128128
TypeId type_id() const override;
129129
std::string ToString() const override;
@@ -132,11 +132,12 @@ class ICEBERG_EXPORT Int64Type : public PrimitiveType {
132132
bool Equals(const Type& other) const override;
133133
};
134134

135-
/// \brief A data type representing a 32-bit (single precision) float.
136-
class ICEBERG_EXPORT Float32Type : public PrimitiveType {
135+
/// \brief A data type representing a 32-bit (single precision) IEEE-754
136+
/// float.
137+
class ICEBERG_EXPORT FloatType : public PrimitiveType {
137138
public:
138-
Float32Type() = default;
139-
~Float32Type() = default;
139+
FloatType() = default;
140+
~FloatType() = default;
140141

141142
TypeId type_id() const override;
142143
std::string ToString() const override;
@@ -145,11 +146,12 @@ class ICEBERG_EXPORT Float32Type : public PrimitiveType {
145146
bool Equals(const Type& other) const override;
146147
};
147148

148-
/// \brief A data type representing a 64-bit (double precision) float.
149-
class ICEBERG_EXPORT Float64Type : public PrimitiveType {
149+
/// \brief A data type representing a 64-bit (double precision) IEEE-754
150+
/// float.
151+
class ICEBERG_EXPORT DoubleType : public PrimitiveType {
150152
public:
151-
Float64Type() = default;
152-
~Float64Type() = default;
153+
DoubleType() = default;
154+
~DoubleType() = default;
153155

154156
TypeId type_id() const override;
155157
std::string ToString() const override;
@@ -240,7 +242,7 @@ class ICEBERG_EXPORT TimestampType : public TimestampBase {
240242
};
241243

242244
/// \brief A data type representing a timestamp as microseconds since the
243-
/// epoch in UTC.
245+
/// epoch in UTC. A time zone or offset is not stored.
244246
class ICEBERG_EXPORT TimestampTzType : public TimestampBase {
245247
public:
246248
TimestampTzType() = default;
@@ -256,7 +258,7 @@ class ICEBERG_EXPORT TimestampTzType : public TimestampBase {
256258
bool Equals(const Type& other) const override;
257259
};
258260

259-
/// \brief A data type representing a bytestring.
261+
/// \brief A data type representing an arbitrary-length byte sequence.
260262
class ICEBERG_EXPORT BinaryType : public PrimitiveType {
261263
public:
262264
BinaryType() = default;
@@ -269,7 +271,8 @@ class ICEBERG_EXPORT BinaryType : public PrimitiveType {
269271
bool Equals(const Type& other) const override;
270272
};
271273

272-
/// \brief A data type representing a string.
274+
/// \brief A data type representing an arbitrary-length character sequence
275+
/// (encoded in UTF-8).
273276
class ICEBERG_EXPORT StringType : public PrimitiveType {
274277
public:
275278
StringType() = default;

src/iceberg/type_fwd.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ namespace iceberg {
3333
///
3434
/// Iceberg V3 types are not currently supported.
3535
enum class TypeId {
36+
kStruct,
37+
kList,
38+
kMap,
3639
kBoolean,
37-
kInt32,
38-
kInt64,
39-
kFloat32,
40-
kFloat64,
40+
kInt,
41+
kLong,
42+
kFloat,
43+
kDouble,
4144
kDecimal,
4245
kDate,
4346
kTime,
4447
kTimestamp,
4548
kTimestampTz,
46-
kBinary,
4749
kString,
48-
kFixed,
4950
kUuid,
50-
kStruct,
51-
kList,
52-
kMap,
51+
kFixed,
52+
kBinary,
5353
};
5454

5555
/// \brief The time unit. In Iceberg V3 nanoseconds are also supported.
@@ -62,10 +62,10 @@ class BooleanType;
6262
class DateType;
6363
class DecimalType;
6464
class FixedType;
65-
class Float32Type;
66-
class Float64Type;
67-
class Int32Type;
68-
class Int64Type;
65+
class FloatType;
66+
class DoubleType;
67+
class IntType;
68+
class LongType;
6969
class ListType;
7070
class MapType;
7171
class NestedType;
@@ -74,7 +74,6 @@ class Schema;
7474
class SchemaField;
7575
class StringType;
7676
class StructType;
77-
class StructType;
7877
class TimeType;
7978
class TimestampBase;
8079
class TimestampType;

test/core/schema_field_test.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929

3030
TEST(SchemaFieldTest, Basics) {
3131
{
32-
iceberg::SchemaField field(1, "foo", std::make_shared<iceberg::Int32Type>(), false);
32+
iceberg::SchemaField field(1, "foo", std::make_shared<iceberg::IntType>(), false);
3333
EXPECT_EQ(1, field.field_id());
3434
EXPECT_EQ("foo", field.name());
35-
EXPECT_EQ(iceberg::TypeId::kInt32, field.type()->type_id());
35+
EXPECT_EQ(iceberg::TypeId::kInt, field.type()->type_id());
3636
EXPECT_FALSE(field.optional());
37-
EXPECT_EQ("foo (1): int32 (required)", field.ToString());
38-
EXPECT_EQ("foo (1): int32 (required)", std::format("{}", field));
37+
EXPECT_EQ("foo (1): int (required)", field.ToString());
38+
EXPECT_EQ("foo (1): int (required)", std::format("{}", field));
3939
}
4040
{
4141
iceberg::SchemaField field = iceberg::SchemaField::MakeOptional(
@@ -60,12 +60,12 @@ TEST(SchemaFieldTest, Basics) {
6060
}
6161

6262
TEST(SchemaFieldTest, Equality) {
63-
iceberg::SchemaField field1(1, "foo", std::make_shared<iceberg::Int32Type>(), false);
64-
iceberg::SchemaField field2(2, "foo", std::make_shared<iceberg::Int32Type>(), false);
65-
iceberg::SchemaField field3(1, "bar", std::make_shared<iceberg::Int32Type>(), false);
66-
iceberg::SchemaField field4(1, "foo", std::make_shared<iceberg::Int64Type>(), false);
67-
iceberg::SchemaField field5(1, "foo", std::make_shared<iceberg::Int32Type>(), true);
68-
iceberg::SchemaField field6(1, "foo", std::make_shared<iceberg::Int32Type>(), false);
63+
iceberg::SchemaField field1(1, "foo", std::make_shared<iceberg::IntType>(), false);
64+
iceberg::SchemaField field2(2, "foo", std::make_shared<iceberg::IntType>(), false);
65+
iceberg::SchemaField field3(1, "bar", std::make_shared<iceberg::IntType>(), false);
66+
iceberg::SchemaField field4(1, "foo", std::make_shared<iceberg::LongType>(), false);
67+
iceberg::SchemaField field5(1, "foo", std::make_shared<iceberg::IntType>(), true);
68+
iceberg::SchemaField field6(1, "foo", std::make_shared<iceberg::IntType>(), false);
6969

7070
ASSERT_EQ(field1, field1);
7171
ASSERT_NE(field1, field2);

test/core/schema_test.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
TEST(SchemaTest, Basics) {
3232
{
33-
iceberg::SchemaField field1(5, "foo", std::make_shared<iceberg::Int32Type>(), true);
33+
iceberg::SchemaField field1(5, "foo", std::make_shared<iceberg::IntType>(), true);
3434
iceberg::SchemaField field2(7, "bar", std::make_shared<iceberg::StringType>(), true);
3535
iceberg::Schema schema(100, {field1, field2});
3636
ASSERT_EQ(schema, schema);
@@ -53,8 +53,7 @@ TEST(SchemaTest, Basics) {
5353
}
5454
ASSERT_THAT(
5555
[]() {
56-
iceberg::SchemaField field1(5, "foo", std::make_shared<iceberg::Int32Type>(),
57-
true);
56+
iceberg::SchemaField field1(5, "foo", std::make_shared<iceberg::IntType>(), true);
5857
iceberg::SchemaField field2(5, "bar", std::make_shared<iceberg::StringType>(),
5958
true);
6059
iceberg::Schema schema(100, {field1, field2});
@@ -64,9 +63,9 @@ TEST(SchemaTest, Basics) {
6463
}
6564

6665
TEST(SchemaTest, Equality) {
67-
iceberg::SchemaField field1(5, "foo", std::make_shared<iceberg::Int32Type>(), true);
66+
iceberg::SchemaField field1(5, "foo", std::make_shared<iceberg::IntType>(), true);
6867
iceberg::SchemaField field2(7, "bar", std::make_shared<iceberg::StringType>(), true);
69-
iceberg::SchemaField field3(5, "foobar", std::make_shared<iceberg::Int32Type>(), true);
68+
iceberg::SchemaField field3(5, "foobar", std::make_shared<iceberg::IntType>(), true);
7069
iceberg::Schema schema1(100, {field1, field2});
7170
iceberg::Schema schema2(101, {field1, field2});
7271
iceberg::Schema schema3(101, {field1});

0 commit comments

Comments
 (0)