Поддержка Mongo ObjectId (#1833)

* update build script (gcc-5 -> gcc-7)

* add gitlab-ci

* sadly but my gitlab worker doesn't have make

* fix gitlkab-ci config

* fix the input device is not a TTY

* set runner tag to docker

* allow to use ObjectId in clickhouse (oid will be converted to string)

* update ci config

* code review
This commit is contained in:
Pavel Litvinenko 2018-02-01 14:26:44 +03:00 committed by Vitaliy Lyudvichenko
parent c74970c098
commit 7db8e99300
4 changed files with 67 additions and 13 deletions

42
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,42 @@
stages:
- build
variables:
GIT_SUBMODULE_STRATEGY: recursive
# NEXUS_USER:
# NEXUS_PASSWORD:
# NEXUS_HOST:
builder:
stage: builder
when: manual
services:
- docker:dind
before_script:
- docker info
- apk add --no-cache git curl binutils ca-certificates
- docker login -u gitlab -p nopasswd $CI_REGISTRY
- docker build -t yandex/clickhouse-builder ./docker/builder
script:
- docker tag yandex/clickhouse-builder $CI_REGISTRY/yandex/clickhouse-builder
- docker push $CI_REGISTRY/yandex/clickhouse-builder
tags:
- docker
build:
stage: build
services:
- docker:dind
before_script:
- cd ./docker/builder
- docker info
- docker build -t yandex/clickhouse-builder .
script:
- docker run --rm --volumes-from "${HOSTNAME}-build" --workdir "${CI_PROJECT_DIR}" --env CI_PROJECT_DIR=${CI_PROJECT_DIR} $CI_REGISTRY/yandex/clickhouse-builder /build_gitlab_ci.sh
# # You can upload your binary to nexus
# after_script:
# - curl -v --keepalive-time 60 --keepalive --user "$NEXUS_USER:$NEXUS_PASSWORD" -XPUT "http://$NEXUS_HOST/repository/binaries/$CI_PROJECT_NAME" --upload-file ./dbms/src/Server/clickhouse
# Or download artifacts from gitlab
artifacts:
paths:
- ./dbms/src/Server/clickhouse
expire_in: 1 day
tags:
- docker

View File

@ -10,6 +10,7 @@
#include <Poco/MongoDB/Connection.h>
#include <Poco/MongoDB/Cursor.h>
#include <Poco/MongoDB/Element.h>
#include <Poco/MongoDB/ObjectId.h>
#pragma GCC diagnostic pop
#include <Dictionaries/DictionaryStructure.h>
@ -48,6 +49,7 @@ String MongoDBBlockInputStream::getID() const
namespace
{
using ValueType = ExternalResultDescription::ValueType;
using ObjectId = Poco::MongoDB::ObjectId;
template <typename T>
void insertNumber(IColumn & column, const Poco::MongoDB::Element & value, const std::string & name)
@ -97,14 +99,22 @@ namespace
case ValueType::String:
{
if (value.type() != Poco::MongoDB::ElementTraits<String>::TypeId)
throw Exception{
"Type mismatch, expected String, got type id = " + toString(value.type()) +
" for column " + name, ErrorCodes::TYPE_MISMATCH};
if (value.type() == Poco::MongoDB::ElementTraits<ObjectId::Ptr>::TypeId)
{
std::string string_id = value.toString();
static_cast<ColumnString &>(column).insertDataWithTerminatingZero(string_id.data(), string_id.size() + 1);
break;
}
else if (value.type() == Poco::MongoDB::ElementTraits<String>::TypeId)
{
String string = static_cast<const Poco::MongoDB::ConcreteElement<String> &>(value).value();
static_cast<ColumnString &>(column).insertDataWithTerminatingZero(string.data(), string.size() + 1);
break;
}
String string = static_cast<const Poco::MongoDB::ConcreteElement<String> &>(value).value();
static_cast<ColumnString &>(column).insertDataWithTerminatingZero(string.data(), string.size() + 1);
break;
throw Exception{
"Type mismatch, expected String, got type id = " + toString(value.type()) +
" for column " + name, ErrorCodes::TYPE_MISMATCH};
}
case ValueType::Date:

View File

@ -6,9 +6,10 @@ RUN apt-get install -y software-properties-common && \
add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get update -y && \
apt-get install -y cmake libssl-dev libcrypto++-dev \
apt-get install -y git cmake3 libssl-dev libcrypto++-dev \
libglib2.0-dev libltdl-dev libicu-dev libmysql++-dev \
gcc-5 g++-5 unixodbc-dev
libreadline-dev libmysqlclient-dev unixodbc-dev \
gcc-7 g++-7 unixodbc-dev devscripts dupload fakeroot debhelper
ADD build.sh /
RUN chmod +x /build.sh

View File

@ -1,10 +1,11 @@
#!/bin/bash
NPROC=8
export THREADS=$(grep -c ^processor /proc/cpuinfo)
export CC=gcc-7
export CXX=g++-7
mkdir -p /server/build
cd /server/build
CXX=g++-5 CC=gcc-5 cmake /server
make -j $(NPROC)
cmake /server
make -j $THREADS