@@ -599,8 +599,8 @@ Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousSortMergeJoin(
599
599
}
600
600
601
601
JNIEXPORT jobject JNICALL
602
- Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregateStep1 (
603
- JNIEnv *env, jobject obj, jlong eid, jbyteArray agg_op, jbyteArray input_rows) {
602
+ Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregate (
603
+ JNIEnv *env, jobject obj, jlong eid, jbyteArray agg_op, jbyteArray input_rows, jboolean isPartial ) {
604
604
(void )obj;
605
605
606
606
jboolean if_copy;
@@ -611,98 +611,21 @@ Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregateStep1
611
611
uint32_t input_rows_length = (uint32_t ) env->GetArrayLength (input_rows);
612
612
uint8_t *input_rows_ptr = (uint8_t *) env->GetByteArrayElements (input_rows, &if_copy);
613
613
614
- uint8_t *first_row = nullptr ;
615
- size_t first_row_length = 0 ;
616
-
617
- uint8_t *last_group = nullptr ;
618
- size_t last_group_length = 0 ;
619
-
620
- uint8_t *last_row = nullptr ;
621
- size_t last_row_length = 0 ;
622
-
623
- if (input_rows_ptr == nullptr ) {
624
- ocall_throw (" NonObliviousAggregateStep1: JNI failed to get input byte array." );
625
- } else {
626
- oe_check_and_time (" Non-Oblivious Aggregate Step 1" ,
627
- ecall_non_oblivious_aggregate_step1 (
628
- (oe_enclave_t *)eid,
629
- agg_op_ptr, agg_op_length,
630
- input_rows_ptr, input_rows_length,
631
- &first_row, &first_row_length,
632
- &last_group, &last_group_length,
633
- &last_row, &last_row_length));
634
- }
635
-
636
- jbyteArray first_row_array = env->NewByteArray (first_row_length);
637
- env->SetByteArrayRegion (first_row_array, 0 , first_row_length, (jbyte *) first_row);
638
- free (first_row);
639
-
640
- jbyteArray last_group_array = env->NewByteArray (last_group_length);
641
- env->SetByteArrayRegion (last_group_array, 0 , last_group_length, (jbyte *) last_group);
642
- free (last_group);
643
-
644
- jbyteArray last_row_array = env->NewByteArray (last_row_length);
645
- env->SetByteArrayRegion (last_row_array, 0 , last_row_length, (jbyte *) last_row);
646
- free (last_row);
647
-
648
- env->ReleaseByteArrayElements (agg_op, (jbyte *) agg_op_ptr, 0 );
649
- env->ReleaseByteArrayElements (input_rows, (jbyte *) input_rows_ptr, 0 );
650
-
651
- jclass tuple3_class = env->FindClass (" scala/Tuple3" );
652
- jobject ret = env->NewObject (
653
- tuple3_class,
654
- env->GetMethodID (tuple3_class, " <init>" ,
655
- " (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V" ),
656
- first_row_array, last_group_array, last_row_array);
657
-
658
- return ret;
659
- }
660
-
661
- JNIEXPORT jbyteArray JNICALL
662
- Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregateStep2 (
663
- JNIEnv *env, jobject obj, jlong eid, jbyteArray agg_op, jbyteArray input_rows,
664
- jbyteArray next_partition_first_row, jbyteArray prev_partition_last_group,
665
- jbyteArray prev_partition_last_row) {
666
- (void )obj;
667
-
668
- jboolean if_copy;
669
-
670
- uint32_t agg_op_length = (uint32_t ) env->GetArrayLength (agg_op);
671
- uint8_t *agg_op_ptr = (uint8_t *) env->GetByteArrayElements (agg_op, &if_copy);
672
-
673
- uint32_t input_rows_length = (uint32_t ) env->GetArrayLength (input_rows);
674
- uint8_t *input_rows_ptr = (uint8_t *) env->GetByteArrayElements (input_rows, &if_copy);
675
-
676
- uint32_t next_partition_first_row_length =
677
- (uint32_t ) env->GetArrayLength (next_partition_first_row);
678
- uint8_t *next_partition_first_row_ptr =
679
- (uint8_t *) env->GetByteArrayElements (next_partition_first_row, &if_copy);
680
-
681
- uint32_t prev_partition_last_group_length =
682
- (uint32_t ) env->GetArrayLength (prev_partition_last_group);
683
- uint8_t *prev_partition_last_group_ptr =
684
- (uint8_t *) env->GetByteArrayElements (prev_partition_last_group, &if_copy);
685
-
686
- uint32_t prev_partition_last_row_length =
687
- (uint32_t ) env->GetArrayLength (prev_partition_last_row);
688
- uint8_t *prev_partition_last_row_ptr =
689
- (uint8_t *) env->GetByteArrayElements (prev_partition_last_row, &if_copy);
690
-
691
614
uint8_t *output_rows = nullptr ;
692
615
size_t output_rows_length = 0 ;
693
616
617
+ bool is_partial = (bool ) isPartial;
618
+
694
619
if (input_rows_ptr == nullptr ) {
695
- ocall_throw (" NonObliviousAggregateStep2 : JNI failed to get input byte array." );
620
+ ocall_throw (" NonObliviousAggregateStep : JNI failed to get input byte array." );
696
621
} else {
697
- oe_check_and_time (" Non-Oblivious Aggregate Step 2 " ,
698
- ecall_non_oblivious_aggregate_step2 (
622
+ oe_check_and_time (" Non-Oblivious Aggregate" ,
623
+ ecall_non_oblivious_aggregate (
699
624
(oe_enclave_t *)eid,
700
625
agg_op_ptr, agg_op_length,
701
626
input_rows_ptr, input_rows_length,
702
- next_partition_first_row_ptr, next_partition_first_row_length,
703
- prev_partition_last_group_ptr, prev_partition_last_group_length,
704
- prev_partition_last_row_ptr, prev_partition_last_row_length,
705
- &output_rows, &output_rows_length));
627
+ &output_rows, &output_rows_length,
628
+ is_partial));
706
629
}
707
630
708
631
jbyteArray ret = env->NewByteArray (output_rows_length);
@@ -711,13 +634,7 @@ Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregateStep2
711
634
712
635
env->ReleaseByteArrayElements (agg_op, (jbyte *) agg_op_ptr, 0 );
713
636
env->ReleaseByteArrayElements (input_rows, (jbyte *) input_rows_ptr, 0 );
714
- env->ReleaseByteArrayElements (
715
- next_partition_first_row, (jbyte *) next_partition_first_row_ptr, 0 );
716
- env->ReleaseByteArrayElements (
717
- prev_partition_last_group, (jbyte *) prev_partition_last_group_ptr, 0 );
718
- env->ReleaseByteArrayElements (
719
- prev_partition_last_row, (jbyte *) prev_partition_last_row_ptr, 0 );
720
-
637
+
721
638
return ret;
722
639
}
723
640
0 commit comments