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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ CTestTestfile.cmake
cmake_install.cmake
Makefile

thirdparty
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ addons:
apt:
packages:
- libboost-dev
#- libsnappy-dev currently handled by thirdparty scipts.
- libsnappy-dev
- libboost-program-options-dev #needed for thrift cpp compilation
- libboost-test-dev #needed for thrift cpp compilation
- libssl-dev #needed for thrift cpp compilation
Expand All @@ -22,8 +22,8 @@ addons:
- pkg-config #needed for thrift cpp compilation

before_install:
- pushd thirdparty
# thrift cpp
- mkdir $HOME/thirdparty && pushd $HOME/thirdparty
# linux: thrift cpp
- >
if [ $TRAVIS_OS_NAME == linux ]; then
wget http://www.us.apache.org/dist/thrift/0.9.1/thrift-0.9.1.tar.gz &&
Expand All @@ -34,15 +34,22 @@ before_install:
make install &&
popd;
fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew install thrift; fi
# snappy and lz4
- ./download_thirdparty.sh
- ./build_thirdparty.sh
# linux: lz4
- >
if [ $TRAVIS_OS_NAME == linux ]; then
wget https://github.com/Cyan4973/lz4/archive/r128.tar.gz &&
tar xfz r128.tar.gz &&
pushd lz4-r128 &&
PREFIX=$HOME/local make install &&
popd;
fi
- popd
# mac dependencies
- if [ $TRAVIS_OS_NAME == osx ]; then brew install thrift snappy lz4; fi

before_script:
- mkdir build
- cd build
- THRIFT_HOME=$HOME/local cmake ..
- THRIFT_HOME=$HOME/local LZ4_HOME=$HOME/local cmake ..

script: make
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ 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})

# find boost headers and libs
set(Boost_DEBUG TRUE)
set(Boost_USE_MULTITHREADED ON)
Expand All @@ -47,16 +44,18 @@ add_library(thriftstatic STATIC IMPORTED)
set_target_properties(thriftstatic PROPERTIES IMPORTED_LOCATION ${THRIFT_STATIC_LIB})

## Snappy
set( Snappy_USE_STATIC_LIBS ON )
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})
set_target_properties(snappystatic PROPERTIES IMPORTED_LOCATION ${SNAPPY_LIBRARIES})

## LZ4
set( Lz4_USE_STATIC_LIBS ON )
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_target_properties(lz4static PROPERTIES IMPORTED_LOCATION ${LZ4_LIBRARIES})

SET(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")
Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ Parquet-cpp [![Build Status](https://travis-ci.org/apache/parquet-cpp.svg)](http
===========
A C++ library to read parquet files.

To build you will need some version of boost installed and thrift 0.7+ installed.
(If you are building thrift from source, you will need to set the THRIFT_HOME env
variable to the directory containing include/ and lib/.)

Then run:
<br>
<code>
thirdparty/download_thirdparty.sh
</code>
<br>
<code>
thirdparty/build_thirdparty.sh
</code>
<br>
<code>
cmake .
</code>
<br>
<code>
make
</code>
## Third Party Dependencies
- boost
- snappy
- lz4
- thrift 0.7+ [install instructions](https://thrift.apache.org/docs/install/)

Many package managers support some or all of these dependencies. E.g.:
```shell
ubuntu$ sudo apt-get install libboost-dev libsnappy-dev liblz4-dev
```
```shell
mac$ brew install boost snappy lz4 thrift
```
You can also take a look at our [.travis.yml](.travis.yml) to see how that build env is set up.

## Build
- `cmake .`
- You can customize dependent library locations through various environment variables:
- THRIFT_HOME customizes the thrift installed location.
- SNAPPY_HOME customizes the snappy installed location.
- LZ4_HOME customizes the lz4 installed location.
- `make`

The binaries will be built to ./bin which contains the libraries to link against as
well as a few example executables.
Expand Down
113 changes: 67 additions & 46 deletions cmake_modules/FindLz4.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright 2012 Cloudera Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,57 +10,79 @@
# 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.
#
# Tries to find LZ4 headers and libraries.
#
# Usage of this module as follows:
#
# find_package(Lz4)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Lz4_HOME - The root of the Lz4 installation. This is considered before
# standard locations. The environment variable LZ4_HOME is also
# considered if this variable is not set.
# Lz4_USE_STATIC_LIBS - Set to ON to force the use of the static
# libraries. Default is OFF
#
# Variables defined by this module:
#
# LZ4_FOUND System has Lz4 libs/headers
# LZ4_LIBRARIES The Lz4 libraries
# LZ4_INCLUDE_DIR The location of Lz4 headers

# - 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
# Determine parameterized roots
if( Lz4_HOME )
list( APPEND _lz4_roots ${Lz4_HOME} )
endif()
if( NOT "$ENV{LZ4_HOME}" STREQUAL "")
file( TO_CMAKE_PATH "$ENV{LZ4_HOME}" _native_path )
list( APPEND _lz4_roots ${_native_path} )
endif()

set(LZ4_SEARCH_HEADER_PATHS
${THIRDPARTY_PREFIX}/include
)
# Try the parameterized roots first
find_path( LZ4_INCLUDE_DIR NAMES lz4.h
PATHS ${_lz4_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "include" )
find_path( LZ4_INCLUDE_DIR NAMES lz4.h )

set(LZ4_SEARCH_LIB_PATH
${THIRDPARTY_PREFIX}/lib
)
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES.
# Patterned after FindBoost.cmake
if( Lz4_USE_STATIC_LIBS )
set( _lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} )
if(WIN32)
set( CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES} )
else()
set( CMAKE_FIND_LIBRARY_SUFFIXES .a )
endif()

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
)
# customize the cached variable depending on the search
set( _lz4_LIBRARIES LZ4_LIBRARIES_STATIC )
else()
set( _lz4_LIBRARIES LZ4_LIBRARIES_DEFAULT )
endif()

find_library(LZ4_LIB_PATH NAMES liblz4.a PATHS ${LZ4_SEARCH_LIB_PATH} NO_DEFAULT_PATH)
# Try the parameterized roots first
find_library( ${_lz4_LIBRARIES} NAMES lz4
PATHS ${_lz4_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "lib" )
find_library( ${_lz4_LIBRARIES} NAMES lz4 )

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 ()
set( LZ4_LIBRARIES ${${_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 ()
# Restore the original find library ordering
if( Lz4_USE_STATIC_LIBS )
set( CMAKE_FIND_LIBRARY_SUFFIXES ${_lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES} )
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( Lz4 DEFAULT_MSG
${_lz4_LIBRARIES}
LZ4_INCLUDE_DIR )

mark_as_advanced(
LZ4_INCLUDE_DIR
LZ4_LIBS
LZ4_STATIC_LIB
)
LZ4_LIBRARIES_STATIC
LZ4_LIBRARIES_DEFAULT
LZ4_INCLUDE_DIR )

112 changes: 66 additions & 46 deletions cmake_modules/FindSnappy.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright 2012 Cloudera Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,57 +10,78 @@
# 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.
#
# Tries to find Snappy headers and libraries.
#
# Usage of this module as follows:
#
# find_package(Snappy)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Snappy_HOME - The root of the Snappy installation. This is considered before
# standard locations. The environment variable SNAPPY_HOME is also
# considered if this variable is not set.
# Snappy_USE_STATIC_LIBS - Set to ON to force the use of the static
# libraries. Default is OFF
#
# Variables defined by this module:
#
# SNAPPY_FOUND System has Snappy libs/headers
# SNAPPY_LIBRARIES The Snappy libraries
# SNAPPY_INCLUDE_DIR The location of Snappy headers

# Determine parameterized roots
if( Snappy_HOME )
list( APPEND _snappy_roots ${Snappy_HOME} )
endif()
if( NOT "$ENV{SNAPPY_HOME}" STREQUAL "")
file( TO_CMAKE_PATH "$ENV{SNAPPY_HOME}" _native_path )
list( APPEND _snappy_roots ${_native_path} )
endif()

# - 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
# Try the parameterized roots first
find_path( SNAPPY_INCLUDE_DIR NAMES snappy.h
PATHS ${_snappy_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "include" )
find_path( SNAPPY_INCLUDE_DIR NAMES snappy.h )

set(SNAPPY_SEARCH_HEADER_PATHS
${THIRDPARTY_PREFIX}/include
)
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES.
# Patterned after FindBoost.cmake
if( Snappy_USE_STATIC_LIBS )
set( _snappy_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} )
if(WIN32)
set( CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES} )
else()
set( CMAKE_FIND_LIBRARY_SUFFIXES .a )
endif()

set(SNAPPY_SEARCH_LIB_PATH
${THIRDPARTY_PREFIX}/lib
)
# customize the cached variable depending on the search
set( _snappy_LIBRARIES SNAPPY_LIBRARIES_STATIC )
else()
set( _snappy_LIBRARIES SNAPPY_LIBRARIES_DEFAULT )
endif()

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
)
# Try the parameterized roots first
find_library( ${_snappy_LIBRARIES} NAMES snappy
PATHS ${_snappy_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "lib" )
find_library( ${_snappy_LIBRARIES} NAMES snappy )

find_library(SNAPPY_LIB_PATH NAMES snappy PATHS ${SNAPPY_SEARCH_LIB_PATH} NO_DEFAULT_PATH)
set( SNAPPY_LIBRARIES ${${_snappy_LIBRARIES}} )

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 ()
# Restore the original find library ordering
if( Snappy_USE_STATIC_LIBS )
set( CMAKE_FIND_LIBRARY_SUFFIXES ${_snappy_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES} )
endif()

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_LIBRARIES}
SNAPPY_INCLUDE_DIR )

mark_as_advanced(
SNAPPY_INCLUDE_DIR
SNAPPY_LIBS
SNAPPY_STATIC_LIB
)
SNAPPY_LIBRARIES_STATIC
SNAPPY_LIBRARIES_DEFAULT
SNAPPY_INCLUDE_DIR )
Loading