From 6fb3b7c61c493898f8637b9c165a240c86a28ff6 Mon Sep 17 00:00:00 2001 From: ion2014 Date: Thu, 8 Nov 2018 15:27:36 +0800 Subject: [PATCH 1/2] HAWQ-1671. Add compile support for orc formatter and wrapper Changed Makefile in contrib/orc Add folder format and cwrapper for split compilation Add dummy code for testing the Makefile --- contrib/orc/Makefile | 2 +- contrib/orc/cwrapper/cwrapper.c | 18 ++++++++++++++++++ contrib/orc/format/orc_format.c | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 contrib/orc/cwrapper/cwrapper.c create mode 100644 contrib/orc/format/orc_format.c diff --git a/contrib/orc/Makefile b/contrib/orc/Makefile index f793f480cc..fb6854a5b4 100644 --- a/contrib/orc/Makefile +++ b/contrib/orc/Makefile @@ -16,7 +16,7 @@ # under the License. # MODULE_big = orc -OBJS = orc.o +OBJS = cwrapper/cwrapper.o format/orc_format.o orc.o PG_CPPFLAGS = -I$(libpq_srcdir) PG_LIBS = $(libpq_pgport) diff --git a/contrib/orc/cwrapper/cwrapper.c b/contrib/orc/cwrapper/cwrapper.c new file mode 100644 index 0000000000..7220975503 --- /dev/null +++ b/contrib/orc/cwrapper/cwrapper.c @@ -0,0 +1,18 @@ +/* + * 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. + */ \ No newline at end of file diff --git a/contrib/orc/format/orc_format.c b/contrib/orc/format/orc_format.c new file mode 100644 index 0000000000..7220975503 --- /dev/null +++ b/contrib/orc/format/orc_format.c @@ -0,0 +1,18 @@ +/* + * 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. + */ \ No newline at end of file From 883f7d387d36ed5c07dae8bf455a4815731aa4ac Mon Sep 17 00:00:00 2001 From: ion2014 Date: Fri, 9 Nov 2018 15:19:11 +0800 Subject: [PATCH 2/2] HAWQ-1674. Add support for compiling CPP projects in orc_format. add cwrapper.cpp to generate interface code for C/C++ link. changed Makefile to support cpp compiling. --- contrib/orc/Makefile | 12 +++++-- contrib/orc/cwrapper/Makefile | 7 ++++ contrib/orc/cwrapper/cwrapper.cpp | 30 ++++++++++++++++ contrib/orc/cwrapper/cwrapper.h | 35 +++++++++++++++++++ contrib/orc/cwrapper/format/Makefile | 6 ++++ .../format/orc_format.cpp} | 6 +++- .../{cwrapper.c => format/orc_format.h} | 3 +- 7 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 contrib/orc/cwrapper/Makefile create mode 100644 contrib/orc/cwrapper/cwrapper.cpp create mode 100644 contrib/orc/cwrapper/cwrapper.h create mode 100644 contrib/orc/cwrapper/format/Makefile rename contrib/orc/{format/orc_format.c => cwrapper/format/orc_format.cpp} (94%) rename contrib/orc/cwrapper/{cwrapper.c => format/orc_format.h} (97%) diff --git a/contrib/orc/Makefile b/contrib/orc/Makefile index fb6854a5b4..9938d7486e 100644 --- a/contrib/orc/Makefile +++ b/contrib/orc/Makefile @@ -16,12 +16,11 @@ # under the License. # MODULE_big = orc -OBJS = cwrapper/cwrapper.o format/orc_format.o orc.o +OBJS = cwrapper/cwrapper.o orc.o PG_CPPFLAGS = -I$(libpq_srcdir) PG_LIBS = $(libpq_pgport) - ifdef USE_PGXS PGXS := $(shell pg_config --pgxs) include $(PGXS) @@ -30,4 +29,11 @@ subdir = contrib/orc top_builddir = ../.. include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk -endif \ No newline at end of file +endif + +clean distclean: + $(MAKE) -C cwrapper $@ || true; + rm -f orc.o orc.so + +cwrapper/cwrapper.o: + $(MAKE) -C cwrapper cwrapper.o diff --git a/contrib/orc/cwrapper/Makefile b/contrib/orc/cwrapper/Makefile new file mode 100644 index 0000000000..d731af8ad2 --- /dev/null +++ b/contrib/orc/cwrapper/Makefile @@ -0,0 +1,7 @@ +cwrapper.o: cwrapper.cpp cwrapper.h + $(MAKE) -C format liborc_format.so + g++ --shared -o cwrapper.o cwrapper.cpp -Lformat -lorc_format + +clean distclean: + $(MAKE) -C format $@ || true; + rm -f ./cwrapper.o \ No newline at end of file diff --git a/contrib/orc/cwrapper/cwrapper.cpp b/contrib/orc/cwrapper/cwrapper.cpp new file mode 100644 index 0000000000..f7a6376897 --- /dev/null +++ b/contrib/orc/cwrapper/cwrapper.cpp @@ -0,0 +1,30 @@ +/* + * 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. + */ + +#include +#include "format/orc_format.h" +#ifdef __cplusplus +extern "C" { +#endif + void wrap_func_test(){ + func_test(); + } +#ifdef __cplusplus +} +#endif diff --git a/contrib/orc/cwrapper/cwrapper.h b/contrib/orc/cwrapper/cwrapper.h new file mode 100644 index 0000000000..4151265459 --- /dev/null +++ b/contrib/orc/cwrapper/cwrapper.h @@ -0,0 +1,35 @@ +/* + * 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 STORAGE_SRC_STORAGE_CWRAPPER_ORC_FORMAT_C_H_ +#define STORAGE_SRC_STORAGE_CWRAPPER_ORC_FORMAT_C_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ERROR_MESSAGE_BUFFER_SIZE +#define ERROR_MESSAGE_BUFFER_SIZE 4096 +#endif + void wrap_func_test(); +#ifdef __cplusplus +} +#endif + +#endif // STORAGE_SRC_STORAGE_CWRAPPER_ORC_FORMAT_C_H_ \ No newline at end of file diff --git a/contrib/orc/cwrapper/format/Makefile b/contrib/orc/cwrapper/format/Makefile new file mode 100644 index 0000000000..cc896f8910 --- /dev/null +++ b/contrib/orc/cwrapper/format/Makefile @@ -0,0 +1,6 @@ +All: orc_format.so +liborc_format.so: orc_format.cpp + g++ --shared -o liborc_format.so orc_format.cpp + +clean: + rm -f ./liborc_format.so \ No newline at end of file diff --git a/contrib/orc/format/orc_format.c b/contrib/orc/cwrapper/format/orc_format.cpp similarity index 94% rename from contrib/orc/format/orc_format.c rename to contrib/orc/cwrapper/format/orc_format.cpp index 7220975503..d1bdbb8f37 100644 --- a/contrib/orc/format/orc_format.c +++ b/contrib/orc/cwrapper/format/orc_format.cpp @@ -15,4 +15,8 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - */ \ No newline at end of file + */ +#include "../cwrapper.h" +void func_test(){ + +} diff --git a/contrib/orc/cwrapper/cwrapper.c b/contrib/orc/cwrapper/format/orc_format.h similarity index 97% rename from contrib/orc/cwrapper/cwrapper.c rename to contrib/orc/cwrapper/format/orc_format.h index 7220975503..c05746d548 100644 --- a/contrib/orc/cwrapper/cwrapper.c +++ b/contrib/orc/cwrapper/format/orc_format.h @@ -15,4 +15,5 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - */ \ No newline at end of file + */ +void func_test(); \ No newline at end of file