Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.


cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.8)

# generate CTest input files
enable_testing()

# where to find cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")

set(THIRDPARTY_PREFIX ${CMAKE_SOURCE_DIR}/thirdparty/installed)
set(CMAKE_PREFIX_PATH ${THIRDPARTY_PREFIX})
set(CMAKE_PREFIX_PATH ${_PREFIX})

# find boost headers and libs
set(Boost_DEBUG TRUE)
Expand All @@ -49,16 +47,22 @@ set_target_properties(thriftstatic PROPERTIES IMPORTED_LOCATION ${THRIFT_STATIC_
## Snappy
find_package(Snappy REQUIRED)
include_directories(SYSTEM ${SNAPPY_INCLUDE_DIR})
add_library(snappystatic STATIC IMPORTED)
set_target_properties(snappystatic PROPERTIES IMPORTED_LOCATION ${SNAPPY_STATIC_LIB})

## LZ4
find_package(Lz4 REQUIRED)
include_directories(SYSTEM ${LZ4_INCLUDE_DIR})
add_library(lz4static STATIC IMPORTED)
set_target_properties(lz4static PROPERTIES IMPORTED_LOCATION ${LZ4_STATIC_LIB})

SET(CMAKE_CXX_FLAGS "-msse4.2 -Wall -Wno-unused-value -Wno-unused-variable -Wno-sign-compare -Wno-unknown-pragmas")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 -Wall -Wno-unused-value -Wno-unused-variable -Wno-sign-compare -Wno-unknown-pragmas")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb")

# Thrift requires these definitions for some types that we use
Expand Down
74 changes: 16 additions & 58 deletions cmake_modules/FindLz4.cmake
Original file line number Diff line number Diff line change
@@ -1,67 +1,25 @@
# Copyright 2012 Cloudera Inc.
# Find the Lz4 libraries
#
# Licensed 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.

# - Find LZ4 (lz4.h, liblz4.a, liblz4.so, and liblz4.so.1)
# This module defines
# LZ4_INCLUDE_DIR, directory containing headers
# LZ4_LIBS, directory containing lz4 libraries
# LZ4_STATIC_LIB, path to liblz4.a
# LZ4_FOUND, whether lz4 has been found
# The following are set after configuration is done:
# LZ4_FOUND
# LZ4_INCLUDE_DIR
# LZ4_LIBRARIES

set(LZ4_SEARCH_HEADER_PATHS
${THIRDPARTY_PREFIX}/include
)

set(LZ4_SEARCH_LIB_PATH
${THIRDPARTY_PREFIX}/lib
find_path(LZ4_INCLUDE_DIR NAMES lz4.h PATHS
/usr/local/include
/usr/include
)

find_path(LZ4_INCLUDE_DIR lz4.h PATHS
${LZ4_SEARCH_HEADER_PATHS}
# make sure we don't accidentally pick up a different version
NO_DEFAULT_PATH
find_library(LZ4_LIBRARIES NAMES lz4 PATHS
/usr/local/lib
/usr/lib
)

find_library(LZ4_LIB_PATH NAMES liblz4.a PATHS ${LZ4_SEARCH_LIB_PATH} NO_DEFAULT_PATH)

if (LZ4_INCLUDE_DIR AND LZ4_LIB_PATH)
set(LZ4_FOUND TRUE)
set(LZ4_LIBS ${LZ4_SEARCH_LIB_PATH})
set(LZ4_STATIC_LIB ${LZ4_SEARCH_LIB_PATH}/liblz4.a)
else ()
set(LZ4_FOUND FALSE)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZ4 DEFAULT_MSG LZ4_INCLUDE_DIR LZ4_LIBRARIES)

if (LZ4_FOUND)
if (NOT Lz4_FIND_QUIETLY)
message(STATUS "Found the Lz4 library: ${LZ4_LIB_PATH}")
endif ()
else ()
if (NOT Lz4_FIND_QUIETLY)
set(LZ4_ERR_MSG "Could not find the Lz4 library. Looked for headers")
set(LZ4_ERR_MSG "${LZ4_ERR_MSG} in ${LZ4_SEARCH_HEADER_PATHS}, and for libs")
set(LZ4_ERR_MSG "${LZ4_ERR_MSG} in ${LZ4_SEARCH_LIB_PATH}")
if (Lz4_FIND_REQUIRED)
message(FATAL_ERROR "${LZ4_ERR_MSG}")
else (Lz4_FIND_REQUIRED)
message(STATUS "${LZ4_ERR_MSG}")
endif (Lz4_FIND_REQUIRED)
endif ()
endif ()

mark_as_advanced(
LZ4_INCLUDE_DIR
LZ4_LIBS
LZ4_STATIC_LIB
)
message(STATUS "Found Lz4 (include: ${LZ4_INCLUDE_DIR}, library: ${LZ4_LIBRARIES})")
mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARIES)
endif()
76 changes: 15 additions & 61 deletions cmake_modules/FindSnappy.cmake
Original file line number Diff line number Diff line change
@@ -1,67 +1,21 @@
# Copyright 2012 Cloudera Inc.
# Find the Snappy libraries
#
# Licensed 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.

# - Find SNAPPY (snappy.h, libsnappy.a, libsnappy.so, and libsnappy.so.1)
# This module defines
# SNAPPY_INCLUDE_DIR, directory containing headers
# SNAPPY_LIBS, directory containing snappy libraries
# SNAPPY_STATIC_LIB, path to libsnappy.a
# SNAPPY_FOUND, whether snappy has been found

set(SNAPPY_SEARCH_HEADER_PATHS
${THIRDPARTY_PREFIX}/include
)

set(SNAPPY_SEARCH_LIB_PATH
${THIRDPARTY_PREFIX}/lib
)

find_path(SNAPPY_INCLUDE_DIR snappy.h PATHS
${SNAPPY_SEARCH_HEADER_PATHS}
# make sure we don't accidentally pick up a different version
NO_DEFAULT_PATH
)
# The following are set after configuration is done:
# SNAPPY_FOUND
# Snappy_INCLUDE_DIR
# Snappy_LIBRARIES

find_library(SNAPPY_LIB_PATH NAMES snappy PATHS ${SNAPPY_SEARCH_LIB_PATH} NO_DEFAULT_PATH)
find_path(Snappy_INCLUDE_DIR NAMES snappy.h
PATHS /usr/local/include /usr/include)

if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIB_PATH)
set(SNAPPY_FOUND TRUE)
set(SNAPPY_LIBS ${SNAPPY_SEARCH_LIB_PATH})
set(SNAPPY_STATIC_LIB ${SNAPPY_SEARCH_LIB_PATH}/libsnappy.a)
else ()
set(SNAPPY_FOUND FALSE)
endif ()
find_library(Snappy_LIBRARIES NAMES snappy
PATHS /usr/local/lib /usr/lib)

if (SNAPPY_FOUND)
if (NOT Snappy_FIND_QUIETLY)
message(STATUS "Found the Snappy library: ${SNAPPY_LIB_PATH}")
endif ()
else ()
if (NOT Snappy_FIND_QUIETLY)
set(SNAPPY_ERR_MSG "Could not find the Snappy library. Looked for headers")
set(SNAPPY_ERR_MSG "${SNAPPY_ERR_MSG} in ${SNAPPY_SEARCH_HEADER_PATHS}, and for libs")
set(SNAPPY_ERR_MSG "${SNAPPY_ERR_MSG} in ${SNAPPY_SEARCH_LIB_PATH}")
if (Snappy_FIND_REQUIRED)
message(FATAL_ERROR "${SNAPPY_ERR_MSG}")
else (Snappy_FIND_REQUIRED)
message(STATUS "${SNAPPY_ERR_MSG}")
endif (Snappy_FIND_REQUIRED)
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Snappy DEFAULT_MSG Snappy_INCLUDE_DIR Snappy_LIBRARIES)

mark_as_advanced(
SNAPPY_INCLUDE_DIR
SNAPPY_LIBS
SNAPPY_STATIC_LIB
)
if(SNAPPY_FOUND)
message(STATUS "Found Snappy (include: ${Snappy_INCLUDE_DIR}, library: ${Snappy_LIBRARIES})")
mark_as_advanced(Snappy_INCLUDE_DIR Snappy_LIBRARIES)
endif()
5 changes: 2 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ SET(LINK_LIBS
Parquet
ParquetCompression
Example
rt
ThriftParquet
thriftstatic
lz4static
snappystatic)
${LZ4_LIBRARIES}
${Snappy_LIBRARIES})

add_executable(compute_stats compute_stats.cc)
target_link_libraries(compute_stats ${LINK_LIBS})
Expand Down
28 changes: 14 additions & 14 deletions example/parquet_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char** argv) {
void *column_ptr = read_parquet(argv[1]);

// an example to use the returned column_ptr
// printf("%-"COL_WIDTH"d\n",((int32_t *)(((int32_t **)column_ptr)[0]))[0]);
// printf("%-" COL_WIDTH "d\n",((int32_t *)(((int32_t **)column_ptr)[0]))[0]);

return 0;
}
Expand Down Expand Up @@ -215,7 +215,7 @@ void* read_parquet(char* filename) {
char *str = (char*)malloc(50);
assert(str);
strcpy(str, metadata.schema[j+1].name.c_str());
printf("%-"COL_WIDTH"s", str);
printf("%-" COL_WIDTH "s", str);
free(str);
}

Expand All @@ -225,22 +225,22 @@ void* read_parquet(char* filename) {
for (j = 0;j < row_group.columns.size(); ++j)
switch(type_array[j]) {
case Type::BOOLEAN:
printf("%-"COL_WIDTH"s","BOOLEAN");
printf("%-" COL_WIDTH "s","BOOLEAN");
break;
case Type::INT32:
printf("%-"COL_WIDTH"s","INT32");
printf("%-" COL_WIDTH "s","INT32");
break;
case Type::INT64:
printf("%-"COL_WIDTH"s","INT64");
printf("%-" COL_WIDTH "s","INT64");
break;
case Type::FLOAT:
printf("%-"COL_WIDTH"s","FLOAT");
printf("%-" COL_WIDTH "s","FLOAT");
break;
case Type::DOUBLE:
printf("%-"COL_WIDTH"s","DOUBLE");
printf("%-" COL_WIDTH "s","DOUBLE");
break;
case Type::BYTE_ARRAY:
printf("%-"COL_WIDTH"s","BYTE_ARRAY");
printf("%-" COL_WIDTH "s","BYTE_ARRAY");
break;
default:
continue;
Expand All @@ -255,26 +255,26 @@ void* read_parquet(char* filename) {
for (j = 0; j < row_group.columns.size(); ++j) {
switch(type_array[j]) {
case Type::BOOLEAN:
printf("%-"COL_WIDTH"d",((bool*)(((bool**)column_ptr)[j]))[k]);
printf("%-" COL_WIDTH "d",((bool*)(((bool**)column_ptr)[j]))[k]);
break;
case Type::INT32:
printf("%-"COL_WIDTH"d",((int32_t *)(((int32_t **)column_ptr)[j]))[k]);
printf("%-" COL_WIDTH "d",((int32_t *)(((int32_t **)column_ptr)[j]))[k]);
break;
case Type::INT64:
printf("%-"COL_WIDTH"ld",((int64_t *)(((int64_t **)column_ptr)[j]))[k]);
printf("%-" COL_WIDTH "ld",((int64_t *)(((int64_t **)column_ptr)[j]))[k]);
break;
case Type::FLOAT:
printf("%-"COL_WIDTH"f",((float*)(((float**)column_ptr)[j]))[k]);
printf("%-" COL_WIDTH "f",((float*)(((float**)column_ptr)[j]))[k]);
break;
case Type::DOUBLE:
printf("%-"COL_WIDTH"lf",((double*)(((double**)column_ptr)[j]))[k]);
printf("%-" COL_WIDTH "lf",((double*)(((double**)column_ptr)[j]))[k]);
break;
case Type::BYTE_ARRAY:
result = ByteArrayToString( ((ByteArray*)(((ByteArray**)column_ptr)[j]))[k] );
str1 = (char*)malloc(result.size());
assert(str1);
strcpy(str1, result.c_str());
printf("%-"COL_WIDTH"s", str1);
printf("%-" COL_WIDTH "s", str1);
free(str1);
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion generated/gen-cpp/parquet_constants.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/gen-cpp/parquet_constants.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading