wangbo commented on a change in pull request #2075: Segment v2 stream load core dump(#2037) URL: https://github.com/apache/incubator-doris/pull/2075#discussion_r341558533
########## File path: be/src/util/owned_slice.h ########## @@ -0,0 +1,82 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "gutil/macros.h" +#include "util/slice.h" + +/** + * used for maintain slice' life cycle + * Attention!!! the input slice must own a data(char*) which using new to allocate memory,or will cause error + */ + +namespace doris { + +/** + * originally make this class pageBuilder',to maintain the life cycle of returned slice + * Attention!!! + * 1. the input slice must own a data(char*) which using new to allocate memory,or will cause error + * 2. don't use std::move for this class + * + * use case: + * fastring buf; + * buf.append(); + * size_t size = buf.size(); + * Slice slice(buf.release(), size); // here is the key point, using buf.release;use buf.data() is error + * + * OwnedSlice owned_slice(slice); + */ +class OwnedSlice { + +public: + OwnedSlice() {_slice.data = nullptr;_slice.size=0;} Review comment: 👌 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org