Skip to content

Commit fbefe75

Browse files
committed
2 parents 24ce3e3 + 7f07a66 commit fbefe75

File tree

6 files changed

+126
-215
lines changed

6 files changed

+126
-215
lines changed

src/function/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "cloud-function"
2+
name = "function"
33
version = "0.1.0"
44
description = "The generic cloud functions for serverless computation."
55
authors = [ "Gang Liao <[email protected]>" ]

src/function/src/aws/lambda.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ fn invoke_async_functions(ctx: &ExecutionContext, batches: &mut Vec<RecordBatch>
9999
loop {
100100
let request = InvokeAsyncRequest {
101101
function_name: next_func.clone(),
102-
invoke_args: Payload::to_bytes(&[batches.pop().unwrap()], uuid.clone()),
102+
invoke_args: Payload::to_vec(
103+
&[batches.pop().unwrap()],
104+
uuid.clone(),
105+
Encoding::default(),
106+
)
107+
.into(),
103108
};
104109

105110
if let Ok(reponse) = block_on(client.invoke_async(request)) {
@@ -204,7 +209,7 @@ async fn payload_handler(ctx: &mut ExecutionContext, event: Value) -> Result<Val
204209
ctx.feed_one_source(&vec![batches]);
205210
let batches = ctx.execute().await?;
206211

207-
Ok(Payload::to_value(&batches, uuid))
212+
Ok(Payload::to_value(&batches, uuid, Encoding::default()))
208213
}
209214

210215
async fn handler(event: Value, _: Context) -> Result<Value> {

src/runtime/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl ExecutionContext {
145145
Encoding::Snappy | Encoding::Lz4 | Encoding::Zstd => {
146146
let encoded: Vec<u8> = serde_json::to_vec(&self).unwrap();
147147
serde_json::to_string(&CloudEnvironment {
148-
context: encoding.compress(&encoded),
148+
context: encoding.compress(encoded),
149149
encoding,
150150
})
151151
.unwrap()

src/runtime/src/encoding.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ impl Default for Encoding {
5151

5252
impl Encoding {
5353
/// Compress data
54-
pub fn compress(&self, s: &[u8]) -> Vec<u8> {
54+
pub fn compress(&self, s: Vec<u8>) -> Vec<u8> {
5555
match *self {
5656
Encoding::Snappy => {
5757
let mut encoder = snap::raw::Encoder::new();
5858
encoder.compress_vec(&s).unwrap()
5959
}
6060
Encoding::Lz4 => lz4::block::compress(&s, None, true).unwrap(),
6161
Encoding::Zstd => zstd::block::compress(&s, 3).unwrap(),
62-
_ => {
63-
unimplemented!();
64-
}
62+
Encoding::None => s,
63+
_ => unimplemented!(),
6564
}
6665
}
6766

@@ -149,7 +148,7 @@ mod tests {
149148
let json = serde_json::to_string(&plan).unwrap();
150149

151150
let now = Instant::now();
152-
let en_json = en.compress(&json.as_bytes());
151+
let en_json = en.compress(json.as_bytes().to_vec());
153152
println!("Compression time: {} μs", now.elapsed().as_micros());
154153

155154
let now = Instant::now();

src/runtime/src/executor/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use crate::config::GLOBALS as globals;
2828
use crate::context::CloudFunction;
2929
use crate::context::ExecutionContext;
30+
use crate::encoding::Encoding;
3031
use crate::error::{Result, SquirtleError};
3132
use crate::payload::{Payload, Uuid};
3233
use arrow::record_batch::RecordBatch;
@@ -123,7 +124,11 @@ pub trait Executor {
123124
assert_eq!(1, output_partitions.len());
124125
assert_eq!(1, output_partitions[0].len());
125126

126-
Ok(Payload::to_value(&output_partitions[0], Uuid::default()))
127+
Ok(Payload::to_value(
128+
&output_partitions[0],
129+
Uuid::default(),
130+
Encoding::default(),
131+
))
127132
}
128133
}
129134

0 commit comments

Comments
 (0)