Skip to content

Commit 8e9c48d

Browse files
committed
fix: cast thrift encoded values to ints to preven issues with 32 systems
1 parent ad23d1e commit 8e9c48d

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

src/lib/parquet/src/Flow/Parquet/ParquetFile/Metadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static function fromThrift(FileMetaData $thrift, Options $options) : self
2424
return new self(
2525
Schema::fromThrift($thrift->schema),
2626
RowGroups::fromThrift($thrift->row_groups, $options),
27-
$thrift->num_rows,
28-
$thrift->version,
27+
(int) $thrift->num_rows,
28+
(int) $thrift->version,
2929
$thrift->created_by
3030
);
3131
}

src/lib/parquet/src/Flow/Parquet/ParquetFile/Page/Header/DataPageHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function fromThrift(\Flow\Parquet\ThriftModel\DataPageHeader $thri
2222
Encodings::from($thrift->encoding),
2323
Encodings::from($thrift->repetition_level_encoding),
2424
Encodings::from($thrift->definition_level_encoding),
25-
$thrift->num_values
25+
(int) $thrift->num_values
2626
);
2727
}
2828

src/lib/parquet/src/Flow/Parquet/ParquetFile/Page/Header/DataPageHeaderV2.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public function __construct(
2525
public static function fromThrift(\Flow\Parquet\ThriftModel\DataPageHeaderV2 $thrift, Options $options) : self
2626
{
2727
return new self(
28-
$thrift->num_values,
29-
$thrift->num_nulls,
30-
$thrift->num_rows,
28+
(int) $thrift->num_values,
29+
(int) $thrift->num_nulls,
30+
(int) $thrift->num_rows,
3131
Encodings::from($thrift->encoding),
32-
$thrift->definition_levels_byte_length,
33-
$thrift->repetition_levels_byte_length,
32+
(int) $thrift->definition_levels_byte_length,
33+
(int) $thrift->repetition_levels_byte_length,
3434
/** @phpstan-ignore-next-line */
3535
$thrift->is_compressed ?? null,
3636
$thrift->statistics ? Statistics::fromThrift($thrift->statistics) : null,

src/lib/parquet/src/Flow/Parquet/ParquetFile/Page/Header/DictionaryPageHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function fromThrift(\Flow\Parquet\ThriftModel\DictionaryPageHeader
1818
{
1919
return new self(
2020
Encodings::from($thrift->encoding),
21-
$thrift->num_values
21+
(int) $thrift->num_values
2222
);
2323
}
2424

src/lib/parquet/src/Flow/Parquet/ParquetFile/Page/PageHeader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static function fromThrift(\Flow\Parquet\ThriftModel\PageHeader $thrift,
2424
{
2525
return new self(
2626
Type::from($thrift->type),
27-
$thrift->compressed_page_size,
28-
$thrift->uncompressed_page_size,
27+
(int) $thrift->compressed_page_size,
28+
(int) $thrift->uncompressed_page_size,
2929
$thrift->data_page_header !== null ? DataPageHeader::fromThrift($thrift->data_page_header) : null,
3030
$thrift->data_page_header_v2 !== null ? DataPageHeaderV2::fromThrift($thrift->data_page_header_v2, $options) : null,
3131
$thrift->dictionary_page_header !== null ? DictionaryPageHeader::fromThrift($thrift->dictionary_page_header) : null

src/lib/parquet/src/Flow/Parquet/ParquetFile/RowGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function fromThrift(\Flow\Parquet\ThriftModel\RowGroup $thrift, Op
2525
{
2626
return new self(
2727
\array_map(static fn (\Flow\Parquet\ThriftModel\ColumnChunk $columnChunk) => ColumnChunk::fromThrift($columnChunk, $options), $thrift->columns),
28-
$thrift->num_rows
28+
(int) $thrift->num_rows
2929
);
3030
}
3131

src/lib/parquet/src/Flow/Parquet/ParquetFile/RowGroup/ColumnChunk.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ public static function fromThrift(\Flow\Parquet\ThriftModel\ColumnChunk $thrift,
4646
return new self(
4747
PhysicalType::from($thrift->meta_data->type),
4848
Compressions::from($thrift->meta_data->codec),
49-
$thrift->meta_data->num_values,
50-
$thrift->file_offset,
49+
(int) $thrift->meta_data->num_values,
50+
(int) $thrift->file_offset,
5151
$thrift->meta_data->path_in_schema,
5252
\array_map(static fn ($encoding) => Encodings::from($encoding), $thrift->meta_data->encodings),
53-
$thrift->meta_data->total_compressed_size,
54-
$thrift->meta_data->total_uncompressed_size,
55-
$thrift->meta_data->dictionary_page_offset,
56-
$thrift->meta_data->data_page_offset,
57-
$thrift->meta_data->index_page_offset,
53+
(int) $thrift->meta_data->total_compressed_size,
54+
(int) $thrift->meta_data->total_uncompressed_size,
55+
$thrift->meta_data->dictionary_page_offset !== null ? (int) $thrift->meta_data->dictionary_page_offset : null,
56+
$thrift->meta_data->data_page_offset !== null ? (int) $thrift->meta_data->data_page_offset : null,
57+
$thrift->meta_data->index_page_offset !== null ? (int) $thrift->meta_data->index_page_offset : null,
5858
$thrift->meta_data->statistics ? Statistics::fromThrift($thrift->meta_data->statistics) : null,
5959
$options
6060
);

src/lib/parquet/src/Flow/Parquet/ParquetFile/Schema/FlatColumn.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public static function fromThrift(SchemaElement $thrift) : self
9595
$thrift->converted_type === null ? null : ConvertedType::from($thrift->converted_type),
9696
$thrift->logicalType === null ? null : LogicalType::fromThrift($thrift->logicalType),
9797
$thrift->repetition_type === null ? null : Repetition::from($thrift->repetition_type),
98-
$thrift->precision,
99-
$thrift->scale,
100-
$thrift->type_length,
98+
$thrift->precision !== null ? (int) $thrift->precision : null,
99+
$thrift->scale !== null ? (int) $thrift->scale : null,
100+
$thrift->type_length !== null ? (int) $thrift->type_length : null,
101101
);
102102
}
103103

src/lib/parquet/src/Flow/Parquet/ParquetFile/Schema/LogicalType/Decimal.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public function __construct(
1717
public static function fromThrift(DecimalType $thrift) : self
1818
{
1919
return new self(
20-
$thrift->scale,
21-
$thrift->precision
20+
(int) $thrift->scale,
21+
(int) $thrift->precision
2222
);
2323
}
2424

src/lib/parquet/src/Flow/Parquet/ParquetFile/Statistics.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static function fromThrift(\Flow\Parquet\ThriftModel\Statistics $thrift)
2424
return new self(
2525
$thrift->max,
2626
$thrift->min,
27-
$thrift->null_count,
28-
$thrift->distinct_count,
27+
$thrift->null_count !== null ? (int) $thrift->null_count : null,
28+
$thrift->distinct_count !== null ? (int) $thrift->distinct_count : null,
2929
$thrift->max_value,
3030
$thrift->min_value,
3131
$thrift->is_max_value_exact,

0 commit comments

Comments
 (0)