From ba44249f808e4b0cd7cd231734edf676fc57e93c Mon Sep 17 00:00:00 2001 From: ZHAO Chun Date: Sat, 15 Jun 2019 20:41:48 +0800 Subject: [PATCH] Remove unused code (#1320) --- be/src/exec/broker_scan_node.cpp | 2 +- be/src/olap/env/env.h | 62 ---------------- be/src/olap/env/io_posix.cpp | 117 ------------------------------- be/src/olap/env/io_posix.h | 46 ------------ 4 files changed, 1 insertion(+), 226 deletions(-) delete mode 100644 be/src/olap/env/env.h delete mode 100644 be/src/olap/env/io_posix.cpp delete mode 100644 be/src/olap/env/io_posix.h diff --git a/be/src/exec/broker_scan_node.cpp b/be/src/exec/broker_scan_node.cpp index e107e39d8d..480cad306e 100644 --- a/be/src/exec/broker_scan_node.cpp +++ b/be/src/exec/broker_scan_node.cpp @@ -322,7 +322,7 @@ Status BrokerScanNode::scanner_scan( // The reason we check if partition_expr_ctxs is empty is when loading data to // a unpartitioned table who has no partition_expr_ctxs, user can specify - // a partition name. And we check here to aovid this check and make our + // a partition name. And we check here to avoid crash and make our // process run as normal if (scan_range.params.__isset.partition_ids && !partition_expr_ctxs.empty()) { int64_t partition_id = get_partition_id(partition_expr_ctxs, row); diff --git a/be/src/olap/env/env.h b/be/src/olap/env/env.h deleted file mode 100644 index 6a3999a85a..0000000000 --- a/be/src/olap/env/env.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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 "common/status.h" -#include "util/slice.h" - -namespace doris { - -class RandomAccessFile { -public: - RandomAccessFile() { } - virtual ~RandomAccessFile() { } - - // Read "result.size" bytes from the file starting at "offset". - // Copies the resulting data into "result.data". - // - // If an error was encountered, returns a non-OK status. - // - // This method will internally retry on EINTR and "short reads" in order to - // fully read the requested number of bytes. In the event that it is not - // possible to read exactly 'length' bytes, an IOError is returned. - // - // Safe for concurrent use by multiple threads. - virtual Status read_at(uint64_t offset, const Slice& result) const = 0; - - // Reads up to the "results" aggregate size, based on each Slice's "size", - // from the file starting at 'offset'. The Slices must point to already-allocated - // buffers for the data to be written to. - // - // If an error was encountered, returns a non-OK status. - // - // This method will internally retry on EINTR and "short reads" in order to - // fully read the requested number of bytes. In the event that it is not - // possible to read exactly 'length' bytes, an IOError is returned. - // - // Safe for concurrent use by multiple threads. - virtual Status read_at(uint64_t offset, const std::vector& result) const = 0; - - // Return the size of this file - virtual Status size(uint64_t* size) const = 0; - - // Return name of this file - virtual std::string file_name() const = 0; -}; - -} diff --git a/be/src/olap/env/io_posix.cpp b/be/src/olap/env/io_posix.cpp deleted file mode 100644 index 4a4ffb0b2f..0000000000 --- a/be/src/olap/env/io_posix.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// 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. - -// Copyright (c) 2011 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. - -#include "env/io_posix.h" - -#include -#include -#include -#include - -#include "common/logging.h" -#include "gutil/macro.h" -#include "gutil/port.h" -#include "util/slice.h" - -namespace doris { - -static Status do_readv_at(const std::string& filename, uint64_t offset, - const Slice* res, size_t res_cnt) { - // Convert the results into the iovec vector to request - // and calculate the total bytes requested - size_t bytes_req = 0; - struct iovec iov[res_cnt]; - for (size_t i = 0; i < res_cnt; i++) { - Slice& result = results[i]; - bytes_req += result.size(); - iov[i] = { result.mutable_data(), result.size() }; - } - - uint64_t cur_offset = offset; - size_t completed_iov = 0; - size_t rem = bytes_req; - while (rem > 0) { - // Never request more than IOV_MAX in one request - size_t iov_count = std::min(res_cnt - completed_iov, static_cast(IOV_MAX)); - ssize_t r; - RETRY_ON_EINTR(r, preadv(fd, iov + completed_iov, iov_count, cur_offset)); - - if (PREDICT_FALSE(r < 0)) { - // An error: return a non-ok status. - // TODO(zc): return IOError(filename, errno); - return Status::InternalError("IOError"); - } - - if (PREDICT_FALSE(r == 0)) { - // EOF. - // return Status::EndOfFile( - // Substitute("EOF trying to read $0 bytes at offset $1", bytes_req, offset)); - return Status::InternalError("EOF"); - } - - if (PREDICT_TRUE(r == rem)) { - // All requested bytes were read. This is almost always the case. - return Status::OK()(); - } - DCHECK_LE(r, rem); - // Adjust iovec vector based on bytes read for the next request - ssize_t bytes_rem = r; - for (size_t i = completed_iov; i < res_cnt; i++) { - if (bytes_rem >= iov[i].iov_len) { - // The full length of this iovec was read - completed_iov++; - bytes_rem -= iov[i].iov_len; - } else { - // Partially read this result. - // Adjust the iov_len and iov_base to request only the missing data. - iov[i].iov_base = static_cast(iov[i].iov_base) + bytes_rem; - iov[i].iov_len -= bytes_rem; - break; // Don't need to adjust remaining iovec's - } - } - cur_offset += r; - rem -= r; - } - DCHECK_EQ(0, rem); - return Status::OK(); -} - -PosixRandomAccessFile::~PosixRandomAccessFile() { - int res; - RETRY_ON_EINTR(res, close(_fd)); - if (res != 0) { - char buf[64]; - LOG(WARNING) << "close file failed, name=" << _filename - << ", errno=" << errno << ", msg=" << strerror_r(errno, buf, 64); - } -} - -Status PosixRandomAccessFile::size(uint64_t* size) const { - struct stat st; - auto res = fstat(_fd, &st); - if (res != 0) { - return Status::InternalError("failed to get file stat"); - } - *size = st.st_size; - return Status::OK(); -} - -} diff --git a/be/src/olap/env/io_posix.h b/be/src/olap/env/io_posix.h deleted file mode 100644 index 7ff70b7076..0000000000 --- a/be/src/olap/env/io_posix.h +++ /dev/null @@ -1,46 +0,0 @@ -// 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 - -#include "olap/env/io_posix.h" - -namespace doris { - -class PosixRandomAccessFile : public RandomAccessFile { -public: - PosixRandomAccessFile(std::string filename, int fd) : _filename(std::move(filename)), _fd(fd) { - } - ~PosixRandomAccessFile() override; - - Status read_at(uint64_t offset, const Slice& result) override { - return read_at(offset, &result, 1); - } - - Status readv_at(uint64_t offset, const Slice* result, size_t count) override; - - Status size(uint64_t* size) const override; - - const std::string& filename() const override { return _filename; } -private: - std::string _filename; - int _fd; -}; - -}