Remove unused code (#1320)
This commit is contained in:
@ -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);
|
||||
|
||||
62
be/src/olap/env/env.h
vendored
62
be/src/olap/env/env.h
vendored
@ -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<Slice>& 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;
|
||||
};
|
||||
|
||||
}
|
||||
117
be/src/olap/env/io_posix.cpp
vendored
117
be/src/olap/env/io_posix.cpp
vendored
@ -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 <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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<size_t>(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<uint8_t *>(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();
|
||||
}
|
||||
|
||||
}
|
||||
46
be/src/olap/env/io_posix.h
vendored
46
be/src/olap/env/io_posix.h
vendored
@ -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 <string>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user