Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new and memcpy row for unsaferowopt #2352

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions hybridse/src/vm/core_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ hybridse::codec::Row CoreAPI::RowProject(const RawPtrHandle fn,
if (row.empty()) {
return hybridse::codec::Row();
}

// Init current run step runtime
JitRuntime::get()->InitRunStep();

Expand All @@ -225,8 +226,10 @@ hybridse::codec::Row CoreAPI::RowProject(const RawPtrHandle fn,
const_cast<int8_t*>(fn));

auto row_ptr = reinterpret_cast<const int8_t*>(&row);

// TODO(tobe): do not need to pass parameter row for offline
auto parameter_ptr = reinterpret_cast<const int8_t*>(&parameter);

int8_t* buf = nullptr;
uint32_t ret = udf(0, row_ptr, nullptr, parameter_ptr, &buf);

Expand All @@ -237,6 +240,7 @@ hybridse::codec::Row CoreAPI::RowProject(const RawPtrHandle fn,
LOG(WARNING) << "fail to run udf " << ret;
return hybridse::codec::Row();
}

return Row(base::RefCountedSlice::CreateManaged(
buf, hybridse::codec::RowView::GetSize(buf)));
}
Expand Down Expand Up @@ -340,11 +344,14 @@ hybridse::codec::Row CoreAPI::UnsafeWindowProjectDirect(
const int inputRowSizeInBytes, const bool is_instance, size_t append_slices,
WindowInterface* window) {

auto bufPtr = reinterpret_cast<int8_t *>(inputUnsafeRowBytes);

// Create Row from input UnsafeRow bytes
auto row = Row(base::RefCountedSlice::Create(bufPtr, inputRowSizeInBytes));
// auto bufPtr = reinterpret_cast<int8_t *>(inputUnsafeRowBytes);
// auto row = Row(base::RefCountedSlice::Create(bufPtr, inputRowSizeInBytes));

// Notice that we need to use new pointer for buffering rows in window list
int8_t* bufPtr = reinterpret_cast<int8_t*>(malloc(inputRowSizeInBytes));
memcpy(bufPtr, inputUnsafeRowBytes, inputRowSizeInBytes);
auto row = Row(base::RefCountedSlice::CreateManaged(bufPtr, inputRowSizeInBytes));

return Runner::WindowProject(fn, key, row, Row(), is_instance, append_slices,
window->GetWindow());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ object RowProjectPlan {
val outputArr = Array.fill[Any](outputFields)(null)

val resultIter = partitionIter.map(row => {

// Encode the spark row to native row
val nativeInputRow = encoder.encode(row)

Expand Down