This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch doris-for-zhongjin in repository https://gitbox.apache.org/repos/asf/doris.git
commit 0ec48da508eba7911a5fb72c823a733e37dfa61f Author: morningman <[email protected]> AuthorDate: Tue Apr 4 16:23:00 2023 +0800 [zhongjin] add tbds hadoop deps and build script --- be/CMakeLists.txt | 12 +- be/src/io/fs/hdfs.h | 2 +- be/src/util/jni-util.cpp | 5 - be/src/util/jni-util.h | 5 - bin/start_be.sh | 22 +- build.sh | 2 + thirdparty/build-thirdparty-for-tbds.sh | 51 ++ thirdparty/tbds_deps/include/tbds/Pipes.hh | 260 ------ thirdparty/tbds_deps/include/tbds/SerialUtils.hh | 170 ---- thirdparty/tbds_deps/include/tbds/StringUtils.hh | 81 -- .../tbds_deps/include/tbds/TemplateFactory.hh | 96 --- thirdparty/tbds_deps/include/tbds/hdfs.h | 938 --------------------- thirdparty/tbds_deps/lib/libhdfs.a | Bin 98692 -> 0 bytes 13 files changed, 81 insertions(+), 1563 deletions(-) diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 9cf43325ae..62e0f3bd79 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -626,7 +626,7 @@ include_directories( SYSTEM ${GENSRC_DIR}/ ${THIRDPARTY_DIR}/include - ${THIRDPARTY_DIR}/../tbds_deps/include + ${THIRDPARTY_DIR}/../hadoop_tbds/include/ ${GPERFTOOLS_HOME}/include ) include_directories($ENV{JAVA_HOME}/include) @@ -766,12 +766,16 @@ set(COMMON_THIRDPARTY ) if (ARCH_AMD64 AND OS_LINUX) - add_library(hadoop_hdfs STATIC IMPORTED) - #set_target_properties(hadoop_hdfs PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib/hadoop_hdfs/native/libhdfs.a) - set_target_properties(hadoop_hdfs PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/../tbds_deps/lib/libhdfs.a) + add_library(hadoop_hdfs SHARED IMPORTED) + set_target_properties(hadoop_hdfs PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/../hadoop_tbds/lib/native/libhdfs.so) + + add_library(jvm SHARED IMPORTED) + FILE(GLOB_RECURSE LIB_JVM $ENV{JAVA_HOME}/jre/lib/*/libjvm.so) + set_target_properties(jvm PROPERTIES IMPORTED_LOCATION ${LIB_JVM}) set(COMMON_THIRDPARTY ${COMMON_THIRDPARTY} + jvm hadoop_hdfs ) add_definitions(-DUSE_HADOOP_HDFS) diff --git a/be/src/io/fs/hdfs.h b/be/src/io/fs/hdfs.h index d802df1004..f158d76b8f 100644 --- a/be/src/io/fs/hdfs.h +++ b/be/src/io/fs/hdfs.h @@ -18,7 +18,7 @@ #pragma once #ifdef USE_HADOOP_HDFS -#include <tbds/hdfs.h> +#include <hdfs.h> #else #include <hdfs/hdfs.h> #endif diff --git a/be/src/util/jni-util.cpp b/be/src/util/jni-util.cpp index 955efb78e7..fa14866808 100644 --- a/be/src/util/jni-util.cpp +++ b/be/src/util/jni-util.cpp @@ -165,7 +165,6 @@ Status JniLocalFrame::push(JNIEnv* env, int max_local_ref) { Status JniUtil::GetJNIEnvSlowPath(JNIEnv** env) { DCHECK(!tls_env_) << "Call GetJNIEnv() fast path"; -#ifdef USE_LIBHDFS3 std::call_once(g_vm_once, FindOrCreateJavaVM); int rc = g_vm->GetEnv(reinterpret_cast<void**>(&tls_env_), JNI_VERSION_1_8); if (rc == JNI_EDETACHED) { @@ -174,10 +173,6 @@ Status JniUtil::GetJNIEnvSlowPath(JNIEnv** env) { if (rc != 0 || tls_env_ == nullptr) { return Status::InternalError("Unable to get JVM: {}", rc); } -#else - // the hadoop libhdfs will do all the stuff - tls_env_ = getJNIEnv(); -#endif *env = tls_env_; return Status::OK(); } diff --git a/be/src/util/jni-util.h b/be/src/util/jni-util.h index ec5f6abf6e..5aa8be9a1f 100644 --- a/be/src/util/jni-util.h +++ b/be/src/util/jni-util.h @@ -23,11 +23,6 @@ #include "gutil/macros.h" #include "util/thrift_util.h" -#ifdef USE_HADOOP_HDFS -// defined in hadoop_hdfs/hdfs.h -extern "C" JNIEnv* getJNIEnv(void); -#endif - namespace doris { #define RETURN_ERROR_IF_EXC(env) \ diff --git a/bin/start_be.sh b/bin/start_be.sh old mode 100755 new mode 100644 index bbaea90c02..443a76340e --- a/bin/start_be.sh +++ b/bin/start_be.sh @@ -269,9 +269,25 @@ fi # set LIBHDFS_OPTS for hadoop libhdfs export LIBHDFS_OPTS="${JAVA_OPTS}" -#echo "CLASSPATH: ${CLASSPATH}" -#echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}" -#echo "LIBHDFS_OPTS: ${LIBHDFS_OPTS}" +jvm_arch="amd64" +MACHINE_TYPE=$(uname -m) +if [[ "${MACHINE_TYPE}" == "aarch64" ]]; then + jvm_arch="aarch64" +fi +# JAVA_HOME is jdk +if [[ -d "$JAVA_HOME/jre" ]]; then + export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/$jvm_arch/server:$JAVA_HOME/jre/lib/$jvm_arch:$LD_LIBRARY_PATH +# JAVA_HOME is jre +else + export LD_LIBRARY_PATH=$JAVA_HOME/lib/$jvm_arch/server:$JAVA_HOME/lib/$jvm_arch:$LD_LIBRARY_PATH +fi + +# libhdfs +export LD_LIBRARY_PATH=${DORIS_HOME}/lib/hadoop-tbds/lib/native/:$LD_LIBRARY_PATH + +echo "CLASSPATH: ${CLASSPATH}" +echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}" +echo "LIBHDFS_OPTS: ${LIBHDFS_OPTS}" # see https://github.com/apache/doris/blob/master/docs/zh-CN/community/developer-guide/debug-tool.md#jemalloc-heap-profile export JEMALLOC_CONF="percpu_arena:percpu,background_thread:true,metadata_thp:auto,muzzy_decay_ms:30000,dirty_decay_ms:30000,oversize_threshold:0,lg_tcache_max:16,prof_prefix:jeprof.out" diff --git a/build.sh b/build.sh index e89d71ca72..bab521d6ca 100755 --- a/build.sh +++ b/build.sh @@ -550,6 +550,8 @@ if [[ "${OUTPUT_BE_BINARY}" -eq 1 ]]; then if [[ -d "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" ]]; then cp -r -p "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" "${DORIS_OUTPUT}/be/lib/" fi + # tbds hadoop + cp -r -p "${DORIS_THIRDPARTY}/hadoop_tbds" "${DORIS_OUTPUT}/be/lib/" if [[ "${DISABLE_JAVA_UDF_IN_CONF}" -eq 1 ]]; then echo -e "\033[33;1mWARNNING: \033[37;1mDisable Java UDF support in be.conf due to the BE was built without Java UDF.\033[0m" diff --git a/thirdparty/build-thirdparty-for-tbds.sh b/thirdparty/build-thirdparty-for-tbds.sh new file mode 100755 index 0000000000..6d2598e19d --- /dev/null +++ b/thirdparty/build-thirdparty-for-tbds.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# shellcheck disable=2034 + +# 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. + +################################################################################# +# This script will +# 1. Check prerequisite libraries. Including: +# cmake byacc flex automake libtool binutils-dev libiberty-dev bison +# 2. Compile and install all thirdparties which are downloaded +# using *download-thirdparty.sh*. +# +# This script will run *download-thirdparty.sh* once again +# to check if all thirdparties have been downloaded, unpacked and patched. +################################################################################# + +set -eo pipefail + +curdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" + +export DORIS_HOME="${curdir}/.." +export TP_DIR="${curdir}" + +TBDS_HADOOP=hadoop-2.2.0.0-2041-tbds-5.2.0.1.tar.xz +THIRDPARTY_INSTALLED=installed-for-tbds-with-thrift13.tar.xz +DOWNLOAD_LINK=https://tencent-tbds-1308700295.cos.ap-beijing.myqcloud.com + +wget --no-check-certificate -q "${DOWNLOAD_LINK}/${THIRDPARTY_INSTALLED}" -O "${TP_DIR}/${THIRDPARTY_INSTALLED}" +wget --no-check-certificate -q "${DOWNLOAD_LINK}/${TBDS_HADOOP}" -O "${TP_DIR}/${TBDS_HADOOP}" + +tar xf "${TP_DIR}/${THIRDPARTY_INSTALLED}" +tar xf "${TP_DIR}/${TBDS_HADOOP}" +mv "${TP_DIR}/hadoop" "${TP_DIR}/hadoop_tbds" + +echo "Finished" + diff --git a/thirdparty/tbds_deps/include/tbds/Pipes.hh b/thirdparty/tbds_deps/include/tbds/Pipes.hh deleted file mode 100755 index b5d0ddd172..0000000000 --- a/thirdparty/tbds_deps/include/tbds/Pipes.hh +++ /dev/null @@ -1,260 +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. - */ -#ifndef HADOOP_PIPES_HH -#define HADOOP_PIPES_HH - -#ifdef SWIG -%module (directors="1") HadoopPipes -%include "std_string.i" -%feature("director") Mapper; -%feature("director") Reducer; -%feature("director") Partitioner; -%feature("director") RecordReader; -%feature("director") RecordWriter; -%feature("director") Factory; -#else -#include <string> -#endif - -#include <stdint.h> - -namespace HadoopPipes { - -/** - * This interface defines the interface between application code and the - * foreign code interface to Hadoop Map/Reduce. - */ - -/** - * A JobConf defines the properties for a job. - */ -class JobConf { -public: - virtual bool hasKey(const std::string& key) const = 0; - virtual const std::string& get(const std::string& key) const = 0; - virtual int getInt(const std::string& key) const = 0; - virtual float getFloat(const std::string& key) const = 0; - virtual bool getBoolean(const std::string&key) const = 0; - virtual ~JobConf() {} -}; - -/** - * Task context provides the information about the task and job. - */ -class TaskContext { -public: - /** - * Counter to keep track of a property and its value. - */ - class Counter { - private: - int id; - public: - Counter(int counterId) : id(counterId) {} - Counter(const Counter& counter) : id(counter.id) {} - - int getId() const { return id; } - }; - - /** - * Get the JobConf for the current task. - */ - virtual const JobConf* getJobConf() = 0; - - /** - * Get the current key. - * @return the current key - */ - virtual const std::string& getInputKey() = 0; - - /** - * Get the current value. - * @return the current value - */ - virtual const std::string& getInputValue() = 0; - - /** - * Generate an output record - */ - virtual void emit(const std::string& key, const std::string& value) = 0; - - /** - * Mark your task as having made progress without changing the status - * message. - */ - virtual void progress() = 0; - - /** - * Set the status message and call progress. - */ - virtual void setStatus(const std::string& status) = 0; - - /** - * Register a counter with the given group and name. - */ - virtual Counter* - getCounter(const std::string& group, const std::string& name) = 0; - - /** - * Increment the value of the counter with the given amount. - */ - virtual void incrementCounter(const Counter* counter, uint64_t amount) = 0; - - virtual ~TaskContext() {} -}; - -class MapContext: public TaskContext { -public: - - /** - * Access the InputSplit of the mapper. - */ - virtual const std::string& getInputSplit() = 0; - - /** - * Get the name of the key class of the input to this task. - */ - virtual const std::string& getInputKeyClass() = 0; - - /** - * Get the name of the value class of the input to this task. - */ - virtual const std::string& getInputValueClass() = 0; - -}; - -class ReduceContext: public TaskContext { -public: - /** - * Advance to the next value. - */ - virtual bool nextValue() = 0; -}; - -class Closable { -public: - virtual void close() {} - virtual ~Closable() {} -}; - -/** - * The application's mapper class to do map. - */ -class Mapper: public Closable { -public: - virtual void map(MapContext& context) = 0; -}; - -/** - * The application's reducer class to do reduce. - */ -class Reducer: public Closable { -public: - virtual void reduce(ReduceContext& context) = 0; -}; - -/** - * User code to decide where each key should be sent. - */ -class Partitioner { -public: - virtual int partition(const std::string& key, int numOfReduces) = 0; - virtual ~Partitioner() {} -}; - -/** - * For applications that want to read the input directly for the map function - * they can define RecordReaders in C++. - */ -class RecordReader: public Closable { -public: - virtual bool next(std::string& key, std::string& value) = 0; - - /** - * The progress of the record reader through the split as a value between - * 0.0 and 1.0. - */ - virtual float getProgress() = 0; -}; - -/** - * An object to write key/value pairs as they are emited from the reduce. - */ -class RecordWriter: public Closable { -public: - virtual void emit(const std::string& key, - const std::string& value) = 0; -}; - -/** - * A factory to create the necessary application objects. - */ -class Factory { -public: - virtual Mapper* createMapper(MapContext& context) const = 0; - virtual Reducer* createReducer(ReduceContext& context) const = 0; - - /** - * Create a combiner, if this application has one. - * @return the new combiner or NULL, if one is not needed - */ - virtual Reducer* createCombiner(MapContext& context) const { - return NULL; - } - - /** - * Create an application partitioner object. - * @return the new partitioner or NULL, if the default partitioner should be - * used. - */ - virtual Partitioner* createPartitioner(MapContext& context) const { - return NULL; - } - - /** - * Create an application record reader. - * @return the new RecordReader or NULL, if the Java RecordReader should be - * used. - */ - virtual RecordReader* createRecordReader(MapContext& context) const { - return NULL; - } - - /** - * Create an application record writer. - * @return the new RecordWriter or NULL, if the Java RecordWriter should be - * used. - */ - virtual RecordWriter* createRecordWriter(ReduceContext& context) const { - return NULL; - } - - virtual ~Factory() {} -}; - -/** - * Run the assigned task in the framework. - * The user's main function should set the various functions using the - * set* functions above and then call this. - * @return true, if the task succeeded. - */ -bool runTask(const Factory& factory); - -} - -#endif diff --git a/thirdparty/tbds_deps/include/tbds/SerialUtils.hh b/thirdparty/tbds_deps/include/tbds/SerialUtils.hh deleted file mode 100755 index cadfd76c02..0000000000 --- a/thirdparty/tbds_deps/include/tbds/SerialUtils.hh +++ /dev/null @@ -1,170 +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. - */ -#ifndef HADOOP_SERIAL_UTILS_HH -#define HADOOP_SERIAL_UTILS_HH - -#include <string> -#include <stdint.h> - -namespace HadoopUtils { - - /** - * A simple exception class that records a message for the user. - */ - class Error { - private: - std::string error; - public: - - /** - * Create an error object with the given message. - */ - Error(const std::string& msg); - - /** - * Construct an error object with the given message that was created on - * the given file, line, and functino. - */ - Error(const std::string& msg, - const std::string& file, int line, const std::string& function); - - /** - * Get the error message. - */ - const std::string& getMessage() const; - }; - - /** - * Check to make sure that the condition is true, and throw an exception - * if it is not. The exception will contain the message and a description - * of the source location. - */ - #define HADOOP_ASSERT(CONDITION, MESSAGE) \ - { \ - if (!(CONDITION)) { \ - throw HadoopUtils::Error((MESSAGE), __FILE__, __LINE__, \ - __func__); \ - } \ - } - - /** - * An interface for an input stream. - */ - class InStream { - public: - /** - * Reads len bytes from the stream into the buffer. - * @param buf the buffer to read into - * @param buflen the length of the buffer - * @throws Error if there are problems reading - */ - virtual void read(void *buf, size_t len) = 0; - virtual ~InStream() {} - }; - - /** - * An interface for an output stream. - */ - class OutStream { - public: - /** - * Write the given buffer to the stream. - * @param buf the data to write - * @param len the number of bytes to write - * @throws Error if there are problems writing - */ - virtual void write(const void *buf, size_t len) = 0; - /** - * Flush the data to the underlying store. - */ - virtual void flush() = 0; - virtual ~OutStream() {} - }; - - /** - * A class to read a file as a stream. - */ - class FileInStream : public InStream { - public: - FileInStream(); - bool open(const std::string& name); - bool open(FILE* file); - void read(void *buf, size_t buflen); - bool skip(size_t nbytes); - bool close(); - virtual ~FileInStream(); - private: - /** - * The file to write to. - */ - FILE *mFile; - /** - * Does is this class responsible for closing the FILE*? - */ - bool isOwned; - }; - - /** - * A class to write a stream to a file. - */ - class FileOutStream: public OutStream { - public: - - /** - * Create a stream that isn't bound to anything. - */ - FileOutStream(); - - /** - * Create the given file, potentially overwriting an existing file. - */ - bool open(const std::string& name, bool overwrite); - bool open(FILE* file); - void write(const void* buf, size_t len); - bool advance(size_t nbytes); - void flush(); - bool close(); - virtual ~FileOutStream(); - private: - FILE *mFile; - bool isOwned; - }; - - /** - * A stream that reads from a string. - */ - class StringInStream: public InStream { - public: - StringInStream(const std::string& str); - virtual void read(void *buf, size_t buflen); - private: - const std::string& buffer; - std::string::const_iterator itr; - }; - - void serializeInt(int32_t t, OutStream& stream); - int32_t deserializeInt(InStream& stream); - void serializeLong(int64_t t, OutStream& stream); - int64_t deserializeLong(InStream& stream); - void serializeFloat(float t, OutStream& stream); - float deserializeFloat(InStream& stream); - void serializeString(const std::string& t, OutStream& stream); - void deserializeString(std::string& t, InStream& stream); -} - -#endif diff --git a/thirdparty/tbds_deps/include/tbds/StringUtils.hh b/thirdparty/tbds_deps/include/tbds/StringUtils.hh deleted file mode 100755 index 4720172725..0000000000 --- a/thirdparty/tbds_deps/include/tbds/StringUtils.hh +++ /dev/null @@ -1,81 +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. - */ -#ifndef HADOOP_STRING_UTILS_HH -#define HADOOP_STRING_UTILS_HH - -#include <stdint.h> -#include <string> -#include <vector> - -namespace HadoopUtils { - - /** - * Convert an integer to a string. - */ - std::string toString(int32_t x); - - /** - * Convert a string to an integer. - * @throws Error if the string is not a valid integer - */ - int32_t toInt(const std::string& val); - - /** - * Convert the string to a float. - * @throws Error if the string is not a valid float - */ - float toFloat(const std::string& val); - - /** - * Convert the string to a boolean. - * @throws Error if the string is not a valid boolean value - */ - bool toBool(const std::string& val); - - /** - * Get the current time in the number of milliseconds since 1970. - */ - uint64_t getCurrentMillis(); - - /** - * Split a string into "words". Multiple deliminators are treated as a single - * word break, so no zero-length words are returned. - * @param str the string to split - * @param separator a list of characters that divide words - */ - std::vector<std::string> splitString(const std::string& str, - const char* separator); - - /** - * Quote a string to avoid "\", non-printable characters, and the - * deliminators. - * @param str the string to quote - * @param deliminators the set of characters to always quote - */ - std::string quoteString(const std::string& str, - const char* deliminators); - - /** - * Unquote the given string to return the original string. - * @param str the string to unquote - */ - std::string unquoteString(const std::string& str); - -} - -#endif diff --git a/thirdparty/tbds_deps/include/tbds/TemplateFactory.hh b/thirdparty/tbds_deps/include/tbds/TemplateFactory.hh deleted file mode 100755 index 22e10ae56f..0000000000 --- a/thirdparty/tbds_deps/include/tbds/TemplateFactory.hh +++ /dev/null @@ -1,96 +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. - */ -#ifndef HADOOP_PIPES_TEMPLATE_FACTORY_HH -#define HADOOP_PIPES_TEMPLATE_FACTORY_HH - -namespace HadoopPipes { - - template <class mapper, class reducer> - class TemplateFactory2: public Factory { - public: - Mapper* createMapper(MapContext& context) const { - return new mapper(context); - } - Reducer* createReducer(ReduceContext& context) const { - return new reducer(context); - } - }; - - template <class mapper, class reducer, class partitioner> - class TemplateFactory3: public TemplateFactory2<mapper,reducer> { - public: - Partitioner* createPartitioner(MapContext& context) const { - return new partitioner(context); - } - }; - - template <class mapper, class reducer> - class TemplateFactory3<mapper, reducer, void> - : public TemplateFactory2<mapper,reducer> { - }; - - template <class mapper, class reducer, class partitioner, class combiner> - class TemplateFactory4 - : public TemplateFactory3<mapper,reducer,partitioner>{ - public: - Reducer* createCombiner(MapContext& context) const { - return new combiner(context); - } - }; - - template <class mapper, class reducer, class partitioner> - class TemplateFactory4<mapper,reducer,partitioner,void> - : public TemplateFactory3<mapper,reducer,partitioner>{ - }; - - template <class mapper, class reducer, class partitioner, - class combiner, class recordReader> - class TemplateFactory5 - : public TemplateFactory4<mapper,reducer,partitioner,combiner>{ - public: - RecordReader* createRecordReader(MapContext& context) const { - return new recordReader(context); - } - }; - - template <class mapper, class reducer, class partitioner,class combiner> - class TemplateFactory5<mapper,reducer,partitioner,combiner,void> - : public TemplateFactory4<mapper,reducer,partitioner,combiner>{ - }; - - template <class mapper, class reducer, class partitioner=void, - class combiner=void, class recordReader=void, - class recordWriter=void> - class TemplateFactory - : public TemplateFactory5<mapper,reducer,partitioner,combiner,recordReader>{ - public: - RecordWriter* createRecordWriter(ReduceContext& context) const { - return new recordWriter(context); - } - }; - - template <class mapper, class reducer, class partitioner, - class combiner, class recordReader> - class TemplateFactory<mapper, reducer, partitioner, combiner, recordReader, - void> - : public TemplateFactory5<mapper,reducer,partitioner,combiner,recordReader>{ - }; - -} - -#endif diff --git a/thirdparty/tbds_deps/include/tbds/hdfs.h b/thirdparty/tbds_deps/include/tbds/hdfs.h deleted file mode 100755 index 5b7bc1e386..0000000000 --- a/thirdparty/tbds_deps/include/tbds/hdfs.h +++ /dev/null @@ -1,938 +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. - */ - -#ifndef LIBHDFS_HDFS_H -#define LIBHDFS_HDFS_H - -#include <errno.h> /* for EINTERNAL, etc. */ -#include <fcntl.h> /* for O_RDONLY, O_WRONLY */ -#include <stdint.h> /* for uint64_t, etc. */ -#include <time.h> /* for time_t */ - -/* - * Support export of DLL symbols during libhdfs build, and import of DLL symbols - * during client application build. A client application may optionally define - * symbol LIBHDFS_DLL_IMPORT in its build. This is not strictly required, but - * the compiler can produce more efficient code with it. - */ -#ifdef WIN32 - #ifdef LIBHDFS_DLL_EXPORT - #define LIBHDFS_EXTERNAL __declspec(dllexport) - #elif LIBHDFS_DLL_IMPORT - #define LIBHDFS_EXTERNAL __declspec(dllimport) - #else - #define LIBHDFS_EXTERNAL - #endif -#else - #ifdef LIBHDFS_DLL_EXPORT - #define LIBHDFS_EXTERNAL __attribute__((visibility("default"))) - #elif LIBHDFS_DLL_IMPORT - #define LIBHDFS_EXTERNAL __attribute__((visibility("default"))) - #else - #define LIBHDFS_EXTERNAL - #endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 1 -#endif - -#ifndef O_WRONLY -#define O_WRONLY 2 -#endif - -#ifndef EINTERNAL -#define EINTERNAL 255 -#endif - -#define ELASTIC_BYTE_BUFFER_POOL_CLASS \ - "org/apache/hadoop/io/ElasticByteBufferPool" - -/** All APIs set errno to meaningful values */ - -#ifdef __cplusplus -extern "C" { -#endif - /** - * Some utility decls used in libhdfs. - */ - struct hdfsBuilder; - typedef int32_t tSize; /// size of data for read/write io ops - typedef time_t tTime; /// time type in seconds - typedef int64_t tOffset;/// offset within the file - typedef uint16_t tPort; /// port - typedef enum tObjectKind { - kObjectKindFile = 'F', - kObjectKindDirectory = 'D', - } tObjectKind; - - - /** - * The C reflection of org.apache.org.hadoop.FileSystem . - */ - struct hdfs_internal; - typedef struct hdfs_internal* hdfsFS; - - struct hdfsFile_internal; - typedef struct hdfsFile_internal* hdfsFile; - - struct hadoopRzOptions; - - struct hadoopRzBuffer; - - /** - * Determine if a file is open for read. - * - * @param file The HDFS file - * @return 1 if the file is open for read; 0 otherwise - */ - LIBHDFS_EXTERNAL - int hdfsFileIsOpenForRead(hdfsFile file); - - /** - * Determine if a file is open for write. - * - * @param file The HDFS file - * @return 1 if the file is open for write; 0 otherwise - */ - LIBHDFS_EXTERNAL - int hdfsFileIsOpenForWrite(hdfsFile file); - - struct hdfsReadStatistics { - uint64_t totalBytesRead; - uint64_t totalLocalBytesRead; - uint64_t totalShortCircuitBytesRead; - uint64_t totalZeroCopyBytesRead; - }; - - /** - * Get read statistics about a file. This is only applicable to files - * opened for reading. - * - * @param file The HDFS file - * @param stats (out parameter) on a successful return, the read - * statistics. Unchanged otherwise. You must free the - * returned statistics with hdfsFileFreeReadStatistics. - * @return 0 if the statistics were successfully returned, - * -1 otherwise. On a failure, please check errno against - * ENOTSUP. webhdfs, LocalFilesystem, and so forth may - * not support read statistics. - */ - LIBHDFS_EXTERNAL - int hdfsFileGetReadStatistics(hdfsFile file, - struct hdfsReadStatistics **stats); - - /** - * @param stats HDFS read statistics for a file. - * - * @return the number of remote bytes read. - */ - LIBHDFS_EXTERNAL - int64_t hdfsReadStatisticsGetRemoteBytesRead( - const struct hdfsReadStatistics *stats); - - /** - * Clear the read statistics for a file. - * - * @param file The file to clear the read statistics of. - * - * @return 0 on success; the error code otherwise. - * EINVAL: the file is not open for reading. - * ENOTSUP: the file does not support clearing the read - * statistics. - * Errno will also be set to this code on failure. - */ - LIBHDFS_EXTERNAL - int hdfsFileClearReadStatistics(hdfsFile file); - - /** - * Free some HDFS read statistics. - * - * @param stats The HDFS read statistics to free. - */ - LIBHDFS_EXTERNAL - void hdfsFileFreeReadStatistics(struct hdfsReadStatistics *stats); - - /** - * hdfsConnectAsUser - Connect to a hdfs file system as a specific user - * Connect to the hdfs. - * @param nn The NameNode. See hdfsBuilderSetNameNode for details. - * @param port The port on which the server is listening. - * @param user the user name (this is hadoop domain user). Or NULL is equivelant to hhdfsConnect(host, port) - * @return Returns a handle to the filesystem or NULL on error. - * @deprecated Use hdfsBuilderConnect instead. - */ - LIBHDFS_EXTERNAL - hdfsFS hdfsConnectAsUser(const char* nn, tPort port, const char *user); - - /** - * hdfsConnect - Connect to a hdfs file system. - * Connect to the hdfs. - * @param nn The NameNode. See hdfsBuilderSetNameNode for details. - * @param port The port on which the server is listening. - * @return Returns a handle to the filesystem or NULL on error. - * @deprecated Use hdfsBuilderConnect instead. - */ - LIBHDFS_EXTERNAL - hdfsFS hdfsConnect(const char* nn, tPort port); - - /** - * hdfsConnect - Connect to an hdfs file system. - * - * Forces a new instance to be created - * - * @param nn The NameNode. See hdfsBuilderSetNameNode for details. - * @param port The port on which the server is listening. - * @param user The user name to use when connecting - * @return Returns a handle to the filesystem or NULL on error. - * @deprecated Use hdfsBuilderConnect instead. - */ - LIBHDFS_EXTERNAL - hdfsFS hdfsConnectAsUserNewInstance(const char* nn, tPort port, const char *user ); - - /** - * hdfsConnect - Connect to an hdfs file system. - * - * Forces a new instance to be created - * - * @param nn The NameNode. See hdfsBuilderSetNameNode for details. - * @param port The port on which the server is listening. - * @return Returns a handle to the filesystem or NULL on error. - * @deprecated Use hdfsBuilderConnect instead. - */ - LIBHDFS_EXTERNAL - hdfsFS hdfsConnectNewInstance(const char* nn, tPort port); - - /** - * Connect to HDFS using the parameters defined by the builder. - * - * The HDFS builder will be freed, whether or not the connection was - * successful. - * - * Every successful call to hdfsBuilderConnect should be matched with a call - * to hdfsDisconnect, when the hdfsFS is no longer needed. - * - * @param bld The HDFS builder - * @return Returns a handle to the filesystem, or NULL on error. - */ - LIBHDFS_EXTERNAL - hdfsFS hdfsBuilderConnect(struct hdfsBuilder *bld); - - /** - * Create an HDFS builder. - * - * @return The HDFS builder, or NULL on error. - */ - LIBHDFS_EXTERNAL - struct hdfsBuilder *hdfsNewBuilder(void); - - /** - * Force the builder to always create a new instance of the FileSystem, - * rather than possibly finding one in the cache. - * - * @param bld The HDFS builder - */ - LIBHDFS_EXTERNAL - void hdfsBuilderSetForceNewInstance(struct hdfsBuilder *bld); - - /** - * Set the HDFS NameNode to connect to. - * - * @param bld The HDFS builder - * @param nn The NameNode to use. - * - * If the string given is 'default', the default NameNode - * configuration will be used (from the XML configuration files) - * - * If NULL is given, a LocalFileSystem will be created. - * - * If the string starts with a protocol type such as file:// or - * hdfs://, this protocol type will be used. If not, the - * hdfs:// protocol type will be used. - * - * You may specify a NameNode port in the usual way by - * passing a string of the format hdfs://<hostname>:<port>. - * Alternately, you may set the port with - * hdfsBuilderSetNameNodePort. However, you must not pass the - * port in two different ways. - */ - LIBHDFS_EXTERNAL - void hdfsBuilderSetNameNode(struct hdfsBuilder *bld, const char *nn); - - /** - * Set the port of the HDFS NameNode to connect to. - * - * @param bld The HDFS builder - * @param port The port. - */ - LIBHDFS_EXTERNAL - void hdfsBuilderSetNameNodePort(struct hdfsBuilder *bld, tPort port); - - /** - * Set the username to use when connecting to the HDFS cluster. - * - * @param bld The HDFS builder - * @param userName The user name. The string will be shallow-copied. - */ - LIBHDFS_EXTERNAL - void hdfsBuilderSetUserName(struct hdfsBuilder *bld, const char *userName); - - /** - * Set the path to the Kerberos ticket cache to use when connecting to - * the HDFS cluster. - * - * @param bld The HDFS builder - * @param kerbTicketCachePath The Kerberos ticket cache path. The string - * will be shallow-copied. - */ - LIBHDFS_EXTERNAL - void hdfsBuilderSetKerbTicketCachePath(struct hdfsBuilder *bld, - const char *kerbTicketCachePath); - - /** - * Free an HDFS builder. - * - * It is normally not necessary to call this function since - * hdfsBuilderConnect frees the builder. - * - * @param bld The HDFS builder - */ - LIBHDFS_EXTERNAL - void hdfsFreeBuilder(struct hdfsBuilder *bld); - - /** - * Set a configuration string for an HdfsBuilder. - * - * @param key The key to set. - * @param val The value, or NULL to set no value. - * This will be shallow-copied. You are responsible for - * ensuring that it remains valid until the builder is - * freed. - * - * @return 0 on success; nonzero error code otherwise. - */ - LIBHDFS_EXTERNAL - int hdfsBuilderConfSetStr(struct hdfsBuilder *bld, const char *key, - const char *val); - - /** - * Get a configuration string. - * - * @param key The key to find - * @param val (out param) The value. This will be set to NULL if the - * key isn't found. You must free this string with - * hdfsConfStrFree. - * - * @return 0 on success; nonzero error code otherwise. - * Failure to find the key is not an error. - */ - LIBHDFS_EXTERNAL - int hdfsConfGetStr(const char *key, char **val); - - /** - * Get a configuration integer. - * - * @param key The key to find - * @param val (out param) The value. This will NOT be changed if the - * key isn't found. - * - * @return 0 on success; nonzero error code otherwise. - * Failure to find the key is not an error. - */ - LIBHDFS_EXTERNAL - int hdfsConfGetInt(const char *key, int32_t *val); - - /** - * Free a configuration string found with hdfsConfGetStr. - * - * @param val A configuration string obtained from hdfsConfGetStr - */ - LIBHDFS_EXTERNAL - void hdfsConfStrFree(char *val); - - /** - * hdfsDisconnect - Disconnect from the hdfs file system. - * Disconnect from hdfs. - * @param fs The configured filesystem handle. - * @return Returns 0 on success, -1 on error. - * Even if there is an error, the resources associated with the - * hdfsFS will be freed. - */ - LIBHDFS_EXTERNAL - int hdfsDisconnect(hdfsFS fs); - - - /** - * hdfsOpenFile - Open a hdfs file in given mode. - * @param fs The configured filesystem handle. - * @param path The full path to the file. - * @param flags - an | of bits/fcntl.h file flags - supported flags are O_RDONLY, O_WRONLY (meaning create or overwrite i.e., implies O_TRUNCAT), - * O_WRONLY|O_APPEND. Other flags are generally ignored other than (O_RDWR || (O_EXCL & O_CREAT)) which return NULL and set errno equal ENOTSUP. - * @param bufferSize Size of buffer for read/write - pass 0 if you want - * to use the default configured values. - * @param replication Block replication - pass 0 if you want to use - * the default configured values. - * @param blocksize Size of block - pass 0 if you want to use the - * default configured values. - * @return Returns the handle to the open file or NULL on error. - */ - LIBHDFS_EXTERNAL - hdfsFile hdfsOpenFile(hdfsFS fs, const char* path, int flags, - int bufferSize, short replication, tSize blocksize); - - /** - * hdfsTruncateFile - Truncate a hdfs file to given lenght. - * @param fs The configured filesystem handle. - * @param path The full path to the file. - * @param newlength The size the file is to be truncated to - * @return 1 if the file has been truncated to the desired newlength - * and is immediately available to be reused for write operations - * such as append. - * 0 if a background process of adjusting the length of the last - * block has been started, and clients should wait for it to - * complete before proceeding with further file updates. - * -1 on error. - */ - int hdfsTruncateFile(hdfsFS fs, const char* path, tOffset newlength); - - /** - * hdfsUnbufferFile - Reduce the buffering done on a file. - * - * @param file The file to unbuffer. - * @return 0 on success - * ENOTSUP if the file does not support unbuffering - * Errno will also be set to this value. - */ - LIBHDFS_EXTERNAL - int hdfsUnbufferFile(hdfsFile file); - - /** - * hdfsCloseFile - Close an open file. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @return Returns 0 on success, -1 on error. - * On error, errno will be set appropriately. - * If the hdfs file was valid, the memory associated with it will - * be freed at the end of this call, even if there was an I/O - * error. - */ - LIBHDFS_EXTERNAL - int hdfsCloseFile(hdfsFS fs, hdfsFile file); - - - /** - * hdfsExists - Checks if a given path exsits on the filesystem - * @param fs The configured filesystem handle. - * @param path The path to look for - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsExists(hdfsFS fs, const char *path); - - - /** - * hdfsSeek - Seek to given offset in file. - * This works only for files opened in read-only mode. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @param desiredPos Offset into the file to seek into. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos); - - - /** - * hdfsTell - Get the current offset in the file, in bytes. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @return Current offset, -1 on error. - */ - LIBHDFS_EXTERNAL - tOffset hdfsTell(hdfsFS fs, hdfsFile file); - - - /** - * hdfsRead - Read data from an open file. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @param buffer The buffer to copy read bytes into. - * @param length The length of the buffer. - * @return On success, a positive number indicating how many bytes - * were read. - * On end-of-file, 0. - * On error, -1. Errno will be set to the error code. - * Just like the POSIX read function, hdfsRead will return -1 - * and set errno to EINTR if data is temporarily unavailable, - * but we are not yet at the end of the file. - */ - LIBHDFS_EXTERNAL - tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length); - - /** - * hdfsPread - Positional read of data from an open file. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @param position Position from which to read - * @param buffer The buffer to copy read bytes into. - * @param length The length of the buffer. - * @return See hdfsRead - */ - LIBHDFS_EXTERNAL - tSize hdfsPread(hdfsFS fs, hdfsFile file, tOffset position, - void* buffer, tSize length); - - - /** - * hdfsWrite - Write data into an open file. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @param buffer The data. - * @param length The no. of bytes to write. - * @return Returns the number of bytes written, -1 on error. - */ - LIBHDFS_EXTERNAL - tSize hdfsWrite(hdfsFS fs, hdfsFile file, const void* buffer, - tSize length); - - - /** - * hdfsWrite - Flush the data. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsFlush(hdfsFS fs, hdfsFile file); - - - /** - * hdfsHFlush - Flush out the data in client's user buffer. After the - * return of this call, new readers will see the data. - * @param fs configured filesystem handle - * @param file file handle - * @return 0 on success, -1 on error and sets errno - */ - LIBHDFS_EXTERNAL - int hdfsHFlush(hdfsFS fs, hdfsFile file); - - - /** - * hdfsHSync - Similar to posix fsync, Flush out the data in client's - * user buffer. all the way to the disk device (but the disk may have - * it in its cache). - * @param fs configured filesystem handle - * @param file file handle - * @return 0 on success, -1 on error and sets errno - */ - LIBHDFS_EXTERNAL - int hdfsHSync(hdfsFS fs, hdfsFile file); - - - /** - * hdfsAvailable - Number of bytes that can be read from this - * input stream without blocking. - * @param fs The configured filesystem handle. - * @param file The file handle. - * @return Returns available bytes; -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsAvailable(hdfsFS fs, hdfsFile file); - - - /** - * hdfsCopy - Copy file from one filesystem to another. - * @param srcFS The handle to source filesystem. - * @param src The path of source file. - * @param dstFS The handle to destination filesystem. - * @param dst The path of destination file. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsCopy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst); - - - /** - * hdfsMove - Move file from one filesystem to another. - * @param srcFS The handle to source filesystem. - * @param src The path of source file. - * @param dstFS The handle to destination filesystem. - * @param dst The path of destination file. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsMove(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst); - - - /** - * hdfsDelete - Delete file. - * @param fs The configured filesystem handle. - * @param path The path of the file. - * @param recursive if path is a directory and set to - * non-zero, the directory is deleted else throws an exception. In - * case of a file the recursive argument is irrelevant. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsDelete(hdfsFS fs, const char* path, int recursive); - - /** - * hdfsRename - Rename file. - * @param fs The configured filesystem handle. - * @param oldPath The path of the source file. - * @param newPath The path of the destination file. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsRename(hdfsFS fs, const char* oldPath, const char* newPath); - - - /** - * hdfsGetWorkingDirectory - Get the current working directory for - * the given filesystem. - * @param fs The configured filesystem handle. - * @param buffer The user-buffer to copy path of cwd into. - * @param bufferSize The length of user-buffer. - * @return Returns buffer, NULL on error. - */ - LIBHDFS_EXTERNAL - char* hdfsGetWorkingDirectory(hdfsFS fs, char *buffer, size_t bufferSize); - - - /** - * hdfsSetWorkingDirectory - Set the working directory. All relative - * paths will be resolved relative to it. - * @param fs The configured filesystem handle. - * @param path The path of the new 'cwd'. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsSetWorkingDirectory(hdfsFS fs, const char* path); - - - /** - * hdfsCreateDirectory - Make the given file and all non-existent - * parents into directories. - * @param fs The configured filesystem handle. - * @param path The path of the directory. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsCreateDirectory(hdfsFS fs, const char* path); - - - /** - * hdfsSetReplication - Set the replication of the specified - * file to the supplied value - * @param fs The configured filesystem handle. - * @param path The path of the file. - * @return Returns 0 on success, -1 on error. - */ - LIBHDFS_EXTERNAL - int hdfsSetReplication(hdfsFS fs, const char* path, int16_t replication); - - - /** - * hdfsFileInfo - Information about a file/directory. - */ - typedef struct { - tObjectKind mKind; /* file or directory */ - char *mName; /* the name of the file */ - tTime mLastMod; /* the last modification time for the file in seconds */ - tOffset mSize; /* the size of the file in bytes */ - short mReplication; /* the count of replicas */ - tOffset mBlockSize; /* the block size for the file */ - char *mOwner; /* the owner of the file */ - char *mGroup; /* the group associated with the file */ - short mPermissions; /* the permissions associated with the file */ - tTime mLastAccess; /* the last access time for the file in seconds */ - } hdfsFileInfo; - - - /** - * hdfsListDirectory - Get list of files/directories for a given - * directory-path. hdfsFreeFileInfo should be called to deallocate memory. - * @param fs The configured filesystem handle. - * @param path The path of the directory. - * @param numEntries Set to the number of files/directories in path. - * @return Returns a dynamically-allocated array of hdfsFileInfo - * objects; NULL on error. - */ - LIBHDFS_EXTERNAL - hdfsFileInfo *hdfsListDirectory(hdfsFS fs, const char* path, - int *numEntries); - - - /** - * hdfsGetPathInfo - Get information about a path as a (dynamically - * allocated) single hdfsFileInfo struct. hdfsFreeFileInfo should be - * called when the pointer is no longer needed. - * @param fs The configured filesystem handle. - * @param path The path of the file. - * @return Returns a dynamically-allocated hdfsFileInfo object; - * NULL on error. - */ - LIBHDFS_EXTERNAL - hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path); - - - /** - * hdfsFreeFileInfo - Free up the hdfsFileInfo array (including fields) - * @param hdfsFileInfo The array of dynamically-allocated hdfsFileInfo - * objects. - * @param numEntries The size of the array. - */ - LIBHDFS_EXTERNAL - void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries); - - /** - * hdfsFileIsEncrypted: determine if a file is encrypted based on its - * hdfsFileInfo. - * @return -1 if there was an error (errno will be set), 0 if the file is - * not encrypted, 1 if the file is encrypted. - */ - LIBHDFS_EXTERNAL - int hdfsFileIsEncrypted(hdfsFileInfo *hdfsFileInfo); - - - /** - * hdfsGetHosts - Get hostnames where a particular block (determined by - * pos & blocksize) of a file is stored. The last element in the array - * is NULL. Due to replication, a single block could be present on - * multiple hosts. - * @param fs The configured filesystem handle. - * @param path The path of the file. - * @param start The start of the block. - * @param length The length of the block. - * @return Returns a dynamically-allocated 2-d array of blocks-hosts; - * NULL on error. - */ - LIBHDFS_EXTERNAL - char*** hdfsGetHosts(hdfsFS fs, const char* path, - tOffset start, tOffset length); - - - /** - * hdfsFreeHosts - Free up the structure returned by hdfsGetHosts - * @param hdfsFileInfo The array of dynamically-allocated hdfsFileInfo - * objects. - * @param numEntries The size of the array. - */ - LIBHDFS_EXTERNAL - void hdfsFreeHosts(char ***blockHosts); - - - /** - * hdfsGetDefaultBlockSize - Get the default blocksize. - * - * @param fs The configured filesystem handle. - * @deprecated Use hdfsGetDefaultBlockSizeAtPath instead. - * - * @return Returns the default blocksize, or -1 on error. - */ - LIBHDFS_EXTERNAL - tOffset hdfsGetDefaultBlockSize(hdfsFS fs); - - - /** - * hdfsGetDefaultBlockSizeAtPath - Get the default blocksize at the - * filesystem indicated by a given path. - * - * @param fs The configured filesystem handle. - * @param path The given path will be used to locate the actual - * filesystem. The full path does not have to exist. - * - * @return Returns the default blocksize, or -1 on error. - */ - LIBHDFS_EXTERNAL - tOffset hdfsGetDefaultBlockSizeAtPath(hdfsFS fs, const char *path); - - - /** - * hdfsGetCapacity - Return the raw capacity of the filesystem. - * @param fs The configured filesystem handle. - * @return Returns the raw-capacity; -1 on error. - */ - LIBHDFS_EXTERNAL - tOffset hdfsGetCapacity(hdfsFS fs); - - - /** - * hdfsGetUsed - Return the total raw size of all files in the filesystem. - * @param fs The configured filesystem handle. - * @return Returns the total-size; -1 on error. - */ - LIBHDFS_EXTERNAL - tOffset hdfsGetUsed(hdfsFS fs); - - /** - * Change the user and/or group of a file or directory. - * - * @param fs The configured filesystem handle. - * @param path the path to the file or directory - * @param owner User string. Set to NULL for 'no change' - * @param group Group string. Set to NULL for 'no change' - * @return 0 on success else -1 - */ - LIBHDFS_EXTERNAL - int hdfsChown(hdfsFS fs, const char* path, const char *owner, - const char *group); - - /** - * hdfsChmod - * @param fs The configured filesystem handle. - * @param path the path to the file or directory - * @param mode the bitmask to set it to - * @return 0 on success else -1 - */ - LIBHDFS_EXTERNAL - int hdfsChmod(hdfsFS fs, const char* path, short mode); - - /** - * hdfsUtime - * @param fs The configured filesystem handle. - * @param path the path to the file or directory - * @param mtime new modification time or -1 for no change - * @param atime new access time or -1 for no change - * @return 0 on success else -1 - */ - LIBHDFS_EXTERNAL - int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime); - - /** - * Allocate a zero-copy options structure. - * - * You must free all options structures allocated with this function using - * hadoopRzOptionsFree. - * - * @return A zero-copy options structure, or NULL if one could - * not be allocated. If NULL is returned, errno will - * contain the error number. - */ - LIBHDFS_EXTERNAL - struct hadoopRzOptions *hadoopRzOptionsAlloc(void); - - /** - * Determine whether we should skip checksums in read0. - * - * @param opts The options structure. - * @param skip Nonzero to skip checksums sometimes; zero to always - * check them. - * - * @return 0 on success; -1 plus errno on failure. - */ - LIBHDFS_EXTERNAL - int hadoopRzOptionsSetSkipChecksum( - struct hadoopRzOptions *opts, int skip); - - /** - * Set the ByteBufferPool to use with read0. - * - * @param opts The options structure. - * @param className If this is NULL, we will not use any - * ByteBufferPool. If this is non-NULL, it will be - * treated as the name of the pool class to use. - * For example, you can use - * ELASTIC_BYTE_BUFFER_POOL_CLASS. - * - * @return 0 if the ByteBufferPool class was found and - * instantiated; - * -1 plus errno otherwise. - */ - LIBHDFS_EXTERNAL - int hadoopRzOptionsSetByteBufferPool( - struct hadoopRzOptions *opts, const char *className); - - /** - * Free a hadoopRzOptionsFree structure. - * - * @param opts The options structure to free. - * Any associated ByteBufferPool will also be freed. - */ - LIBHDFS_EXTERNAL - void hadoopRzOptionsFree(struct hadoopRzOptions *opts); - - /** - * Perform a byte buffer read. - * If possible, this will be a zero-copy (mmap) read. - * - * @param file The file to read from. - * @param opts An options structure created by hadoopRzOptionsAlloc. - * @param maxLength The maximum length to read. We may read fewer bytes - * than this length. - * - * @return On success, we will return a new hadoopRzBuffer. - * This buffer will continue to be valid and readable - * until it is released by readZeroBufferFree. Failure to - * release a buffer will lead to a memory leak. - * You can access the data within the hadoopRzBuffer with - * hadoopRzBufferGet. If you have reached EOF, the data - * within the hadoopRzBuffer will be NULL. You must still - * free hadoopRzBuffer instances containing NULL. - * - * On failure, we will return NULL plus an errno code. - * errno = EOPNOTSUPP indicates that we could not do a - * zero-copy read, and there was no ByteBufferPool - * supplied. - */ - LIBHDFS_EXTERNAL - struct hadoopRzBuffer* hadoopReadZero(hdfsFile file, - struct hadoopRzOptions *opts, int32_t maxLength); - - /** - * Determine the length of the buffer returned from readZero. - * - * @param buffer a buffer returned from readZero. - * @return the length of the buffer. - */ - LIBHDFS_EXTERNAL - int32_t hadoopRzBufferLength(const struct hadoopRzBuffer *buffer); - - /** - * Get a pointer to the raw buffer returned from readZero. - * - * To find out how many bytes this buffer contains, call - * hadoopRzBufferLength. - * - * @param buffer a buffer returned from readZero. - * @return a pointer to the start of the buffer. This will be - * NULL when end-of-file has been reached. - */ - LIBHDFS_EXTERNAL - const void *hadoopRzBufferGet(const struct hadoopRzBuffer *buffer); - - /** - * Release a buffer obtained through readZero. - * - * @param file The hdfs stream that created this buffer. This must be - * the same stream you called hadoopReadZero on. - * @param buffer The buffer to release. - */ - LIBHDFS_EXTERNAL - void hadoopRzBufferFree(hdfsFile file, struct hadoopRzBuffer *buffer); - -#ifdef __cplusplus -} -#endif - -#undef LIBHDFS_EXTERNAL -#endif /*LIBHDFS_HDFS_H*/ - -/** - * vim: ts=4: sw=4: et - */ diff --git a/thirdparty/tbds_deps/lib/libhdfs.a b/thirdparty/tbds_deps/lib/libhdfs.a deleted file mode 100644 index 2bb83df066..0000000000 Binary files a/thirdparty/tbds_deps/lib/libhdfs.a and /dev/null differ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
