@@ -42,9 +42,9 @@ use crate::encryption::modules::{create_module_aad, ModuleType};
42
42
use crate :: errors:: { ParquetError , Result } ;
43
43
use crate :: file:: properties:: { BloomFilterPosition , WriterPropertiesPtr } ;
44
44
use crate :: file:: reader:: ChunkReader ;
45
- use crate :: file:: { metadata:: * , PARQUET_MAGIC } ;
46
45
#[ cfg( feature = "encryption" ) ]
47
46
use crate :: file:: PARQUET_MAGIC_ENCR_FOOTER ;
47
+ use crate :: file:: { metadata:: * , PARQUET_MAGIC } ;
48
48
use crate :: schema:: types:: { ColumnDescPtr , SchemaDescPtr , SchemaDescriptor , TypePtr } ;
49
49
50
50
/// A wrapper around a [`Write`] that keeps track of the number
@@ -576,15 +576,24 @@ impl<'a, W: Write + Send> SerializedRowGroupWriter<'a, W> {
576
576
let props = self . props . clone ( ) ;
577
577
#[ cfg( feature = "encryption" ) ]
578
578
let file_encryptor = self . file_encryptor . clone ( ) ;
579
+ #[ cfg( feature = "encryption" ) ]
580
+ let row_group_index = self . row_group_index as usize ;
581
+ #[ cfg( feature = "encryption" ) ]
582
+ let column_index = self . column_index - 1 ;
583
+
579
584
let ( buf, on_close) = self . get_on_close ( ) ;
580
585
#[ cfg( feature = "encryption" ) ]
581
586
let mut page_writer = SerializedPageWriter :: new ( buf) ;
587
+ #[ cfg( feature = "encryption" ) ]
588
+ {
589
+ page_writer. with_row_group_ordinal ( row_group_index) ;
590
+ page_writer. with_column_ordinal ( column_index) ;
591
+ page_writer. with_file_encryptor ( file_encryptor) ;
592
+ }
593
+
582
594
#[ cfg( not( feature = "encryption" ) ) ]
583
595
let page_writer = SerializedPageWriter :: new ( buf) ;
584
596
585
- #[ cfg( feature = "encryption" ) ]
586
- page_writer. with_file_encryptor ( file_encryptor) ;
587
-
588
597
Some ( factory (
589
598
column,
590
599
props,
@@ -765,6 +774,10 @@ pub struct SerializedPageWriter<'a, W: Write> {
765
774
file_encryptor : Option < Arc < FileEncryptor > > ,
766
775
#[ cfg( feature = "encryption" ) ]
767
776
page_ordinal : usize ,
777
+ #[ cfg( feature = "encryption" ) ]
778
+ column_ordinal : usize ,
779
+ #[ cfg( feature = "encryption" ) ]
780
+ row_group_ordinal : usize ,
768
781
}
769
782
770
783
impl < ' a , W : Write > SerializedPageWriter < ' a , W > {
@@ -776,6 +789,10 @@ impl<'a, W: Write> SerializedPageWriter<'a, W> {
776
789
file_encryptor : None ,
777
790
#[ cfg( feature = "encryption" ) ]
778
791
page_ordinal : 0 ,
792
+ #[ cfg( feature = "encryption" ) ]
793
+ column_ordinal : 1 ,
794
+ #[ cfg( feature = "encryption" ) ]
795
+ row_group_ordinal : 0 ,
779
796
}
780
797
}
781
798
@@ -785,6 +802,18 @@ impl<'a, W: Write> SerializedPageWriter<'a, W> {
785
802
self . file_encryptor = file_encryptor;
786
803
}
787
804
805
+ #[ cfg( feature = "encryption" ) ]
806
+ /// Set the column ordinal for this page writer
807
+ fn with_column_ordinal ( & mut self , column_ordinal : usize ) {
808
+ self . column_ordinal = column_ordinal;
809
+ }
810
+
811
+ #[ cfg( feature = "encryption" ) ]
812
+ /// Set the row group ordinal for this page writer
813
+ fn with_row_group_ordinal ( & mut self , row_group_ordinal : usize ) {
814
+ self . row_group_ordinal = row_group_ordinal;
815
+ }
816
+
788
817
/// Serializes page header into Thrift.
789
818
/// Returns number of bytes that have been written into the sink.
790
819
#[ inline]
@@ -796,9 +825,9 @@ impl<'a, W: Write> SerializedPageWriter<'a, W> {
796
825
let aad = create_module_aad (
797
826
file_encryptor. file_aad ( ) ,
798
827
ModuleType :: DataPageHeader ,
799
- 0 ,
800
- 0 ,
801
- Some ( 0 ) ,
828
+ self . row_group_ordinal ,
829
+ self . column_ordinal ,
830
+ Some ( self . page_ordinal ) ,
802
831
) ?;
803
832
encrypt_object ( header, file_encryptor, & mut self . sink , & aad) ?;
804
833
} else {
@@ -833,8 +862,8 @@ impl<W: Write + Send> PageWriter for SerializedPageWriter<'_, W> {
833
862
let aad = create_module_aad (
834
863
encryptor. file_aad ( ) ,
835
864
ModuleType :: DataPage ,
836
- 0 ,
837
- 0 ,
865
+ self . row_group_ordinal ,
866
+ self . column_ordinal ,
838
867
Some ( self . page_ordinal ) ,
839
868
) ?;
840
869
encrypted_buffer = encryptor. get_footer_encryptor ( ) . encrypt ( page. data ( ) , & aad) ;
0 commit comments