提交 688a9992 编写于 作者: G groot

fix make error


Former-commit-id: 7a5d078a48a92b0595e67bf8fe9891a075044bf4
上级 4cbdb587
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include "AttributeSerializer.h"
namespace zilliz {
namespace vecwise {
namespace server {
void AttributeSerializer::Encode(const std::map<std::string, std::string>& attrib, std::string& result) {
}
void AttributeSerializer::Decode(const std::string& str, std::map<std::string, std::string>& result) {
}
}
}
}
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include <map>
namespace zilliz {
namespace vecwise {
namespace server {
class AttributeSerializer {
public:
static void Encode(const std::map<std::string, std::string>& attrib, std::string& result);
static void Decode(const std::string& str, std::map<std::string, std::string>& result);
};
}
}
}
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include "StringHelpFunctions.h"
namespace zilliz {
namespace vecwise {
namespace server {
void StringHelpFunctions::TrimStringLineBreak(std::string &string) {
if (!string.empty()) {
static std::string s_format("\n\r");
string.erase(string.find_last_not_of(s_format) + 1);
}
}
void StringHelpFunctions::TrimStringBlank(std::string &string) {
if (!string.empty()) {
static std::string s_format(" \n\r\t");
string.erase(0, string.find_first_not_of(s_format));
string.erase(string.find_last_not_of(s_format) + 1);
}
}
void StringHelpFunctions::TrimStringQuote(std::string &string, const std::string &qoute) {
if (!string.empty()) {
string.erase(0, string.find_first_not_of(qoute));
string.erase(string.find_last_not_of(qoute) + 1);
}
}
ServerError StringHelpFunctions::SplitStringByDelimeter(const std::string &str,
const std::string &delimeter,
std::vector<std::string> &result) {
size_t last = 0;
size_t index = str.find_first_of(delimeter, last);
while (index != std::string::npos) {
result.emplace_back(str.substr(last, index - last));
last = index + 1;
index = str.find_first_of(delimeter, last);
}
if (index - last > 0) {
std::string temp = str.substr(last);
result.emplace_back(temp);
}
return SERVER_SUCCESS;
}
ServerError StringHelpFunctions::SplitStringByQuote(const std::string &str,
const std::string &delimeter,
const std::string &quote,
std::vector<std::string> &result) {
if (quote.empty()) {
return SplitStringByDelimeter(str, delimeter, result);
}
size_t last = 0;
size_t index = str.find_first_of(quote, last);
if (index == std::string::npos) {
return SplitStringByDelimeter(str, delimeter, result);
}
std::string process_str = str;
while (index != std::string::npos) {
std::string prefix = process_str.substr(last, index - last);
std::string append_prefix;
if (!prefix.empty()) {
std::vector<std::string> prefix_split;
SplitStringByDelimeter(prefix, delimeter, prefix_split);
for (size_t i = 0; i < prefix_split.size() - 1; i++) {
result.push_back(prefix_split[i]);
}
append_prefix = prefix_split[prefix_split.size() - 1];
}
last = index + 1;
std::string postfix = process_str.substr(last);
index = postfix.find_first_of(quote, 0);
if (index == std::string::npos) {
return SERVER_UNEXPECTED_ERROR;
}
std::string quoted_text = postfix.substr(0, index);
append_prefix += quoted_text;
last = index + 1;
index = postfix.find_first_of(delimeter, last);
if (index != std::string::npos) {
if (index > last) {
append_prefix += postfix.substr(last, index - last);
}
} else {
append_prefix += postfix.substr(last);
}
result.emplace_back(append_prefix);
if (last == postfix.length()) {
return SERVER_SUCCESS;
}
process_str = postfix.substr(index + 1);
last = 0;
index = process_str.find_first_of(quote, last);
}
if (!process_str.empty()) {
return SplitStringByDelimeter(process_str, delimeter, result);
}
return SERVER_SUCCESS;
}
}
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "./Error.h"
#include <vector>
namespace zilliz {
namespace vecwise {
namespace server {
class StringHelpFunctions {
private:
StringHelpFunctions() = default;
public:
static void TrimStringLineBreak(std::string &string);
static void TrimStringBlank(std::string &string);
static void TrimStringQuote(std::string &string, const std::string &qoute);
//split string by delimeter ','
// a,b,c a | b | c
// a,b, a | b |
// ,b,c | b | c
// ,b, | b |
// ,, | |
// a a
static ServerError SplitStringByDelimeter(const std::string &str,
const std::string &delimeter,
std::vector<std::string> &result);
//assume the table has two columns, quote='\"', delimeter=','
// a,b a | b
// "aa,gg,yy",b aa,gg,yy | b
// aa"dd,rr"kk,pp aadd,rrkk | pp
// "aa,bb" aa,bb
// 55,1122\"aa,bb\",yyy,\"kkk\" 55 | 1122aa,bb | yyy | kkk
// "55,1122"aa,bb",yyy,"kkk" illegal
static ServerError SplitStringByQuote(const std::string &str,
const std::string &delimeter,
const std::string &quote,
std::vector<std::string> &result);
};
}
}
}
......@@ -12,6 +12,7 @@ set(unittest_srcs
${CMAKE_CURRENT_SOURCE_DIR}/vecwise_test.cpp ${VECWISE_THIRD_PARTY_BUILD}/include/easylogging++.cc)
set(unittest_libs
yaml-cpp
gtest_main
gmock_main
pthread)
......
......@@ -31,7 +31,6 @@ set(db_test_src
cuda_add_executable(db_test ${db_test_src})
set(db_libs
yaml-cpp
faiss
cudart
cublas
......
......@@ -6,24 +6,41 @@
include_directories(../../src)
aux_source_directory(../../src/wrapper wrapper_src)
aux_source_directory(../../src/config config_files)
# Make sure that your call to link_directories takes place before your call to the relevant add_executable.
include_directories(/usr/local/cuda/include)
link_directories("/usr/local/cuda/lib64")
set(require_files
../../src/server/VecIdMapper.cpp
../../src/server/ServerConfig.cpp
../../src/utils/CommonUtil.cpp
../../src/utils/TimeRecorder.cpp
)
set(wrapper_test_src
${unittest_srcs}
${wrapper_src}
${config_files}
${require_files}
wrapper_test.cpp
)
add_executable(wrapper_test ${wrapper_test_src})
set(wrapper_libs
stdc++
boost_system
boost_filesystem
faiss
cudart
cublas
sqlite3
rocksdb
snappy
bz2
z
)
target_link_libraries(wrapper_test ${unittest_libs} ${wrapper_libs})
......
......@@ -32,7 +32,6 @@ cuda_add_executable(server_test
set(require_libs
stdc++
yaml-cpp
boost_system
boost_filesystem
pthread
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册