feather-format-0.3.1/0000775000175100017510000000000013005023556014372 5ustar wesmwesm00000000000000feather-format-0.3.1/requirements.txt0000664000175100017510000000001712676603306017666 0ustar wesmwesm00000000000000pandas>=0.17.0 feather-format-0.3.1/PKG-INFO0000664000175100017510000000625013005023556015472 0ustar wesmwesm00000000000000Metadata-Version: 1.1 Name: feather-format Version: 0.3.1 Summary: Python interface to the Apache Arrow-based Feather File Format Home-page: http://github.com/wesm/feather Author: Wes McKinney Author-email: wesm@apache.org License: Apache License, Version 2.0 Description: ## Python interface to the Apache Arrow-based Feather File Format Feather efficiently stores pandas DataFrame objects on disk. ## Installing ```shell pip install feather-format ``` From [conda-forge][1]: ```shell conda install feather-format -c conda-forge ``` #### Mac notes Anaconda uses a default 10.5 deployment target which does not have C++11 properly available. This can be fixed by setting: ``` export MACOSX_DEPLOYMENT_TARGET=10.9 ``` Deployments targets as early as 10.7 can be used if the compiler supports C++11 and the correct mode is selected. For example using the following: ``` export MACOSX_DEPLOYMENT_TARGET=10.7 export CFLAGS="${CXXFLAGS} -stdlib=libc++ -std=c++11" export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -std=c++11" ``` This may be necessary in some other OS X environments. ## Build Building Feather requires a C++11 compiler. We've simplified the PyPI packaging to include libfeather (the C++ core library) to be built statically as part of the Python extension build, but this may change in the future. ### Static builds for easier packaging At the moment, the libfeather sources are being built and linked with the Cython extension, rather than building the `libfeather` shared library and linking to that. While we continue to do this, building from source requires you to symlink (or copy) the C++ sources. See: ```shell # Symlink the C++ library for the static build ln -s ../cpp/src src python setup.py build # To install it locally python setup.py install # Source distribution python setup.py sdist ``` To change this and instead link to an installed `libfeather.so`, look in `setup.py` and make the following change: ```python FEATHER_STATIC_BUILD = False ``` ## Limitations Some features of pandas are not supported in Feather: * Non-string column names * Row indexes * Object-type columns with non-homogeneous data [1]: https://conda-forge.github.io Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Cython feather-format-0.3.1/setup.py0000664000175100017510000001174613005023215016105 0ustar wesmwesm00000000000000#!/usr/bin/env python # # Copyright 2016 Feather Developers # # 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. # Bits here from Apache Kudu (incubating), ASL 2.0 from Cython.Distutils import build_ext from Cython.Build import cythonize import Cython import numpy as np import sys from setuptools import setup from distutils.command.clean import clean as _clean from distutils.extension import Extension import os import platform if Cython.__version__ < '0.19.1': raise Exception('Please upgrade to Cython 0.19.1 or newer') MAJOR = 0 MINOR = 3 MICRO = 1 VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) ISRELEASED = True setup_dir = os.path.abspath(os.path.dirname(__file__)) def write_version_py(filename=os.path.join(setup_dir, 'feather/version.py')): version = VERSION if not ISRELEASED: version += '.dev' a = open(filename, 'w') file_content = "\n".join(["", "# THIS FILE IS GENERATED FROM SETUP.PY", "version = '%(version)s'", "isrelease = '%(isrelease)s'"]) a.write(file_content % {'version': VERSION, 'isrelease': str(ISRELEASED)}) a.close() class clean(_clean): def run(self): _clean.run(self) for x in ['feather/ext.cpp']: try: os.remove(x) except OSError: pass FEATHER_SOURCES = ['feather/ext.pyx'] INCLUDE_PATHS = ['feather', np.get_include()] LIBRARIES = [] EXTRA_LINK_ARGS = [] FEATHER_STATIC_BUILD = True if FEATHER_STATIC_BUILD: INCLUDE_PATHS.append(os.path.join(setup_dir, 'src')) FEATHER_SOURCES.extend([ 'src/feather/buffer.cc', 'src/feather/io.cc', 'src/feather/metadata.cc', 'src/feather/reader.cc', 'src/feather/status.cc', 'src/feather/types.cc', 'src/feather/writer.cc' ]) LIBRARY_DIRS = [] else: # Library build if 'FEATHER_HOME' in os.environ: prefix = os.environ['FEATHER_HOME'] sys.stderr.write("Building from configured libfeather prefix {0}\n" .format(prefix)) else: if os.path.exists("/usr/local/include/feather"): prefix = "/usr/local" elif os.path.exists("/usr/include/feather"): prefix = "/usr" else: sys.stderr.write("Cannot find installed libfeather " "core library.\n") sys.exit(1) sys.stderr.write("Building from system prefix {0}\n".format(prefix)) feather_include_dir = os.path.join(prefix, 'include') feather_lib_dir = os.path.join(prefix, 'lib') INCLUDE_PATHS.append(feather_include_dir) LIBRARIES.append('feather') LIBRARY_DIRS = [feather_lib_dir] if platform.system() == 'Darwin': EXTRA_LINK_ARGS.append('-Wl,-rpath,' + feather_lib_dir) EXTRA_COMPILE_ARGS = [] if platform.system() != 'Windows': EXTRA_COMPILE_ARGS = ['-std=c++11', '-O3'] RT_LIBRARY_DIRS = LIBRARY_DIRS ext = Extension('feather.ext', FEATHER_SOURCES, language='c++', libraries=LIBRARIES, include_dirs=INCLUDE_PATHS, library_dirs=LIBRARY_DIRS, runtime_library_dirs=RT_LIBRARY_DIRS, extra_compile_args=EXTRA_COMPILE_ARGS, extra_link_args=EXTRA_LINK_ARGS) extensions = [ext] extensions = cythonize(extensions) write_version_py() LONG_DESCRIPTION = open(os.path.join(setup_dir, "README.md")).read() DESCRIPTION = "Python interface to the Apache Arrow-based Feather File Format" CLASSIFIERS = [ 'Development Status :: 3 - Alpha', 'Environment :: Console', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Cython' ] URL = 'http://github.com/wesm/feather' setup( name="feather-format", packages=['feather', 'feather.tests'], version=VERSION, package_data={'feather': ['*.pxd', '*.pyx']}, ext_modules=extensions, cmdclass={ 'clean': clean, 'build_ext': build_ext }, install_requires=['cython >= 0.21'], description=DESCRIPTION, long_description=LONG_DESCRIPTION, license='Apache License, Version 2.0', classifiers=CLASSIFIERS, author="Wes McKinney", author_email="wesm@apache.org", url=URL, test_suite="feather.tests" ) feather-format-0.3.1/feather_format.egg-info/0000775000175100017510000000000013005023556021052 5ustar wesmwesm00000000000000feather-format-0.3.1/feather_format.egg-info/SOURCES.txt0000664000175100017510000000247513005023556022746 0ustar wesmwesm00000000000000MANIFEST.in README.md requirements.txt setup.py feather/__init__.py feather/api.py feather/compat.py feather/ext.cpp feather/ext.pyx feather/interop.h feather/libfeather.pxd feather/version.py feather/tests/__init__.py feather/tests/test_reader.py feather_format.egg-info/PKG-INFO feather_format.egg-info/SOURCES.txt feather_format.egg-info/dependency_links.txt feather_format.egg-info/requires.txt feather_format.egg-info/top_level.txt src/feather/CMakeLists.txt src/feather/api.h src/feather/buffer.cc src/feather/buffer.h src/feather/buffer.o src/feather/common.h src/feather/compatibility.h src/feather/feather-c.cc src/feather/feather-c.h src/feather/feather-c.o src/feather/io.cc src/feather/io.h src/feather/io.o src/feather/metadata.cc src/feather/metadata.fbs src/feather/metadata.h src/feather/metadata.o src/feather/metadata_generated.h src/feather/mman.h src/feather/reader.cc src/feather/reader.h src/feather/reader.o src/feather/status.cc src/feather/status.h src/feather/status.o src/feather/types.cc src/feather/types.h src/feather/types.o src/feather/writer.cc src/feather/writer.h src/feather/writer.o src/feather/tests/c-api-test.cc src/feather/tests/io-test.cc src/feather/tests/metadata-test.cc src/feather/tests/test-common.h src/feather/tests/test_main.cc src/feather/tests/writer-test.cc src/flatbuffers/flatbuffers.hfeather-format-0.3.1/feather_format.egg-info/PKG-INFO0000664000175100017510000000625013005023556022152 0ustar wesmwesm00000000000000Metadata-Version: 1.1 Name: feather-format Version: 0.3.1 Summary: Python interface to the Apache Arrow-based Feather File Format Home-page: http://github.com/wesm/feather Author: Wes McKinney Author-email: wesm@apache.org License: Apache License, Version 2.0 Description: ## Python interface to the Apache Arrow-based Feather File Format Feather efficiently stores pandas DataFrame objects on disk. ## Installing ```shell pip install feather-format ``` From [conda-forge][1]: ```shell conda install feather-format -c conda-forge ``` #### Mac notes Anaconda uses a default 10.5 deployment target which does not have C++11 properly available. This can be fixed by setting: ``` export MACOSX_DEPLOYMENT_TARGET=10.9 ``` Deployments targets as early as 10.7 can be used if the compiler supports C++11 and the correct mode is selected. For example using the following: ``` export MACOSX_DEPLOYMENT_TARGET=10.7 export CFLAGS="${CXXFLAGS} -stdlib=libc++ -std=c++11" export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -std=c++11" ``` This may be necessary in some other OS X environments. ## Build Building Feather requires a C++11 compiler. We've simplified the PyPI packaging to include libfeather (the C++ core library) to be built statically as part of the Python extension build, but this may change in the future. ### Static builds for easier packaging At the moment, the libfeather sources are being built and linked with the Cython extension, rather than building the `libfeather` shared library and linking to that. While we continue to do this, building from source requires you to symlink (or copy) the C++ sources. See: ```shell # Symlink the C++ library for the static build ln -s ../cpp/src src python setup.py build # To install it locally python setup.py install # Source distribution python setup.py sdist ``` To change this and instead link to an installed `libfeather.so`, look in `setup.py` and make the following change: ```python FEATHER_STATIC_BUILD = False ``` ## Limitations Some features of pandas are not supported in Feather: * Non-string column names * Row indexes * Object-type columns with non-homogeneous data [1]: https://conda-forge.github.io Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Cython feather-format-0.3.1/feather_format.egg-info/top_level.txt0000664000175100017510000000001013005023556023573 0ustar wesmwesm00000000000000feather feather-format-0.3.1/feather_format.egg-info/requires.txt0000664000175100017510000000001713005023556023450 0ustar wesmwesm00000000000000cython >= 0.21 feather-format-0.3.1/feather_format.egg-info/dependency_links.txt0000664000175100017510000000000113005023556025120 0ustar wesmwesm00000000000000 feather-format-0.3.1/setup.cfg0000664000175100017510000000007313005023556016213 0ustar wesmwesm00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 feather-format-0.3.1/feather/0000775000175100017510000000000013005023556016010 5ustar wesmwesm00000000000000feather-format-0.3.1/feather/ext.pyx0000664000175100017510000001773013004772715017371 0ustar wesmwesm00000000000000# Copyright 2016 Feather Developers # # 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. # distutils: language = c++ # cython: embedsignature = True from libcpp.string cimport string from libcpp cimport bool as c_bool cimport cpython from cython.operator cimport dereference as deref from libfeather cimport * import pandas as pd from feather.compat import pdapi from numpy cimport ndarray cimport numpy as cnp import numpy as np from feather.compat import frombytes, tobytes, encode_file_path import six cnp.import_array() class FeatherError(Exception): pass cdef extern from "interop.h" namespace "feather::py": Status pandas_to_primitive(object ao, PrimitiveArray* out) Status pandas_masked_to_primitive(object ao, object mask, PrimitiveArray* out) object get_null_mask(const PrimitiveArray& arr) object raw_primitive_to_pandas(const PrimitiveArray& arr) object primitive_to_pandas(const PrimitiveArray& arr) void set_numpy_nan(object nan) cdef check_status(const Status& status): if status.ok(): return cdef string c_message = status.ToString() raise FeatherError(frombytes(c_message)) cdef update_mask_with_datatype_nulls(mask, values): datatype_nulls = pd.isnull(values) if datatype_nulls.any(): if mask is None: return datatype_nulls else: return mask | datatype_nulls set_numpy_nan(np.nan) cdef class FeatherWriter: cdef: unique_ptr[TableWriter] writer int64_t num_rows def __cinit__(self, object name): cdef: string c_name = encode_file_path(name) check_status(TableWriter.OpenFile(c_name, &self.writer)) self.num_rows = -1 def close(self): if self.num_rows < 0: self.num_rows = 0 self.writer.get().SetNumRows(self.num_rows) check_status(self.writer.get().Finalize()) def write_array(self, object name, object col, object mask=None): if self.num_rows >= 0: if len(col) != self.num_rows: raise ValueError('prior column had a different number of rows') else: self.num_rows = len(col) if pdapi.is_categorical_dtype(col.dtype): self.write_category(name, col, mask) elif pdapi.is_datetime64_any_dtype(col.dtype): self.write_timestamp(name, col, mask) else: self.write_primitive(name, col, mask) cdef write_category(self, name, col, mask): cdef: string c_name = tobytes(name) PrimitiveArray values PrimitiveArray levels col_values = _unbox_series(col) mask_to_file = update_mask_with_datatype_nulls(mask, col_values) self.write_ndarray(col_values.codes, mask_to_file, &values) check_status(pandas_to_primitive(np.asarray(col_values.categories), &levels)) check_status(self.writer.get().AppendCategory(c_name, values, levels, col_values.ordered)) cdef write_primitive(self, name, col, mask): cdef: string c_name = tobytes(name) PrimitiveArray values col_values = _unbox_series(col) self.write_ndarray(col_values, mask, &values) check_status(self.writer.get().AppendPlain(c_name, values)) cdef write_timestamp(self, name, col, mask): cdef: string c_name = tobytes(name) PrimitiveArray values TimestampMetadata metadata col_values = _unbox_series(col) mask_to_file = update_mask_with_datatype_nulls(mask, col_values) self.write_ndarray(col_values.view('i8'), mask_to_file, &values) metadata.unit = TimeUnit_NANOSECOND tz = getattr(col.dtype, 'tz', None) if tz is None: metadata.timezone = b'' else: metadata.timezone = tobytes(tz.zone) check_status(self.writer.get().AppendTimestamp(c_name, values, metadata)) cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1: if mask is None: check_status(pandas_to_primitive(values, out)) else: check_status(pandas_masked_to_primitive(values, mask, out)) return 0 cdef _unbox_series(col): if isinstance(col, pd.Series): col_values = col.values else: col_values = col return col_values cdef class Column: cdef: shared_ptr[CColumnMetadata] metadata CColumnMetadata* mp FeatherReader parent int column_index def __cinit__(self): self.mp = NULL cdef init(self, FeatherReader parent, int i): cdef TableReader* tbl = parent.reader.get() self.parent = parent self.column_index = i check_status(tbl.GetColumnMetadata(i, &self.metadata)) self.mp = self.metadata.get() property name: def __get__(self): return frombytes(self.mp.name()) property type: def __get__(self): return self.mp.type() property user_metadata: def __get__(self): return frombytes(self.mp.user_metadata()) property null_count: def __get__(self): cdef: unique_ptr[CColumn] col CColumn* cp check_status(self.parent.reader.get() .GetColumn(self.column_index, &col)) return col.get().values().null_count def read(self): cdef: unique_ptr[CColumn] col CColumn* cp check_status(self.parent.reader.get() .GetColumn(self.column_index, &col)) cp = col.get() if cp.type() == ColumnType_PRIMITIVE: values = primitive_to_pandas(cp.values()) elif cp.type() == ColumnType_CATEGORY: values = category_to_pandas(cp) elif cp.type() == ColumnType_TIMESTAMP: values = timestamp_to_pandas(cp) else: raise NotImplementedError(cp.type()) return values cdef class FeatherReader: cdef: unique_ptr[TableReader] reader def __cinit__(self, object name): cdef: string c_name = encode_file_path(name) check_status(TableReader.OpenFile(c_name, &self.reader)) property num_rows: def __get__(self): return self.reader.get().num_rows() property num_columns: def __get__(self): return self.reader.get().num_columns() def get_column(self, int i): if i < 0 or i >= self.num_columns: raise IndexError(i) cdef Column col = Column() col.init(self, i) return col cdef category_to_pandas(CColumn* col): cdef CategoryColumn* cat = (col) values = raw_primitive_to_pandas(cat.values()) mask = get_null_mask(cat.values()) values[mask] = -1 levels = primitive_to_pandas(cat.levels()) return pd.Categorical(values, categories=levels, fastpath=True) cdef timestamp_to_pandas(CColumn* col): cdef TimestampColumn* ts = (col) values = raw_primitive_to_pandas(ts.values()) mask = get_null_mask(ts.values()) tz = frombytes(ts.timezone()) if tz: values = (pd.DatetimeIndex(values).tz_localize('utc') .tz_convert(tz)) result = pd.Series(values) else: result = pd.Series(values, dtype='M8[ns]') result.iloc[mask] = pd.NaT return result feather-format-0.3.1/feather/compat.py0000664000175100017510000000525513004673761017664 0ustar wesmwesm00000000000000# 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. # flake8: noqa import itertools import numpy as np import sys import six from six import BytesIO, StringIO, string_types as py_string PY26 = sys.version_info[:2] == (2, 6) PY2 = sys.version_info[0] == 2 if PY26: import unittest2 as unittest else: import unittest if PY2: import cPickle try: from cdecimal import Decimal except ImportError: from decimal import Decimal unicode_type = unicode lzip = zip zip = itertools.izip def dict_values(x): return x.values() range = xrange long = long def tobytes(o): if isinstance(o, unicode): return o.encode('utf8') else: return o def frombytes(o): return o else: unicode_type = str def lzip(*x): return list(zip(*x)) long = int zip = zip def dict_values(x): return list(x.values()) from decimal import Decimal range = range def tobytes(o): if isinstance(o, str): return o.encode('utf8') else: return o def frombytes(o): return o.decode('utf8') def encode_file_path(path): import os # Windows requires utf-16le encoding for unicode file names if isinstance(path, unicode_type): if os.name == 'nt': # try: # encoded_path = path.encode('ascii') # except: encoded_path = path.encode('utf-16le') else: # POSIX systems can handle utf-8 encoded_path = path.encode('utf-8') else: encoded_path = path return encoded_path def guid(): from uuid import uuid4 guid = uuid4() return guid.get_hex() if PY2 else guid.hex integer_types = six.integer_types + (np.integer,) from distutils.version import LooseVersion import pandas if LooseVersion(pandas.__version__) < '0.19.0': pdapi = pandas.core.common else: pdapi = pandas.api.types feather-format-0.3.1/feather/ext.cpp0000664000175100017510000141314413005023200017306 0ustar wesmwesm00000000000000/* Generated by Cython 0.24 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "/home/wesm/anaconda3/lib/python3.5/site-packages/numpy/core/include/numpy/arrayobject.h", "/home/wesm/anaconda3/lib/python3.5/site-packages/numpy/core/include/numpy/ufuncobject.h", "/home/wesm/code/feather/python/src/feather/api.h", "feather/interop.h" ], "extra_compile_args": [ "-std=c++11", "-O3" ], "include_dirs": [ "feather", "/home/wesm/anaconda3/lib/python3.5/site-packages/numpy/core/include", "/home/wesm/code/feather/python/src" ], "language": "c++" } } END: Cython Metadata */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else #define CYTHON_ABI "0_24" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #undef SHIFT #undef BASE #undef MASK #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifndef __cplusplus #error "Cython files generated with the C++ option must be compiled with a C++ compiler." #endif #ifndef CYTHON_INLINE #define CYTHON_INLINE inline #endif template void __Pyx_call_destructor(T& x) { x.~T(); } template class __Pyx_FakeReference { public: __Pyx_FakeReference() : ptr(NULL) { } __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } T *operator->() { return ptr; } operator T&() { return *ptr; } private: T *ptr; }; #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { \ __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ } #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__feather__ext #define __PYX_HAVE_API__feather__ext #include "string.h" #include #include "ios" #include "new" #include "stdexcept" #include "typeinfo" #include "stdio.h" #include "pythread.h" #include "stdint.h" #include #include #include #include "feather/api.h" #include "stdlib.h" #include "numpy/arrayobject.h" #include "numpy/ufuncobject.h" #include "interop.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) && defined (_M_X64) #define __Pyx_sst_abs(value) _abs64(value) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; /* None.proto */ #if !defined(CYTHON_CCOMPLEX) #if defined(__cplusplus) #define CYTHON_CCOMPLEX 1 #elif defined(_Complex_I) #define CYTHON_CCOMPLEX 1 #else #define CYTHON_CCOMPLEX 0 #endif #endif #if CYTHON_CCOMPLEX #ifdef __cplusplus #include #else #include #endif #endif #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) #undef _Complex_I #define _Complex_I 1.0fj #endif static const char *__pyx_f[] = { "feather/ext.pyx", "__init__.pxd", "stringsource", "type.pxd", "bool.pxd", "complex.pxd", }; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t */ typedef npy_int8 __pyx_t_5numpy_int8_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t */ typedef npy_int16 __pyx_t_5numpy_int16_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< * ctypedef npy_int64 int64_t * #ctypedef npy_int96 int96_t */ typedef npy_int32 __pyx_t_5numpy_int32_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< * #ctypedef npy_int96 int96_t * #ctypedef npy_int128 int128_t */ typedef npy_int64 __pyx_t_5numpy_int64_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< * ctypedef npy_uint64 uint64_t * #ctypedef npy_uint96 uint96_t */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< * #ctypedef npy_uint96 uint96_t * #ctypedef npy_uint128 uint128_t */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< * ctypedef npy_float64 float64_t * #ctypedef npy_float80 float80_t */ typedef npy_float32 __pyx_t_5numpy_float32_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< * #ctypedef npy_float80 float80_t * #ctypedef npy_float128 float128_t */ typedef npy_float64 __pyx_t_5numpy_float64_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t */ typedef npy_long __pyx_t_5numpy_int_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< * ctypedef npy_longlong longlong_t * */ typedef npy_longlong __pyx_t_5numpy_long_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< * * ctypedef npy_ulong uint_t */ typedef npy_longlong __pyx_t_5numpy_longlong_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t */ typedef npy_ulong __pyx_t_5numpy_uint_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< * ctypedef npy_ulonglong ulonglong_t * */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< * * ctypedef npy_intp intp_t */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< * ctypedef npy_uintp uintp_t * */ typedef npy_intp __pyx_t_5numpy_intp_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< * * ctypedef npy_double float_t */ typedef npy_uintp __pyx_t_5numpy_uintp_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t */ typedef npy_double __pyx_t_5numpy_float_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< * ctypedef npy_longdouble longdouble_t * */ typedef npy_double __pyx_t_5numpy_double_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cfloat cfloat_t */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; /* None.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< float > __pyx_t_float_complex; #else typedef float _Complex __pyx_t_float_complex; #endif #else typedef struct { float real, imag; } __pyx_t_float_complex; #endif /* None.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus typedef ::std::complex< double > __pyx_t_double_complex; #else typedef double _Complex __pyx_t_double_complex; #endif #else typedef struct { double real, imag; } __pyx_t_double_complex; #endif /*--- Type declarations ---*/ struct __pyx_obj_7feather_3ext_FeatherWriter; struct __pyx_obj_7feather_3ext_Column; struct __pyx_obj_7feather_3ext_FeatherReader; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< * ctypedef npy_clongdouble clongdouble_t * */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< * * ctypedef npy_cdouble complex_t */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew1(a): */ typedef npy_cdouble __pyx_t_5numpy_complex_t; /* "feather/ext.pyx":69 * set_numpy_nan(np.nan) * * cdef class FeatherWriter: # <<<<<<<<<<<<<< * cdef: * unique_ptr[TableWriter] writer */ struct __pyx_obj_7feather_3ext_FeatherWriter { PyObject_HEAD struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *__pyx_vtab; std::unique_ptr writer; int64_t num_rows; }; /* "feather/ext.pyx":163 * * * cdef class Column: # <<<<<<<<<<<<<< * cdef: * shared_ptr[CColumnMetadata] metadata */ struct __pyx_obj_7feather_3ext_Column { PyObject_HEAD struct __pyx_vtabstruct_7feather_3ext_Column *__pyx_vtab; std::shared_ptr< feather::metadata::Column> metadata; feather::metadata::Column *mp; struct __pyx_obj_7feather_3ext_FeatherReader *parent; int column_index; }; /* "feather/ext.pyx":230 * * * cdef class FeatherReader: # <<<<<<<<<<<<<< * cdef: * unique_ptr[TableReader] reader */ struct __pyx_obj_7feather_3ext_FeatherReader { PyObject_HEAD std::unique_ptr reader; }; /* "feather/ext.pyx":69 * set_numpy_nan(np.nan) * * cdef class FeatherWriter: # <<<<<<<<<<<<<< * cdef: * unique_ptr[TableWriter] writer */ struct __pyx_vtabstruct_7feather_3ext_FeatherWriter { PyObject *(*write_category)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, PyObject *); PyObject *(*write_primitive)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, PyObject *); PyObject *(*write_timestamp)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, PyObject *); int (*write_ndarray)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, feather::PrimitiveArray *); }; static struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *__pyx_vtabptr_7feather_3ext_FeatherWriter; /* "feather/ext.pyx":163 * * * cdef class Column: # <<<<<<<<<<<<<< * cdef: * shared_ptr[CColumnMetadata] metadata */ struct __pyx_vtabstruct_7feather_3ext_Column { PyObject *(*init)(struct __pyx_obj_7feather_3ext_Column *, struct __pyx_obj_7feather_3ext_FeatherReader *, int); }; static struct __pyx_vtabstruct_7feather_3ext_Column *__pyx_vtabptr_7feather_3ext_Column; /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* PyThreadStateGet.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #endif /* PyErrFetchRestore.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /* GetAttr3.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /* KeywordStringCheck.proto */ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); /* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* None.proto */ #include /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____feather_3a__3a_ColumnType_3a__3a_type(enum feather::ColumnType::type value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* None.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus #define __Pyx_CREAL(z) ((z).real()) #define __Pyx_CIMAG(z) ((z).imag()) #else #define __Pyx_CREAL(z) (__real__(z)) #define __Pyx_CIMAG(z) (__imag__(z)) #endif #else #define __Pyx_CREAL(z) ((z).real) #define __Pyx_CIMAG(z) ((z).imag) #endif #if defined(__cplusplus) && CYTHON_CCOMPLEX && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) #define __Pyx_SET_CREAL(z,x) ((z).real(x)) #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) #else #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) #endif /* None.proto */ static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); /* None.proto */ #if CYTHON_CCOMPLEX #define __Pyx_c_eqf(a, b) ((a)==(b)) #define __Pyx_c_sumf(a, b) ((a)+(b)) #define __Pyx_c_difff(a, b) ((a)-(b)) #define __Pyx_c_prodf(a, b) ((a)*(b)) #define __Pyx_c_quotf(a, b) ((a)/(b)) #define __Pyx_c_negf(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zerof(z) ((z)==(float)0) #define __Pyx_c_conjf(z) (::std::conj(z)) #if 1 #define __Pyx_c_absf(z) (::std::abs(z)) #define __Pyx_c_powf(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zerof(z) ((z)==0) #define __Pyx_c_conjf(z) (conjf(z)) #if 1 #define __Pyx_c_absf(z) (cabsf(z)) #define __Pyx_c_powf(a, b) (cpowf(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); #endif #endif /* None.proto */ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); /* None.proto */ #if CYTHON_CCOMPLEX #define __Pyx_c_eq(a, b) ((a)==(b)) #define __Pyx_c_sum(a, b) ((a)+(b)) #define __Pyx_c_diff(a, b) ((a)-(b)) #define __Pyx_c_prod(a, b) ((a)*(b)) #define __Pyx_c_quot(a, b) ((a)/(b)) #define __Pyx_c_neg(a) (-(a)) #ifdef __cplusplus #define __Pyx_c_is_zero(z) ((z)==(double)0) #define __Pyx_c_conj(z) (::std::conj(z)) #if 1 #define __Pyx_c_abs(z) (::std::abs(z)) #define __Pyx_c_pow(a, b) (::std::pow(a, b)) #endif #else #define __Pyx_c_is_zero(z) ((z)==0) #define __Pyx_c_conj(z) (conj(z)) #if 1 #define __Pyx_c_abs(z) (cabs(z)) #define __Pyx_c_pow(a, b) (cpow(a, b)) #endif #endif #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); #endif #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); /* PyIdentifierFromString.proto */ #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif /* ModuleImport.proto */ static PyObject *__Pyx_ImportModule(const char *name); /* TypeImport.proto */ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static PyObject *__pyx_f_7feather_3ext_13FeatherWriter_write_category(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask); /* proto*/ static PyObject *__pyx_f_7feather_3ext_13FeatherWriter_write_primitive(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask); /* proto*/ static PyObject *__pyx_f_7feather_3ext_13FeatherWriter_write_timestamp(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask); /* proto*/ static int __pyx_f_7feather_3ext_13FeatherWriter_write_ndarray(CYTHON_UNUSED struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_values, PyObject *__pyx_v_mask, feather::PrimitiveArray *__pyx_v_out); /* proto*/ static PyObject *__pyx_f_7feather_3ext_6Column_init(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self, struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_parent, int __pyx_v_i); /* proto*/ /* Module declarations from 'libc.string' */ /* Module declarations from 'libcpp.string' */ /* Module declarations from 'libcpp' */ /* Module declarations from 'cpython.version' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'libc.stdio' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'cpython.exc' */ /* Module declarations from 'cpython.module' */ /* Module declarations from 'cpython.mem' */ /* Module declarations from 'cpython.tuple' */ /* Module declarations from 'cpython.list' */ /* Module declarations from 'cpython.sequence' */ /* Module declarations from 'cpython.mapping' */ /* Module declarations from 'cpython.iterator' */ /* Module declarations from 'cpython.number' */ /* Module declarations from 'cpython.int' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.bool' */ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; /* Module declarations from 'cpython.long' */ /* Module declarations from 'cpython.float' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.complex' */ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; /* Module declarations from 'cpython.string' */ /* Module declarations from 'cpython.unicode' */ /* Module declarations from 'cpython.dict' */ /* Module declarations from 'cpython.instance' */ /* Module declarations from 'cpython.function' */ /* Module declarations from 'cpython.method' */ /* Module declarations from 'cpython.weakref' */ /* Module declarations from 'cpython.getargs' */ /* Module declarations from 'cpython.pythread' */ /* Module declarations from 'cpython.pystate' */ /* Module declarations from 'cpython.cobject' */ /* Module declarations from 'cpython.oldbuffer' */ /* Module declarations from 'cpython.set' */ /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'cpython.bytes' */ /* Module declarations from 'cpython.pycapsule' */ /* Module declarations from 'cpython' */ /* Module declarations from 'libc.stdint' */ /* Module declarations from 'libcpp.vector' */ /* Module declarations from 'feather.libfeather' */ /* Module declarations from 'libc.stdlib' */ /* Module declarations from 'numpy' */ /* Module declarations from 'numpy' */ static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ /* Module declarations from 'feather.ext' */ static PyTypeObject *__pyx_ptype_7feather_3ext_FeatherWriter = 0; static PyTypeObject *__pyx_ptype_7feather_3ext_Column = 0; static PyTypeObject *__pyx_ptype_7feather_3ext_FeatherReader = 0; static PyObject *__pyx_f_7feather_3ext_check_status(feather::Status const &); /*proto*/ static PyObject *__pyx_f_7feather_3ext_update_mask_with_datatype_nulls(PyObject *, PyObject *); /*proto*/ static PyObject *__pyx_f_7feather_3ext__unbox_series(PyObject *); /*proto*/ static PyObject *__pyx_f_7feather_3ext_category_to_pandas( feather::Column *); /*proto*/ static PyObject *__pyx_f_7feather_3ext_timestamp_to_pandas( feather::Column *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ #define __Pyx_MODULE_NAME "feather.ext" int __pyx_module_is_main_feather__ext = 0; /* Implementation of 'feather.ext' */ static PyObject *__pyx_builtin_Exception; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_NotImplementedError; static PyObject *__pyx_builtin_IndexError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_RuntimeError; static const char __pyx_k__3[] = ""; static const char __pyx_k_i8[] = "i8"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_pd[] = "pd"; static const char __pyx_k_tz[] = "tz"; static const char __pyx_k_NaT[] = "NaT"; static const char __pyx_k_any[] = "any"; static const char __pyx_k_col[] = "col"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_nan[] = "nan"; static const char __pyx_k_six[] = "six"; static const char __pyx_k_utc[] = "utc"; static const char __pyx_k_iloc[] = "iloc"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_mask[] = "mask"; static const char __pyx_k_name[] = "name"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_view[] = "view"; static const char __pyx_k_zone[] = "zone"; static const char __pyx_k_M8_ns[] = "M8[ns]"; static const char __pyx_k_codes[] = "codes"; static const char __pyx_k_dtype[] = "dtype"; static const char __pyx_k_numpy[] = "numpy"; static const char __pyx_k_pdapi[] = "pdapi"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_Series[] = "Series"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_isnull[] = "isnull"; static const char __pyx_k_module[] = "__module__"; static const char __pyx_k_pandas[] = "pandas"; static const char __pyx_k_values[] = "values"; static const char __pyx_k_asarray[] = "asarray"; static const char __pyx_k_ordered[] = "ordered"; static const char __pyx_k_prepare[] = "__prepare__"; static const char __pyx_k_tobytes[] = "tobytes"; static const char __pyx_k_fastpath[] = "fastpath"; static const char __pyx_k_qualname[] = "__qualname__"; static const char __pyx_k_Exception[] = "Exception"; static const char __pyx_k_frombytes[] = "frombytes"; static const char __pyx_k_metaclass[] = "__metaclass__"; static const char __pyx_k_IndexError[] = "IndexError"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_categories[] = "categories"; static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_tz_convert[] = "tz_convert"; static const char __pyx_k_Categorical[] = "Categorical"; static const char __pyx_k_feather_ext[] = "feather.ext"; static const char __pyx_k_num_columns[] = "num_columns"; static const char __pyx_k_tz_localize[] = "tz_localize"; static const char __pyx_k_FeatherError[] = "FeatherError"; static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_DatetimeIndex[] = "DatetimeIndex"; static const char __pyx_k_feather_compat[] = "feather.compat"; static const char __pyx_k_encode_file_path[] = "encode_file_path"; static const char __pyx_k_NotImplementedError[] = "NotImplementedError"; static const char __pyx_k_is_categorical_dtype[] = "is_categorical_dtype"; static const char __pyx_k_is_datetime64_any_dtype[] = "is_datetime64_any_dtype"; static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; static const char __pyx_k_prior_column_had_a_different_num[] = "prior column had a different number of rows"; static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; static PyObject *__pyx_n_s_Categorical; static PyObject *__pyx_n_s_DatetimeIndex; static PyObject *__pyx_n_s_Exception; static PyObject *__pyx_n_s_FeatherError; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_n_s_IndexError; static PyObject *__pyx_kp_s_M8_ns; static PyObject *__pyx_n_s_NaT; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_NotImplementedError; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_Series; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_kp_b__3; static PyObject *__pyx_n_s_any; static PyObject *__pyx_n_s_asarray; static PyObject *__pyx_n_s_categories; static PyObject *__pyx_n_s_codes; static PyObject *__pyx_n_s_col; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_encode_file_path; static PyObject *__pyx_n_s_fastpath; static PyObject *__pyx_n_s_feather_compat; static PyObject *__pyx_n_s_feather_ext; static PyObject *__pyx_n_s_frombytes; static PyObject *__pyx_n_s_i8; static PyObject *__pyx_n_s_iloc; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_is_categorical_dtype; static PyObject *__pyx_n_s_is_datetime64_any_dtype; static PyObject *__pyx_n_s_isnull; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_mask; static PyObject *__pyx_n_s_metaclass; static PyObject *__pyx_n_s_module; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_nan; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_num_columns; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_ordered; static PyObject *__pyx_n_s_pandas; static PyObject *__pyx_n_s_pd; static PyObject *__pyx_n_s_pdapi; static PyObject *__pyx_n_s_prepare; static PyObject *__pyx_kp_s_prior_column_had_a_different_num; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_six; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_tobytes; static PyObject *__pyx_n_s_tz; static PyObject *__pyx_n_s_tz_convert; static PyObject *__pyx_n_s_tz_localize; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_utc; static PyObject *__pyx_n_s_values; static PyObject *__pyx_n_s_view; static PyObject *__pyx_n_s_zone; static int __pyx_pf_7feather_3ext_13FeatherWriter___cinit__(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ static PyObject *__pyx_pf_7feather_3ext_13FeatherWriter_2close(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_13FeatherWriter_4write_array(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask); /* proto */ static int __pyx_pf_7feather_3ext_6Column___cinit__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_6Column_4name___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_6Column_4type___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_6Column_13user_metadata___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_6Column_10null_count___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_6Column_2read(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self); /* proto */ static int __pyx_pf_7feather_3ext_13FeatherReader___cinit__(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ static PyObject *__pyx_pf_7feather_3ext_13FeatherReader_8num_rows___get__(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_13FeatherReader_11num_columns___get__(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_7feather_3ext_13FeatherReader_2get_column(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self, int __pyx_v_i); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static PyObject *__pyx_tp_new_7feather_3ext_FeatherWriter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_7feather_3ext_Column(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_7feather_3ext_FeatherReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_neg_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; static PyObject *__pyx_tuple__10; /* "feather/ext.pyx":52 * * * cdef check_status(const Status& status): # <<<<<<<<<<<<<< * if status.ok(): * return */ static PyObject *__pyx_f_7feather_3ext_check_status(feather::Status const &__pyx_v_status) { std::string __pyx_v_c_message; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("check_status", 0); /* "feather/ext.pyx":53 * * cdef check_status(const Status& status): * if status.ok(): # <<<<<<<<<<<<<< * return * */ __pyx_t_1 = (__pyx_v_status.ok() != 0); if (__pyx_t_1) { /* "feather/ext.pyx":54 * cdef check_status(const Status& status): * if status.ok(): * return # <<<<<<<<<<<<<< * * cdef string c_message = status.ToString() */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "feather/ext.pyx":53 * * cdef check_status(const Status& status): * if status.ok(): # <<<<<<<<<<<<<< * return * */ } /* "feather/ext.pyx":56 * return * * cdef string c_message = status.ToString() # <<<<<<<<<<<<<< * raise FeatherError(frombytes(c_message)) * */ __pyx_v_c_message = __pyx_v_status.ToString(); /* "feather/ext.pyx":57 * * cdef string c_message = status.ToString() * raise FeatherError(frombytes(c_message)) # <<<<<<<<<<<<<< * * cdef update_mask_with_datatype_nulls(mask, values): */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_FeatherError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_frombytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_c_message); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_7) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); } else { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_5) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 57, __pyx_L1_error) /* "feather/ext.pyx":52 * * * cdef check_status(const Status& status): # <<<<<<<<<<<<<< * if status.ok(): * return */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("feather.ext.check_status", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":59 * raise FeatherError(frombytes(c_message)) * * cdef update_mask_with_datatype_nulls(mask, values): # <<<<<<<<<<<<<< * datatype_nulls = pd.isnull(values) * if datatype_nulls.any(): */ static PyObject *__pyx_f_7feather_3ext_update_mask_with_datatype_nulls(PyObject *__pyx_v_mask, PyObject *__pyx_v_values) { PyObject *__pyx_v_datatype_nulls = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; __Pyx_RefNannySetupContext("update_mask_with_datatype_nulls", 0); /* "feather/ext.pyx":60 * * cdef update_mask_with_datatype_nulls(mask, values): * datatype_nulls = pd.isnull(values) # <<<<<<<<<<<<<< * if datatype_nulls.any(): * if mask is None: */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isnull); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(__pyx_v_values); __Pyx_GIVEREF(__pyx_v_values); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_values); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_datatype_nulls = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":61 * cdef update_mask_with_datatype_nulls(mask, values): * datatype_nulls = pd.isnull(values) * if datatype_nulls.any(): # <<<<<<<<<<<<<< * if mask is None: * return datatype_nulls */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_datatype_nulls, __pyx_n_s_any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* "feather/ext.pyx":62 * datatype_nulls = pd.isnull(values) * if datatype_nulls.any(): * if mask is None: # <<<<<<<<<<<<<< * return datatype_nulls * else: */ __pyx_t_5 = (__pyx_v_mask == Py_None); __pyx_t_6 = (__pyx_t_5 != 0); if (__pyx_t_6) { /* "feather/ext.pyx":63 * if datatype_nulls.any(): * if mask is None: * return datatype_nulls # <<<<<<<<<<<<<< * else: * return mask | datatype_nulls */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_datatype_nulls); __pyx_r = __pyx_v_datatype_nulls; goto __pyx_L0; /* "feather/ext.pyx":62 * datatype_nulls = pd.isnull(values) * if datatype_nulls.any(): * if mask is None: # <<<<<<<<<<<<<< * return datatype_nulls * else: */ } /* "feather/ext.pyx":65 * return datatype_nulls * else: * return mask | datatype_nulls # <<<<<<<<<<<<<< * * set_numpy_nan(np.nan) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyNumber_Or(__pyx_v_mask, __pyx_v_datatype_nulls); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } /* "feather/ext.pyx":61 * cdef update_mask_with_datatype_nulls(mask, values): * datatype_nulls = pd.isnull(values) * if datatype_nulls.any(): # <<<<<<<<<<<<<< * if mask is None: * return datatype_nulls */ } /* "feather/ext.pyx":59 * raise FeatherError(frombytes(c_message)) * * cdef update_mask_with_datatype_nulls(mask, values): # <<<<<<<<<<<<<< * datatype_nulls = pd.isnull(values) * if datatype_nulls.any(): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("feather.ext.update_mask_with_datatype_nulls", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_datatype_nulls); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":74 * int64_t num_rows * * def __cinit__(self, object name): # <<<<<<<<<<<<<< * cdef: * string c_name = encode_file_path(name) */ /* Python wrapper */ static int __pyx_pw_7feather_3ext_13FeatherWriter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7feather_3ext_13FeatherWriter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 74, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_name = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 74, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("feather.ext.FeatherWriter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7feather_3ext_13FeatherWriter___cinit__(((struct __pyx_obj_7feather_3ext_FeatherWriter *)__pyx_v_self), __pyx_v_name); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7feather_3ext_13FeatherWriter___cinit__(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name) { std::string __pyx_v_c_name; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; std::string __pyx_t_5; __Pyx_RefNannySetupContext("__cinit__", 0); /* "feather/ext.pyx":76 * def __cinit__(self, object name): * cdef: * string c_name = encode_file_path(name) # <<<<<<<<<<<<<< * * check_status(TableWriter.OpenFile(c_name, &self.writer)) */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_encode_file_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_c_name = __pyx_t_5; /* "feather/ext.pyx":78 * string c_name = encode_file_path(name) * * check_status(TableWriter.OpenFile(c_name, &self.writer)) # <<<<<<<<<<<<<< * self.num_rows = -1 * */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(feather::TableWriter::OpenFile(__pyx_v_c_name, (&__pyx_v_self->writer))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":79 * * check_status(TableWriter.OpenFile(c_name, &self.writer)) * self.num_rows = -1 # <<<<<<<<<<<<<< * * def close(self): */ __pyx_v_self->num_rows = -1L; /* "feather/ext.pyx":74 * int64_t num_rows * * def __cinit__(self, object name): # <<<<<<<<<<<<<< * cdef: * string c_name = encode_file_path(name) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("feather.ext.FeatherWriter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":81 * self.num_rows = -1 * * def close(self): # <<<<<<<<<<<<<< * if self.num_rows < 0: * self.num_rows = 0 */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_13FeatherWriter_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_7feather_3ext_13FeatherWriter_2close[] = "FeatherWriter.close(self)"; static PyObject *__pyx_pw_7feather_3ext_13FeatherWriter_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("close (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_13FeatherWriter_2close(((struct __pyx_obj_7feather_3ext_FeatherWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_13FeatherWriter_2close(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("close", 0); /* "feather/ext.pyx":82 * * def close(self): * if self.num_rows < 0: # <<<<<<<<<<<<<< * self.num_rows = 0 * self.writer.get().SetNumRows(self.num_rows) */ __pyx_t_1 = ((__pyx_v_self->num_rows < 0) != 0); if (__pyx_t_1) { /* "feather/ext.pyx":83 * def close(self): * if self.num_rows < 0: * self.num_rows = 0 # <<<<<<<<<<<<<< * self.writer.get().SetNumRows(self.num_rows) * check_status(self.writer.get().Finalize()) */ __pyx_v_self->num_rows = 0; /* "feather/ext.pyx":82 * * def close(self): * if self.num_rows < 0: # <<<<<<<<<<<<<< * self.num_rows = 0 * self.writer.get().SetNumRows(self.num_rows) */ } /* "feather/ext.pyx":84 * if self.num_rows < 0: * self.num_rows = 0 * self.writer.get().SetNumRows(self.num_rows) # <<<<<<<<<<<<<< * check_status(self.writer.get().Finalize()) * */ __pyx_v_self->writer.get()->SetNumRows(__pyx_v_self->num_rows); /* "feather/ext.pyx":85 * self.num_rows = 0 * self.writer.get().SetNumRows(self.num_rows) * check_status(self.writer.get().Finalize()) # <<<<<<<<<<<<<< * * def write_array(self, object name, object col, object mask=None): */ __pyx_t_2 = __pyx_f_7feather_3ext_check_status(__pyx_v_self->writer.get()->Finalize()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "feather/ext.pyx":81 * self.num_rows = -1 * * def close(self): # <<<<<<<<<<<<<< * if self.num_rows < 0: * self.num_rows = 0 */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("feather.ext.FeatherWriter.close", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":87 * check_status(self.writer.get().Finalize()) * * def write_array(self, object name, object col, object mask=None): # <<<<<<<<<<<<<< * if self.num_rows >= 0: * if len(col) != self.num_rows: */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_13FeatherWriter_5write_array(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_7feather_3ext_13FeatherWriter_4write_array[] = "FeatherWriter.write_array(self, name, col, mask=None)"; static PyObject *__pyx_pw_7feather_3ext_13FeatherWriter_5write_array(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; PyObject *__pyx_v_col = 0; PyObject *__pyx_v_mask = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_array (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_col,&__pyx_n_s_mask,0}; PyObject* values[3] = {0,0,0}; values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_col)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("write_array", 0, 2, 3, 1); __PYX_ERR(0, 87, __pyx_L3_error) } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mask); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_array") < 0)) __PYX_ERR(0, 87, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = values[0]; __pyx_v_col = values[1]; __pyx_v_mask = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_array", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 87, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("feather.ext.FeatherWriter.write_array", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7feather_3ext_13FeatherWriter_4write_array(((struct __pyx_obj_7feather_3ext_FeatherWriter *)__pyx_v_self), __pyx_v_name, __pyx_v_col, __pyx_v_mask); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_13FeatherWriter_4write_array(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("write_array", 0); /* "feather/ext.pyx":88 * * def write_array(self, object name, object col, object mask=None): * if self.num_rows >= 0: # <<<<<<<<<<<<<< * if len(col) != self.num_rows: * raise ValueError('prior column had a different number of rows') */ __pyx_t_1 = ((__pyx_v_self->num_rows >= 0) != 0); if (__pyx_t_1) { /* "feather/ext.pyx":89 * def write_array(self, object name, object col, object mask=None): * if self.num_rows >= 0: * if len(col) != self.num_rows: # <<<<<<<<<<<<<< * raise ValueError('prior column had a different number of rows') * else: */ __pyx_t_2 = PyObject_Length(__pyx_v_col); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 89, __pyx_L1_error) __pyx_t_1 = ((__pyx_t_2 != __pyx_v_self->num_rows) != 0); if (__pyx_t_1) { /* "feather/ext.pyx":90 * if self.num_rows >= 0: * if len(col) != self.num_rows: * raise ValueError('prior column had a different number of rows') # <<<<<<<<<<<<<< * else: * self.num_rows = len(col) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 90, __pyx_L1_error) /* "feather/ext.pyx":89 * def write_array(self, object name, object col, object mask=None): * if self.num_rows >= 0: * if len(col) != self.num_rows: # <<<<<<<<<<<<<< * raise ValueError('prior column had a different number of rows') * else: */ } /* "feather/ext.pyx":88 * * def write_array(self, object name, object col, object mask=None): * if self.num_rows >= 0: # <<<<<<<<<<<<<< * if len(col) != self.num_rows: * raise ValueError('prior column had a different number of rows') */ goto __pyx_L3; } /* "feather/ext.pyx":92 * raise ValueError('prior column had a different number of rows') * else: * self.num_rows = len(col) # <<<<<<<<<<<<<< * * if pdapi.is_categorical_dtype(col.dtype): */ /*else*/ { __pyx_t_2 = PyObject_Length(__pyx_v_col); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 92, __pyx_L1_error) __pyx_v_self->num_rows = __pyx_t_2; } __pyx_L3:; /* "feather/ext.pyx":94 * self.num_rows = len(col) * * if pdapi.is_categorical_dtype(col.dtype): # <<<<<<<<<<<<<< * self.write_category(name, col, mask) * elif pdapi.is_datetime64_any_dtype(col.dtype): */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_pdapi); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_is_categorical_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (!__pyx_t_6) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* "feather/ext.pyx":95 * * if pdapi.is_categorical_dtype(col.dtype): * self.write_category(name, col, mask) # <<<<<<<<<<<<<< * elif pdapi.is_datetime64_any_dtype(col.dtype): * self.write_timestamp(name, col, mask) */ __pyx_t_3 = ((struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *)__pyx_v_self->__pyx_vtab)->write_category(__pyx_v_self, __pyx_v_name, __pyx_v_col, __pyx_v_mask); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "feather/ext.pyx":94 * self.num_rows = len(col) * * if pdapi.is_categorical_dtype(col.dtype): # <<<<<<<<<<<<<< * self.write_category(name, col, mask) * elif pdapi.is_datetime64_any_dtype(col.dtype): */ goto __pyx_L5; } /* "feather/ext.pyx":96 * if pdapi.is_categorical_dtype(col.dtype): * self.write_category(name, col, mask) * elif pdapi.is_datetime64_any_dtype(col.dtype): # <<<<<<<<<<<<<< * self.write_timestamp(name, col, mask) * else: */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pdapi); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_is_datetime64_any_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_4) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* "feather/ext.pyx":97 * self.write_category(name, col, mask) * elif pdapi.is_datetime64_any_dtype(col.dtype): * self.write_timestamp(name, col, mask) # <<<<<<<<<<<<<< * else: * self.write_primitive(name, col, mask) */ __pyx_t_3 = ((struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *)__pyx_v_self->__pyx_vtab)->write_timestamp(__pyx_v_self, __pyx_v_name, __pyx_v_col, __pyx_v_mask); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "feather/ext.pyx":96 * if pdapi.is_categorical_dtype(col.dtype): * self.write_category(name, col, mask) * elif pdapi.is_datetime64_any_dtype(col.dtype): # <<<<<<<<<<<<<< * self.write_timestamp(name, col, mask) * else: */ goto __pyx_L5; } /* "feather/ext.pyx":99 * self.write_timestamp(name, col, mask) * else: * self.write_primitive(name, col, mask) # <<<<<<<<<<<<<< * * cdef write_category(self, name, col, mask): */ /*else*/ { __pyx_t_3 = ((struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *)__pyx_v_self->__pyx_vtab)->write_primitive(__pyx_v_self, __pyx_v_name, __pyx_v_col, __pyx_v_mask); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L5:; /* "feather/ext.pyx":87 * check_status(self.writer.get().Finalize()) * * def write_array(self, object name, object col, object mask=None): # <<<<<<<<<<<<<< * if self.num_rows >= 0: * if len(col) != self.num_rows: */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("feather.ext.FeatherWriter.write_array", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":101 * self.write_primitive(name, col, mask) * * cdef write_category(self, name, col, mask): # <<<<<<<<<<<<<< * cdef: * string c_name = tobytes(name) */ static PyObject *__pyx_f_7feather_3ext_13FeatherWriter_write_category(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask) { std::string __pyx_v_c_name; feather::PrimitiveArray __pyx_v_values; feather::PrimitiveArray __pyx_v_levels; PyObject *__pyx_v_col_values = NULL; PyObject *__pyx_v_mask_to_file = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; std::string __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; bool __pyx_t_8; __Pyx_RefNannySetupContext("write_category", 0); /* "feather/ext.pyx":103 * cdef write_category(self, name, col, mask): * cdef: * string c_name = tobytes(name) # <<<<<<<<<<<<<< * PrimitiveArray values * PrimitiveArray levels */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tobytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_c_name = __pyx_t_5; /* "feather/ext.pyx":107 * PrimitiveArray levels * * col_values = _unbox_series(col) # <<<<<<<<<<<<<< * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) * */ __pyx_t_1 = __pyx_f_7feather_3ext__unbox_series(__pyx_v_col); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_col_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":108 * * col_values = _unbox_series(col) * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) # <<<<<<<<<<<<<< * * self.write_ndarray(col_values.codes, mask_to_file, &values) */ __pyx_t_1 = __pyx_f_7feather_3ext_update_mask_with_datatype_nulls(__pyx_v_mask, __pyx_v_col_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mask_to_file = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":110 * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) * * self.write_ndarray(col_values.codes, mask_to_file, &values) # <<<<<<<<<<<<<< * check_status(pandas_to_primitive(np.asarray(col_values.categories), * &levels)) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_col_values, __pyx_n_s_codes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = ((struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *)__pyx_v_self->__pyx_vtab)->write_ndarray(__pyx_v_self, __pyx_t_1, __pyx_v_mask_to_file, (&__pyx_v_values)); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":111 * * self.write_ndarray(col_values.codes, mask_to_file, &values) * check_status(pandas_to_primitive(np.asarray(col_values.categories), # <<<<<<<<<<<<<< * &levels)) * check_status(self.writer.get().AppendCategory(c_name, values, levels, */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_col_values, __pyx_n_s_categories); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "feather/ext.pyx":112 * self.write_ndarray(col_values.codes, mask_to_file, &values) * check_status(pandas_to_primitive(np.asarray(col_values.categories), * &levels)) # <<<<<<<<<<<<<< * check_status(self.writer.get().AppendCategory(c_name, values, levels, * col_values.ordered)) */ __pyx_t_4 = __pyx_f_7feather_3ext_check_status(feather::py::pandas_to_primitive(__pyx_t_1, (&__pyx_v_levels))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "feather/ext.pyx":114 * &levels)) * check_status(self.writer.get().AppendCategory(c_name, values, levels, * col_values.ordered)) # <<<<<<<<<<<<<< * * cdef write_primitive(self, name, col, mask): */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_col_values, __pyx_n_s_ordered); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 == (bool)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "feather/ext.pyx":113 * check_status(pandas_to_primitive(np.asarray(col_values.categories), * &levels)) * check_status(self.writer.get().AppendCategory(c_name, values, levels, # <<<<<<<<<<<<<< * col_values.ordered)) * */ __pyx_t_4 = __pyx_f_7feather_3ext_check_status(__pyx_v_self->writer.get()->AppendCategory(__pyx_v_c_name, __pyx_v_values, __pyx_v_levels, __pyx_t_8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "feather/ext.pyx":101 * self.write_primitive(name, col, mask) * * cdef write_category(self, name, col, mask): # <<<<<<<<<<<<<< * cdef: * string c_name = tobytes(name) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("feather.ext.FeatherWriter.write_category", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_col_values); __Pyx_XDECREF(__pyx_v_mask_to_file); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":116 * col_values.ordered)) * * cdef write_primitive(self, name, col, mask): # <<<<<<<<<<<<<< * cdef: * string c_name = tobytes(name) */ static PyObject *__pyx_f_7feather_3ext_13FeatherWriter_write_primitive(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask) { std::string __pyx_v_c_name; feather::PrimitiveArray __pyx_v_values; PyObject *__pyx_v_col_values = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; std::string __pyx_t_5; int __pyx_t_6; __Pyx_RefNannySetupContext("write_primitive", 0); /* "feather/ext.pyx":118 * cdef write_primitive(self, name, col, mask): * cdef: * string c_name = tobytes(name) # <<<<<<<<<<<<<< * PrimitiveArray values * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tobytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_c_name = __pyx_t_5; /* "feather/ext.pyx":121 * PrimitiveArray values * * col_values = _unbox_series(col) # <<<<<<<<<<<<<< * self.write_ndarray(col_values, mask, &values) * check_status(self.writer.get().AppendPlain(c_name, values)) */ __pyx_t_1 = __pyx_f_7feather_3ext__unbox_series(__pyx_v_col); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_col_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":122 * * col_values = _unbox_series(col) * self.write_ndarray(col_values, mask, &values) # <<<<<<<<<<<<<< * check_status(self.writer.get().AppendPlain(c_name, values)) * */ __pyx_t_6 = ((struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *)__pyx_v_self->__pyx_vtab)->write_ndarray(__pyx_v_self, __pyx_v_col_values, __pyx_v_mask, (&__pyx_v_values)); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 122, __pyx_L1_error) /* "feather/ext.pyx":123 * col_values = _unbox_series(col) * self.write_ndarray(col_values, mask, &values) * check_status(self.writer.get().AppendPlain(c_name, values)) # <<<<<<<<<<<<<< * * cdef write_timestamp(self, name, col, mask): */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(__pyx_v_self->writer.get()->AppendPlain(__pyx_v_c_name, __pyx_v_values)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":116 * col_values.ordered)) * * cdef write_primitive(self, name, col, mask): # <<<<<<<<<<<<<< * cdef: * string c_name = tobytes(name) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("feather.ext.FeatherWriter.write_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_col_values); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":125 * check_status(self.writer.get().AppendPlain(c_name, values)) * * cdef write_timestamp(self, name, col, mask): # <<<<<<<<<<<<<< * cdef: * string c_name = tobytes(name) */ static PyObject *__pyx_f_7feather_3ext_13FeatherWriter_write_timestamp(struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_col, PyObject *__pyx_v_mask) { std::string __pyx_v_c_name; feather::PrimitiveArray __pyx_v_values; feather::TimestampMetadata __pyx_v_metadata; PyObject *__pyx_v_col_values = NULL; PyObject *__pyx_v_mask_to_file = NULL; PyObject *__pyx_v_tz = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; std::string __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("write_timestamp", 0); /* "feather/ext.pyx":127 * cdef write_timestamp(self, name, col, mask): * cdef: * string c_name = tobytes(name) # <<<<<<<<<<<<<< * PrimitiveArray values * TimestampMetadata metadata */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tobytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_c_name = __pyx_t_5; /* "feather/ext.pyx":131 * TimestampMetadata metadata * * col_values = _unbox_series(col) # <<<<<<<<<<<<<< * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) * */ __pyx_t_1 = __pyx_f_7feather_3ext__unbox_series(__pyx_v_col); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_col_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":132 * * col_values = _unbox_series(col) * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) # <<<<<<<<<<<<<< * * self.write_ndarray(col_values.view('i8'), mask_to_file, &values) */ __pyx_t_1 = __pyx_f_7feather_3ext_update_mask_with_datatype_nulls(__pyx_v_mask, __pyx_v_col_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mask_to_file = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":134 * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) * * self.write_ndarray(col_values.view('i8'), mask_to_file, &values) # <<<<<<<<<<<<<< * * metadata.unit = TimeUnit_NANOSECOND */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_col_values, __pyx_n_s_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = ((struct __pyx_vtabstruct_7feather_3ext_FeatherWriter *)__pyx_v_self->__pyx_vtab)->write_ndarray(__pyx_v_self, __pyx_t_2, __pyx_v_mask_to_file, (&__pyx_v_values)); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "feather/ext.pyx":136 * self.write_ndarray(col_values.view('i8'), mask_to_file, &values) * * metadata.unit = TimeUnit_NANOSECOND # <<<<<<<<<<<<<< * * tz = getattr(col.dtype, 'tz', None) */ __pyx_v_metadata.unit = feather::TimeUnit::NANOSECOND; /* "feather/ext.pyx":138 * metadata.unit = TimeUnit_NANOSECOND * * tz = getattr(col.dtype, 'tz', None) # <<<<<<<<<<<<<< * if tz is None: * metadata.timezone = b'' */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetAttr3(__pyx_t_2, __pyx_n_s_tz, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_tz = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":139 * * tz = getattr(col.dtype, 'tz', None) * if tz is None: # <<<<<<<<<<<<<< * metadata.timezone = b'' * else: */ __pyx_t_7 = (__pyx_v_tz == Py_None); __pyx_t_8 = (__pyx_t_7 != 0); if (__pyx_t_8) { /* "feather/ext.pyx":140 * tz = getattr(col.dtype, 'tz', None) * if tz is None: * metadata.timezone = b'' # <<<<<<<<<<<<<< * else: * metadata.timezone = tobytes(tz.zone) */ __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_kp_b__3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L1_error) __pyx_v_metadata.timezone = __pyx_t_5; /* "feather/ext.pyx":139 * * tz = getattr(col.dtype, 'tz', None) * if tz is None: # <<<<<<<<<<<<<< * metadata.timezone = b'' * else: */ goto __pyx_L3; } /* "feather/ext.pyx":142 * metadata.timezone = b'' * else: * metadata.timezone = tobytes(tz.zone) # <<<<<<<<<<<<<< * * check_status(self.writer.get().AppendTimestamp(c_name, values, */ /*else*/ { __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_tobytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_tz, __pyx_n_s_zone); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_metadata.timezone = __pyx_t_5; } __pyx_L3:; /* "feather/ext.pyx":144 * metadata.timezone = tobytes(tz.zone) * * check_status(self.writer.get().AppendTimestamp(c_name, values, # <<<<<<<<<<<<<< * metadata)) * */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(__pyx_v_self->writer.get()->AppendTimestamp(__pyx_v_c_name, __pyx_v_values, __pyx_v_metadata)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":125 * check_status(self.writer.get().AppendPlain(c_name, values)) * * cdef write_timestamp(self, name, col, mask): # <<<<<<<<<<<<<< * cdef: * string c_name = tobytes(name) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("feather.ext.FeatherWriter.write_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_col_values); __Pyx_XDECREF(__pyx_v_mask_to_file); __Pyx_XDECREF(__pyx_v_tz); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":147 * metadata)) * * cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1: # <<<<<<<<<<<<<< * if mask is None: * check_status(pandas_to_primitive(values, out)) */ static int __pyx_f_7feather_3ext_13FeatherWriter_write_ndarray(CYTHON_UNUSED struct __pyx_obj_7feather_3ext_FeatherWriter *__pyx_v_self, PyObject *__pyx_v_values, PyObject *__pyx_v_mask, feather::PrimitiveArray *__pyx_v_out) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("write_ndarray", 0); /* "feather/ext.pyx":148 * * cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1: * if mask is None: # <<<<<<<<<<<<<< * check_status(pandas_to_primitive(values, out)) * else: */ __pyx_t_1 = (__pyx_v_mask == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "feather/ext.pyx":149 * cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1: * if mask is None: * check_status(pandas_to_primitive(values, out)) # <<<<<<<<<<<<<< * else: * check_status(pandas_masked_to_primitive(values, mask, out)) */ __pyx_t_3 = __pyx_f_7feather_3ext_check_status(feather::py::pandas_to_primitive(__pyx_v_values, __pyx_v_out)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "feather/ext.pyx":148 * * cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1: * if mask is None: # <<<<<<<<<<<<<< * check_status(pandas_to_primitive(values, out)) * else: */ goto __pyx_L3; } /* "feather/ext.pyx":151 * check_status(pandas_to_primitive(values, out)) * else: * check_status(pandas_masked_to_primitive(values, mask, out)) # <<<<<<<<<<<<<< * return 0 * */ /*else*/ { __pyx_t_3 = __pyx_f_7feather_3ext_check_status(feather::py::pandas_masked_to_primitive(__pyx_v_values, __pyx_v_mask, __pyx_v_out)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L3:; /* "feather/ext.pyx":152 * else: * check_status(pandas_masked_to_primitive(values, mask, out)) * return 0 # <<<<<<<<<<<<<< * * */ __pyx_r = 0; goto __pyx_L0; /* "feather/ext.pyx":147 * metadata)) * * cdef int write_ndarray(self, values, mask, PrimitiveArray* out) except -1: # <<<<<<<<<<<<<< * if mask is None: * check_status(pandas_to_primitive(values, out)) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("feather.ext.FeatherWriter.write_ndarray", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":155 * * * cdef _unbox_series(col): # <<<<<<<<<<<<<< * if isinstance(col, pd.Series): * col_values = col.values */ static PyObject *__pyx_f_7feather_3ext__unbox_series(PyObject *__pyx_v_col) { PyObject *__pyx_v_col_values = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; __Pyx_RefNannySetupContext("_unbox_series", 0); /* "feather/ext.pyx":156 * * cdef _unbox_series(col): * if isinstance(col, pd.Series): # <<<<<<<<<<<<<< * col_values = col.values * else: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_col, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* "feather/ext.pyx":157 * cdef _unbox_series(col): * if isinstance(col, pd.Series): * col_values = col.values # <<<<<<<<<<<<<< * else: * col_values = col */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_col_values = __pyx_t_2; __pyx_t_2 = 0; /* "feather/ext.pyx":156 * * cdef _unbox_series(col): * if isinstance(col, pd.Series): # <<<<<<<<<<<<<< * col_values = col.values * else: */ goto __pyx_L3; } /* "feather/ext.pyx":159 * col_values = col.values * else: * col_values = col # <<<<<<<<<<<<<< * return col_values * */ /*else*/ { __Pyx_INCREF(__pyx_v_col); __pyx_v_col_values = __pyx_v_col; } __pyx_L3:; /* "feather/ext.pyx":160 * else: * col_values = col * return col_values # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_col_values); __pyx_r = __pyx_v_col_values; goto __pyx_L0; /* "feather/ext.pyx":155 * * * cdef _unbox_series(col): # <<<<<<<<<<<<<< * if isinstance(col, pd.Series): * col_values = col.values */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("feather.ext._unbox_series", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_col_values); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":170 * int column_index * * def __cinit__(self): # <<<<<<<<<<<<<< * self.mp = NULL * */ /* Python wrapper */ static int __pyx_pw_7feather_3ext_6Column_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7feather_3ext_6Column_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; __pyx_r = __pyx_pf_7feather_3ext_6Column___cinit__(((struct __pyx_obj_7feather_3ext_Column *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7feather_3ext_6Column___cinit__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); /* "feather/ext.pyx":171 * * def __cinit__(self): * self.mp = NULL # <<<<<<<<<<<<<< * * cdef init(self, FeatherReader parent, int i): */ __pyx_v_self->mp = NULL; /* "feather/ext.pyx":170 * int column_index * * def __cinit__(self): # <<<<<<<<<<<<<< * self.mp = NULL * */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":173 * self.mp = NULL * * cdef init(self, FeatherReader parent, int i): # <<<<<<<<<<<<<< * cdef TableReader* tbl = parent.reader.get() * */ static PyObject *__pyx_f_7feather_3ext_6Column_init(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self, struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_parent, int __pyx_v_i) { feather::TableReader *__pyx_v_tbl; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("init", 0); /* "feather/ext.pyx":174 * * cdef init(self, FeatherReader parent, int i): * cdef TableReader* tbl = parent.reader.get() # <<<<<<<<<<<<<< * * self.parent = parent */ __pyx_v_tbl = __pyx_v_parent->reader.get(); /* "feather/ext.pyx":176 * cdef TableReader* tbl = parent.reader.get() * * self.parent = parent # <<<<<<<<<<<<<< * self.column_index = i * */ __Pyx_INCREF(((PyObject *)__pyx_v_parent)); __Pyx_GIVEREF(((PyObject *)__pyx_v_parent)); __Pyx_GOTREF(__pyx_v_self->parent); __Pyx_DECREF(((PyObject *)__pyx_v_self->parent)); __pyx_v_self->parent = __pyx_v_parent; /* "feather/ext.pyx":177 * * self.parent = parent * self.column_index = i # <<<<<<<<<<<<<< * * check_status(tbl.GetColumnMetadata(i, &self.metadata)) */ __pyx_v_self->column_index = __pyx_v_i; /* "feather/ext.pyx":179 * self.column_index = i * * check_status(tbl.GetColumnMetadata(i, &self.metadata)) # <<<<<<<<<<<<<< * self.mp = self.metadata.get() * */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(__pyx_v_tbl->GetColumnMetadata(__pyx_v_i, (&__pyx_v_self->metadata))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":180 * * check_status(tbl.GetColumnMetadata(i, &self.metadata)) * self.mp = self.metadata.get() # <<<<<<<<<<<<<< * * property name: */ __pyx_v_self->mp = __pyx_v_self->metadata.get(); /* "feather/ext.pyx":173 * self.mp = NULL * * cdef init(self, FeatherReader parent, int i): # <<<<<<<<<<<<<< * cdef TableReader* tbl = parent.reader.get() * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("feather.ext.Column.init", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":184 * property name: * * def __get__(self): # <<<<<<<<<<<<<< * return frombytes(self.mp.name()) * */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_6Column_4name_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7feather_3ext_6Column_4name_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_6Column_4name___get__(((struct __pyx_obj_7feather_3ext_Column *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_6Column_4name___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "feather/ext.pyx":185 * * def __get__(self): * return frombytes(self.mp.name()) # <<<<<<<<<<<<<< * * property type: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frombytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_self->mp->name()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "feather/ext.pyx":184 * property name: * * def __get__(self): # <<<<<<<<<<<<<< * return frombytes(self.mp.name()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("feather.ext.Column.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":189 * property type: * * def __get__(self): # <<<<<<<<<<<<<< * return self.mp.type() * */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_6Column_4type_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7feather_3ext_6Column_4type_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_6Column_4type___get__(((struct __pyx_obj_7feather_3ext_Column *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_6Column_4type___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "feather/ext.pyx":190 * * def __get__(self): * return self.mp.type() # <<<<<<<<<<<<<< * * property user_metadata: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_enum____feather_3a__3a_ColumnType_3a__3a_type(__pyx_v_self->mp->type()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "feather/ext.pyx":189 * property type: * * def __get__(self): # <<<<<<<<<<<<<< * return self.mp.type() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("feather.ext.Column.type.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":194 * property user_metadata: * * def __get__(self): # <<<<<<<<<<<<<< * return frombytes(self.mp.user_metadata()) * */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_6Column_13user_metadata_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7feather_3ext_6Column_13user_metadata_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_6Column_13user_metadata___get__(((struct __pyx_obj_7feather_3ext_Column *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_6Column_13user_metadata___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "feather/ext.pyx":195 * * def __get__(self): * return frombytes(self.mp.user_metadata()) # <<<<<<<<<<<<<< * * property null_count: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frombytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_self->mp->user_metadata()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "feather/ext.pyx":194 * property user_metadata: * * def __get__(self): # <<<<<<<<<<<<<< * return frombytes(self.mp.user_metadata()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("feather.ext.Column.user_metadata.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":198 * * property null_count: * def __get__(self): # <<<<<<<<<<<<<< * cdef: * unique_ptr[CColumn] col */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_6Column_10null_count_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7feather_3ext_6Column_10null_count_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_6Column_10null_count___get__(((struct __pyx_obj_7feather_3ext_Column *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_6Column_10null_count___get__(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self) { std::unique_ptr< feather::Column> __pyx_v_col; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "feather/ext.pyx":203 * CColumn* cp * * check_status(self.parent.reader.get() # <<<<<<<<<<<<<< * .GetColumn(self.column_index, &col)) * */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(__pyx_v_self->parent->reader.get()->GetColumn(__pyx_v_self->column_index, (&__pyx_v_col))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":206 * .GetColumn(self.column_index, &col)) * * return col.get().values().null_count # <<<<<<<<<<<<<< * * def read(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_col.get()->values().null_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "feather/ext.pyx":198 * * property null_count: * def __get__(self): # <<<<<<<<<<<<<< * cdef: * unique_ptr[CColumn] col */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("feather.ext.Column.null_count.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":208 * return col.get().values().null_count * * def read(self): # <<<<<<<<<<<<<< * cdef: * unique_ptr[CColumn] col */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_6Column_3read(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_7feather_3ext_6Column_2read[] = "Column.read(self)"; static PyObject *__pyx_pw_7feather_3ext_6Column_3read(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_6Column_2read(((struct __pyx_obj_7feather_3ext_Column *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_6Column_2read(struct __pyx_obj_7feather_3ext_Column *__pyx_v_self) { std::unique_ptr< feather::Column> __pyx_v_col; feather::Column *__pyx_v_cp; PyObject *__pyx_v_values = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("read", 0); /* "feather/ext.pyx":213 * CColumn* cp * * check_status(self.parent.reader.get() # <<<<<<<<<<<<<< * .GetColumn(self.column_index, &col)) * */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(__pyx_v_self->parent->reader.get()->GetColumn(__pyx_v_self->column_index, (&__pyx_v_col))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":216 * .GetColumn(self.column_index, &col)) * * cp = col.get() # <<<<<<<<<<<<<< * * if cp.type() == ColumnType_PRIMITIVE: */ __pyx_v_cp = __pyx_v_col.get(); /* "feather/ext.pyx":218 * cp = col.get() * * if cp.type() == ColumnType_PRIMITIVE: # <<<<<<<<<<<<<< * values = primitive_to_pandas(cp.values()) * elif cp.type() == ColumnType_CATEGORY: */ __pyx_t_2 = ((__pyx_v_cp->type() == feather::ColumnType::PRIMITIVE) != 0); if (__pyx_t_2) { /* "feather/ext.pyx":219 * * if cp.type() == ColumnType_PRIMITIVE: * values = primitive_to_pandas(cp.values()) # <<<<<<<<<<<<<< * elif cp.type() == ColumnType_CATEGORY: * values = category_to_pandas(cp) */ __pyx_t_1 = feather::py::primitive_to_pandas(__pyx_v_cp->values()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":218 * cp = col.get() * * if cp.type() == ColumnType_PRIMITIVE: # <<<<<<<<<<<<<< * values = primitive_to_pandas(cp.values()) * elif cp.type() == ColumnType_CATEGORY: */ goto __pyx_L3; } /* "feather/ext.pyx":220 * if cp.type() == ColumnType_PRIMITIVE: * values = primitive_to_pandas(cp.values()) * elif cp.type() == ColumnType_CATEGORY: # <<<<<<<<<<<<<< * values = category_to_pandas(cp) * elif cp.type() == ColumnType_TIMESTAMP: */ __pyx_t_2 = ((__pyx_v_cp->type() == feather::ColumnType::CATEGORY) != 0); if (__pyx_t_2) { /* "feather/ext.pyx":221 * values = primitive_to_pandas(cp.values()) * elif cp.type() == ColumnType_CATEGORY: * values = category_to_pandas(cp) # <<<<<<<<<<<<<< * elif cp.type() == ColumnType_TIMESTAMP: * values = timestamp_to_pandas(cp) */ __pyx_t_1 = __pyx_f_7feather_3ext_category_to_pandas(__pyx_v_cp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":220 * if cp.type() == ColumnType_PRIMITIVE: * values = primitive_to_pandas(cp.values()) * elif cp.type() == ColumnType_CATEGORY: # <<<<<<<<<<<<<< * values = category_to_pandas(cp) * elif cp.type() == ColumnType_TIMESTAMP: */ goto __pyx_L3; } /* "feather/ext.pyx":222 * elif cp.type() == ColumnType_CATEGORY: * values = category_to_pandas(cp) * elif cp.type() == ColumnType_TIMESTAMP: # <<<<<<<<<<<<<< * values = timestamp_to_pandas(cp) * else: */ __pyx_t_2 = ((__pyx_v_cp->type() == feather::ColumnType::TIMESTAMP) != 0); if (__pyx_t_2) { /* "feather/ext.pyx":223 * values = category_to_pandas(cp) * elif cp.type() == ColumnType_TIMESTAMP: * values = timestamp_to_pandas(cp) # <<<<<<<<<<<<<< * else: * raise NotImplementedError(cp.type()) */ __pyx_t_1 = __pyx_f_7feather_3ext_timestamp_to_pandas(__pyx_v_cp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":222 * elif cp.type() == ColumnType_CATEGORY: * values = category_to_pandas(cp) * elif cp.type() == ColumnType_TIMESTAMP: # <<<<<<<<<<<<<< * values = timestamp_to_pandas(cp) * else: */ goto __pyx_L3; } /* "feather/ext.pyx":225 * values = timestamp_to_pandas(cp) * else: * raise NotImplementedError(cp.type()) # <<<<<<<<<<<<<< * * return values */ /*else*/ { __pyx_t_1 = __Pyx_PyInt_From_enum____feather_3a__3a_ColumnType_3a__3a_type(__pyx_v_cp->type()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 225, __pyx_L1_error) } __pyx_L3:; /* "feather/ext.pyx":227 * raise NotImplementedError(cp.type()) * * return values # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_values); __pyx_r = __pyx_v_values; goto __pyx_L0; /* "feather/ext.pyx":208 * return col.get().values().null_count * * def read(self): # <<<<<<<<<<<<<< * cdef: * unique_ptr[CColumn] col */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("feather.ext.Column.read", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_values); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":234 * unique_ptr[TableReader] reader * * def __cinit__(self, object name): # <<<<<<<<<<<<<< * cdef: * string c_name = encode_file_path(name) */ /* Python wrapper */ static int __pyx_pw_7feather_3ext_13FeatherReader_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7feather_3ext_13FeatherReader_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 234, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_name = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 234, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("feather.ext.FeatherReader.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7feather_3ext_13FeatherReader___cinit__(((struct __pyx_obj_7feather_3ext_FeatherReader *)__pyx_v_self), __pyx_v_name); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7feather_3ext_13FeatherReader___cinit__(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self, PyObject *__pyx_v_name) { std::string __pyx_v_c_name; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; std::string __pyx_t_5; __Pyx_RefNannySetupContext("__cinit__", 0); /* "feather/ext.pyx":236 * def __cinit__(self, object name): * cdef: * string c_name = encode_file_path(name) # <<<<<<<<<<<<<< * * check_status(TableReader.OpenFile(c_name, &self.reader)) */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_encode_file_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_c_name = __pyx_t_5; /* "feather/ext.pyx":238 * string c_name = encode_file_path(name) * * check_status(TableReader.OpenFile(c_name, &self.reader)) # <<<<<<<<<<<<<< * * property num_rows: */ __pyx_t_1 = __pyx_f_7feather_3ext_check_status(feather::TableReader::OpenFile(__pyx_v_c_name, (&__pyx_v_self->reader))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":234 * unique_ptr[TableReader] reader * * def __cinit__(self, object name): # <<<<<<<<<<<<<< * cdef: * string c_name = encode_file_path(name) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("feather.ext.FeatherReader.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":242 * property num_rows: * * def __get__(self): # <<<<<<<<<<<<<< * return self.reader.get().num_rows() * */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_13FeatherReader_8num_rows_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7feather_3ext_13FeatherReader_8num_rows_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_13FeatherReader_8num_rows___get__(((struct __pyx_obj_7feather_3ext_FeatherReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_13FeatherReader_8num_rows___get__(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "feather/ext.pyx":243 * * def __get__(self): * return self.reader.get().num_rows() # <<<<<<<<<<<<<< * * property num_columns: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->reader.get()->num_rows()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "feather/ext.pyx":242 * property num_rows: * * def __get__(self): # <<<<<<<<<<<<<< * return self.reader.get().num_rows() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("feather.ext.FeatherReader.num_rows.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":247 * property num_columns: * * def __get__(self): # <<<<<<<<<<<<<< * return self.reader.get().num_columns() * */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_13FeatherReader_11num_columns_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7feather_3ext_13FeatherReader_11num_columns_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_r = __pyx_pf_7feather_3ext_13FeatherReader_11num_columns___get__(((struct __pyx_obj_7feather_3ext_FeatherReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_13FeatherReader_11num_columns___get__(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); /* "feather/ext.pyx":248 * * def __get__(self): * return self.reader.get().num_columns() # <<<<<<<<<<<<<< * * def get_column(self, int i): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->reader.get()->num_columns()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "feather/ext.pyx":247 * property num_columns: * * def __get__(self): # <<<<<<<<<<<<<< * return self.reader.get().num_columns() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("feather.ext.FeatherReader.num_columns.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":250 * return self.reader.get().num_columns() * * def get_column(self, int i): # <<<<<<<<<<<<<< * if i < 0 or i >= self.num_columns: * raise IndexError(i) */ /* Python wrapper */ static PyObject *__pyx_pw_7feather_3ext_13FeatherReader_3get_column(PyObject *__pyx_v_self, PyObject *__pyx_arg_i); /*proto*/ static char __pyx_doc_7feather_3ext_13FeatherReader_2get_column[] = "FeatherReader.get_column(self, int i)"; static PyObject *__pyx_pw_7feather_3ext_13FeatherReader_3get_column(PyObject *__pyx_v_self, PyObject *__pyx_arg_i) { int __pyx_v_i; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_column (wrapper)", 0); assert(__pyx_arg_i); { __pyx_v_i = __Pyx_PyInt_As_int(__pyx_arg_i); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 250, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("feather.ext.FeatherReader.get_column", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7feather_3ext_13FeatherReader_2get_column(((struct __pyx_obj_7feather_3ext_FeatherReader *)__pyx_v_self), ((int)__pyx_v_i)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7feather_3ext_13FeatherReader_2get_column(struct __pyx_obj_7feather_3ext_FeatherReader *__pyx_v_self, int __pyx_v_i) { struct __pyx_obj_7feather_3ext_Column *__pyx_v_col = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("get_column", 0); /* "feather/ext.pyx":251 * * def get_column(self, int i): * if i < 0 or i >= self.num_columns: # <<<<<<<<<<<<<< * raise IndexError(i) * */ __pyx_t_2 = ((__pyx_v_i < 0) != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_num_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "feather/ext.pyx":252 * def get_column(self, int i): * if i < 0 or i >= self.num_columns: * raise IndexError(i) # <<<<<<<<<<<<<< * * cdef Column col = Column() */ __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 252, __pyx_L1_error) /* "feather/ext.pyx":251 * * def get_column(self, int i): * if i < 0 or i >= self.num_columns: # <<<<<<<<<<<<<< * raise IndexError(i) * */ } /* "feather/ext.pyx":254 * raise IndexError(i) * * cdef Column col = Column() # <<<<<<<<<<<<<< * col.init(self, i) * */ __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7feather_3ext_Column), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_col = ((struct __pyx_obj_7feather_3ext_Column *)__pyx_t_5); __pyx_t_5 = 0; /* "feather/ext.pyx":255 * * cdef Column col = Column() * col.init(self, i) # <<<<<<<<<<<<<< * * return col */ __pyx_t_5 = ((struct __pyx_vtabstruct_7feather_3ext_Column *)__pyx_v_col->__pyx_vtab)->init(__pyx_v_col, __pyx_v_self, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "feather/ext.pyx":257 * col.init(self, i) * * return col # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_col)); __pyx_r = ((PyObject *)__pyx_v_col); goto __pyx_L0; /* "feather/ext.pyx":250 * return self.reader.get().num_columns() * * def get_column(self, int i): # <<<<<<<<<<<<<< * if i < 0 or i >= self.num_columns: * raise IndexError(i) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("feather.ext.FeatherReader.get_column", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_col); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":260 * * * cdef category_to_pandas(CColumn* col): # <<<<<<<<<<<<<< * cdef CategoryColumn* cat = (col) * */ static PyObject *__pyx_f_7feather_3ext_category_to_pandas( feather::Column *__pyx_v_col) { feather::CategoryColumn *__pyx_v_cat; PyObject *__pyx_v_values = NULL; PyObject *__pyx_v_mask = NULL; PyObject *__pyx_v_levels = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("category_to_pandas", 0); /* "feather/ext.pyx":261 * * cdef category_to_pandas(CColumn* col): * cdef CategoryColumn* cat = (col) # <<<<<<<<<<<<<< * * values = raw_primitive_to_pandas(cat.values()) */ __pyx_v_cat = ((feather::CategoryColumn *)__pyx_v_col); /* "feather/ext.pyx":263 * cdef CategoryColumn* cat = (col) * * values = raw_primitive_to_pandas(cat.values()) # <<<<<<<<<<<<<< * mask = get_null_mask(cat.values()) * values[mask] = -1 */ __pyx_t_1 = feather::py::raw_primitive_to_pandas(__pyx_v_cat->values()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":264 * * values = raw_primitive_to_pandas(cat.values()) * mask = get_null_mask(cat.values()) # <<<<<<<<<<<<<< * values[mask] = -1 * levels = primitive_to_pandas(cat.levels()) */ __pyx_t_1 = feather::py::get_null_mask(__pyx_v_cat->values()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mask = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":265 * values = raw_primitive_to_pandas(cat.values()) * mask = get_null_mask(cat.values()) * values[mask] = -1 # <<<<<<<<<<<<<< * levels = primitive_to_pandas(cat.levels()) * */ if (unlikely(PyObject_SetItem(__pyx_v_values, __pyx_v_mask, __pyx_int_neg_1) < 0)) __PYX_ERR(0, 265, __pyx_L1_error) /* "feather/ext.pyx":266 * mask = get_null_mask(cat.values()) * values[mask] = -1 * levels = primitive_to_pandas(cat.levels()) # <<<<<<<<<<<<<< * * return pd.Categorical(values, categories=levels, */ __pyx_t_1 = feather::py::primitive_to_pandas(__pyx_v_cat->levels()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_levels = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":268 * levels = primitive_to_pandas(cat.levels()) * * return pd.Categorical(values, categories=levels, # <<<<<<<<<<<<<< * fastpath=True) * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Categorical); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_values); __Pyx_GIVEREF(__pyx_v_values); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_values); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_categories, __pyx_v_levels) < 0) __PYX_ERR(0, 268, __pyx_L1_error) /* "feather/ext.pyx":269 * * return pd.Categorical(values, categories=levels, * fastpath=True) # <<<<<<<<<<<<<< * * cdef timestamp_to_pandas(CColumn* col): */ if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_fastpath, Py_True) < 0) __PYX_ERR(0, 268, __pyx_L1_error) /* "feather/ext.pyx":268 * levels = primitive_to_pandas(cat.levels()) * * return pd.Categorical(values, categories=levels, # <<<<<<<<<<<<<< * fastpath=True) * */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* "feather/ext.pyx":260 * * * cdef category_to_pandas(CColumn* col): # <<<<<<<<<<<<<< * cdef CategoryColumn* cat = (col) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("feather.ext.category_to_pandas", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_values); __Pyx_XDECREF(__pyx_v_mask); __Pyx_XDECREF(__pyx_v_levels); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "feather/ext.pyx":271 * fastpath=True) * * cdef timestamp_to_pandas(CColumn* col): # <<<<<<<<<<<<<< * cdef TimestampColumn* ts = (col) * */ static PyObject *__pyx_f_7feather_3ext_timestamp_to_pandas( feather::Column *__pyx_v_col) { feather::TimestampColumn *__pyx_v_ts; PyObject *__pyx_v_values = NULL; PyObject *__pyx_v_mask = NULL; PyObject *__pyx_v_tz = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; __Pyx_RefNannySetupContext("timestamp_to_pandas", 0); /* "feather/ext.pyx":272 * * cdef timestamp_to_pandas(CColumn* col): * cdef TimestampColumn* ts = (col) # <<<<<<<<<<<<<< * * values = raw_primitive_to_pandas(ts.values()) */ __pyx_v_ts = ((feather::TimestampColumn *)__pyx_v_col); /* "feather/ext.pyx":274 * cdef TimestampColumn* ts = (col) * * values = raw_primitive_to_pandas(ts.values()) # <<<<<<<<<<<<<< * mask = get_null_mask(ts.values()) * */ __pyx_t_1 = feather::py::raw_primitive_to_pandas(__pyx_v_ts->values()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":275 * * values = raw_primitive_to_pandas(ts.values()) * mask = get_null_mask(ts.values()) # <<<<<<<<<<<<<< * * tz = frombytes(ts.timezone()) */ __pyx_t_1 = feather::py::get_null_mask(__pyx_v_ts->values()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mask = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":277 * mask = get_null_mask(ts.values()) * * tz = frombytes(ts.timezone()) # <<<<<<<<<<<<<< * if tz: * values = (pd.DatetimeIndex(values).tz_localize('utc') */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_frombytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_ts->timezone()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_tz = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":278 * * tz = frombytes(ts.timezone()) * if tz: # <<<<<<<<<<<<<< * values = (pd.DatetimeIndex(values).tz_localize('utc') * .tz_convert(tz)) */ __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_tz); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 278, __pyx_L1_error) if (__pyx_t_6) { /* "feather/ext.pyx":279 * tz = frombytes(ts.timezone()) * if tz: * values = (pd.DatetimeIndex(values).tz_localize('utc') # <<<<<<<<<<<<<< * .tz_convert(tz)) * result = pd.Series(values) */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_DatetimeIndex); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_5) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_v_values); __Pyx_GIVEREF(__pyx_v_values); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_values); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tz_localize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "feather/ext.pyx":280 * if tz: * values = (pd.DatetimeIndex(values).tz_localize('utc') * .tz_convert(tz)) # <<<<<<<<<<<<<< * result = pd.Series(values) * else: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tz_convert); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_tz); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(__pyx_v_tz); __Pyx_GIVEREF(__pyx_v_tz); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_tz); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_values, __pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":281 * values = (pd.DatetimeIndex(values).tz_localize('utc') * .tz_convert(tz)) * result = pd.Series(values) # <<<<<<<<<<<<<< * else: * result = pd.Series(values, dtype='M8[ns]') */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_values); __Pyx_GIVEREF(__pyx_v_values); PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_values); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_result = __pyx_t_1; __pyx_t_1 = 0; /* "feather/ext.pyx":278 * * tz = frombytes(ts.timezone()) * if tz: # <<<<<<<<<<<<<< * values = (pd.DatetimeIndex(values).tz_localize('utc') * .tz_convert(tz)) */ goto __pyx_L3; } /* "feather/ext.pyx":283 * result = pd.Series(values) * else: * result = pd.Series(values, dtype='M8[ns]') # <<<<<<<<<<<<<< * result.iloc[mask] = pd.NaT * */ /*else*/ { __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_values); __Pyx_GIVEREF(__pyx_v_values); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_values); __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_kp_s_M8_ns) < 0) __PYX_ERR(0, 283, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_result = __pyx_t_3; __pyx_t_3 = 0; } __pyx_L3:; /* "feather/ext.pyx":284 * else: * result = pd.Series(values, dtype='M8[ns]') * result.iloc[mask] = pd.NaT # <<<<<<<<<<<<<< * * return result */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_NaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_iloc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_v_mask, __pyx_t_2) < 0)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "feather/ext.pyx":286 * result.iloc[mask] = pd.NaT * * return result # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; /* "feather/ext.pyx":271 * fastpath=True) * * cdef timestamp_to_pandas(CColumn* col): # <<<<<<<<<<<<<< * cdef TimestampColumn* ts = (col) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("feather.ext.timestamp_to_pandas", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_values); __Pyx_XDECREF(__pyx_v_mask); __Pyx_XDECREF(__pyx_v_tz); __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* Python wrapper */ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_copy_shape; int __pyx_v_i; int __pyx_v_ndim; int __pyx_v_endian_detector; int __pyx_v_little_endian; int __pyx_v_t; char *__pyx_v_f; PyArray_Descr *__pyx_v_descr = 0; int __pyx_v_offset; int __pyx_v_hasfields; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; char *__pyx_t_7; __Pyx_RefNannySetupContext("__getbuffer__", 0); if (__pyx_v_info != NULL) { __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< * * cdef int copy_shape, i, ndim */ __pyx_t_1 = ((__pyx_v_info == NULL) != 0); if (__pyx_t_1) { __pyx_r = 0; goto __pyx_L0; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * */ __pyx_v_endian_detector = 1; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * * ndim = PyArray_NDIM(self) */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< * * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< * else: * copy_shape = 0 */ __pyx_v_copy_shape = 1; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * copy_shape = 1 * else: */ goto __pyx_L4; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) */ /*else*/ { __pyx_v_copy_shape = 0; } __pyx_L4:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not C contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 218, __pyx_L1_error) /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< * raise ValueError(u"ndarray is not Fortran contiguous") * */ __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 222, __pyx_L1_error) /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< * info.ndim = ndim * if copy_shape: */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< * if copy_shape: * # Allocate new buffer for strides and shape info. */ __pyx_v_info->ndim = __pyx_v_ndim; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< * info.shape = info.strides + ndim * for i in range(ndim): */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] */ __pyx_t_4 = __pyx_v_ndim; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< * info.shape[i] = PyArray_DIMS(self)[i] * else: */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< * else: * info.strides = PyArray_STRIDES(self) */ (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. */ goto __pyx_L11; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL */ /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) */ __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); } __pyx_L11:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) */ __pyx_v_info->suboffsets = NULL; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< * info.readonly = not PyArray_ISWRITEABLE(self) * */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< * * cdef int t */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< * cdef dtype descr = self.descr * cdef int offset */ __pyx_v_f = NULL; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< * cdef int offset * */ __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); __Pyx_INCREF(__pyx_t_3); __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< * * if not hasfields and not copy_shape: */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< * else: * # need to call releasebuffer */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< * # do not call releasebuffer * info.obj = None */ goto __pyx_L14; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< * * if not hasfields: */ /*else*/ { __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); } __pyx_L14:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): */ __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { } __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 259, __pyx_L1_error) /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" */ switch (__pyx_v_t) { case NPY_BYTE: __pyx_v_f = ((char *)"b"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" */ case NPY_UBYTE: __pyx_v_f = ((char *)"B"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" */ case NPY_SHORT: __pyx_v_f = ((char *)"h"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" */ case NPY_USHORT: __pyx_v_f = ((char *)"H"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" */ case NPY_INT: __pyx_v_f = ((char *)"i"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" */ case NPY_UINT: __pyx_v_f = ((char *)"I"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" */ case NPY_LONG: __pyx_v_f = ((char *)"l"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" */ case NPY_ULONG: __pyx_v_f = ((char *)"L"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" */ case NPY_LONGLONG: __pyx_v_f = ((char *)"q"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" */ case NPY_ULONGLONG: __pyx_v_f = ((char *)"Q"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" */ case NPY_FLOAT: __pyx_v_f = ((char *)"f"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" */ case NPY_DOUBLE: __pyx_v_f = ((char *)"d"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" */ case NPY_LONGDOUBLE: __pyx_v_f = ((char *)"g"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" */ case NPY_CFLOAT: __pyx_v_f = ((char *)"Zf"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" */ case NPY_CDOUBLE: __pyx_v_f = ((char *)"Zd"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f = "O" * else: */ case NPY_CLONGDOUBLE: __pyx_v_f = ((char *)"Zg"); break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ case NPY_OBJECT: __pyx_v_f = ((char *)"O"); break; default: /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(1, 278, __pyx_L1_error) break; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< * return * else: */ __pyx_v_info->format = __pyx_v_f; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< * else: * info.format = stdlib.malloc(_buffer_format_string_len) */ __pyx_r = 0; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 */ /*else*/ { __pyx_v_info->format = ((char *)malloc(0xFF)); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< * offset = 0 * f = _util_dtypestring(descr, info.format + 1, */ (__pyx_v_info->format[0]) = '^'; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< * f = _util_dtypestring(descr, info.format + 1, * info.format + _buffer_format_string_len, */ __pyx_v_offset = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error) __pyx_v_f = __pyx_t_7; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< * * def __releasebuffer__(ndarray self, Py_buffer* info): */ (__pyx_v_f[0]) = '\x00'; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< * # This implementation of getbuffer is geared towards Cython * # requirements, and does not yet fullfill the PEP. */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { __Pyx_GOTREF(__pyx_v_info->obj); __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; } goto __pyx_L2; __pyx_L0:; if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { __Pyx_GOTREF(Py_None); __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; } __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_descr); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* Python wrapper */ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) */ free(__pyx_v_info->format); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< * # info.shape was stored after info.strides in the same block * */ free(__pyx_v_info->strides); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< * stdlib.free(info.strides) * # info.shape was stored after info.strides in the same block */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< * if PyArray_HASFIELDS(self): * stdlib.free(info.format) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(1, a) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(2, a, b) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(3, a, b, c) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(4, a, b, c, d) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< * return PyArray_MultiIterNew(5, a, b, c, d, e) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { PyArray_Descr *__pyx_v_child = 0; int __pyx_v_endian_detector; int __pyx_v_little_endian; PyObject *__pyx_v_fields = 0; PyObject *__pyx_v_childname = NULL; PyObject *__pyx_v_new_offset = NULL; PyObject *__pyx_v_t = NULL; char *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; long __pyx_t_8; char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< * cdef bint little_endian = ((&endian_detector)[0] != 0) * cdef tuple fields */ __pyx_v_endian_detector = 1; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< * cdef tuple fields * */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(1, 794, __pyx_L1_error) } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ if (unlikely(__pyx_v_descr->fields == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 795, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< * * if (end - f) - (new_offset - offset[0]) < 15: */ if (likely(__pyx_v_fields != Py_None)) { PyObject* sequence = __pyx_v_fields; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(1, 796, __pyx_L1_error) } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error) } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 799, __pyx_L1_error) /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { } __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< * raise ValueError(u"Non-native byte order not supported") * # One could encode it in the format string and have Cython */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ if (__pyx_t_6) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 803, __pyx_L1_error) /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< * f[0] = 120 # "x"; pad byte * f += 1 */ while (1) { __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ (__pyx_v_f[0]) = 0x78; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< * offset[0] += 1 * */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< * * offset[0] += child.itemsize */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< * * if not PyDataType_HASFIELDS(child): */ __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 823, __pyx_L1_error) /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short.") * */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; goto __pyx_L15; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ /*else*/ { __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 844, __pyx_L1_error) } __pyx_L15:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< * else: * # Cython ignores struct boundary information ("T{...}"), */ __pyx_v_f = (__pyx_v_f + 1); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< * t = child.type_num * if end - f < 5: */ goto __pyx_L13; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ /*else*/ { __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error) __pyx_v_f = __pyx_t_9; } __pyx_L13:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< * fields = descr.fields[childname] * child, new_offset = fields */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_f; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< * # Recursive utility function used in __getbuffer__ to get format * # string. The new location in the format string is returned. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_child); __Pyx_XDECREF(__pyx_v_fields); __Pyx_XDECREF(__pyx_v_childname); __Pyx_XDECREF(__pyx_v_new_offset); __Pyx_XDECREF(__pyx_v_t); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { PyObject *__pyx_v_baseptr; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ __pyx_t_1 = (__pyx_v_base == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< * else: * Py_INCREF(base) # important to do this before decref below! */ __pyx_v_baseptr = NULL; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< * baseptr = NULL * else: */ goto __pyx_L3; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< * baseptr = base * Py_XDECREF(arr.base) */ /*else*/ { Py_INCREF(__pyx_v_base); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< * Py_XDECREF(arr.base) * arr.base = baseptr */ __pyx_v_baseptr = ((PyObject *)__pyx_v_base); } __pyx_L3:; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< * arr.base = baseptr * */ Py_XDECREF(__pyx_v_arr->base); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< * * cdef inline object get_array_base(ndarray arr): */ __pyx_v_arr->base = __pyx_v_baseptr; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< * cdef PyObject* baseptr * if base is None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< * else: * return arr.base */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< * return None * else: */ } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); __pyx_r = ((PyObject *)__pyx_v_arr->base); goto __pyx_L0; } /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< * if arr.base is NULL: * return None */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":31 * * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0); /* "string.to_py":32 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyUnicode_FromStringAndSize(char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":31 * * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":37 * * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0); /* "string.to_py":38 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyStr_FromStringAndSize(char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":37 * * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":43 * * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0); /* "string.to_py":44 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyBytes_FromStringAndSize(char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":43 * * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":49 * * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0); /* "string.to_py":50 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyByteArray_FromStringAndSize(char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":49 * * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":55 * * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) * */ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0); /* "string.to_py":56 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":55 * * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.from_py":13 * * @cname("__pyx_convert_string_from_py_std__in_string") * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< * cdef Py_ssize_t length * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) */ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) { Py_ssize_t __pyx_v_length; char *__pyx_v_data; std::string __pyx_r; __Pyx_RefNannyDeclarations char *__pyx_t_1; __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0); /* "string.from_py":15 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: * cdef Py_ssize_t length * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) # <<<<<<<<<<<<<< * return string(data, length) * */ __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(2, 15, __pyx_L1_error) __pyx_v_data = __pyx_t_1; /* "string.from_py":16 * cdef Py_ssize_t length * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) * return string(data, length) # <<<<<<<<<<<<<< * * */ __pyx_r = std::string(__pyx_v_data, __pyx_v_length); goto __pyx_L0; /* "string.from_py":13 * * @cname("__pyx_convert_string_from_py_std__in_string") * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< * cdef Py_ssize_t length * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_vtabstruct_7feather_3ext_FeatherWriter __pyx_vtable_7feather_3ext_FeatherWriter; static PyObject *__pyx_tp_new_7feather_3ext_FeatherWriter(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_7feather_3ext_FeatherWriter *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_7feather_3ext_FeatherWriter *)o); p->__pyx_vtab = __pyx_vtabptr_7feather_3ext_FeatherWriter; new((void*)&(p->writer)) std::unique_ptr (); if (unlikely(__pyx_pw_7feather_3ext_13FeatherWriter_1__cinit__(o, a, k) < 0)) { Py_DECREF(o); o = 0; } return o; } static void __pyx_tp_dealloc_7feather_3ext_FeatherWriter(PyObject *o) { struct __pyx_obj_7feather_3ext_FeatherWriter *p = (struct __pyx_obj_7feather_3ext_FeatherWriter *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif __Pyx_call_destructor(p->writer); (*Py_TYPE(o)->tp_free)(o); } static PyMethodDef __pyx_methods_7feather_3ext_FeatherWriter[] = { {"close", (PyCFunction)__pyx_pw_7feather_3ext_13FeatherWriter_3close, METH_NOARGS, __pyx_doc_7feather_3ext_13FeatherWriter_2close}, {"write_array", (PyCFunction)__pyx_pw_7feather_3ext_13FeatherWriter_5write_array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7feather_3ext_13FeatherWriter_4write_array}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_7feather_3ext_FeatherWriter = { PyVarObject_HEAD_INIT(0, 0) "feather.ext.FeatherWriter", /*tp_name*/ sizeof(struct __pyx_obj_7feather_3ext_FeatherWriter), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_7feather_3ext_FeatherWriter, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_7feather_3ext_FeatherWriter, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_7feather_3ext_FeatherWriter, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_7feather_3ext_Column __pyx_vtable_7feather_3ext_Column; static PyObject *__pyx_tp_new_7feather_3ext_Column(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_7feather_3ext_Column *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_7feather_3ext_Column *)o); p->__pyx_vtab = __pyx_vtabptr_7feather_3ext_Column; new((void*)&(p->metadata)) std::shared_ptr< feather::metadata::Column> (); p->parent = ((struct __pyx_obj_7feather_3ext_FeatherReader *)Py_None); Py_INCREF(Py_None); if (unlikely(__pyx_pw_7feather_3ext_6Column_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) { Py_DECREF(o); o = 0; } return o; } static void __pyx_tp_dealloc_7feather_3ext_Column(PyObject *o) { struct __pyx_obj_7feather_3ext_Column *p = (struct __pyx_obj_7feather_3ext_Column *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); __Pyx_call_destructor(p->metadata); Py_CLEAR(p->parent); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_7feather_3ext_Column(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_7feather_3ext_Column *p = (struct __pyx_obj_7feather_3ext_Column *)o; if (p->parent) { e = (*v)(((PyObject*)p->parent), a); if (e) return e; } return 0; } static int __pyx_tp_clear_7feather_3ext_Column(PyObject *o) { PyObject* tmp; struct __pyx_obj_7feather_3ext_Column *p = (struct __pyx_obj_7feather_3ext_Column *)o; tmp = ((PyObject*)p->parent); p->parent = ((struct __pyx_obj_7feather_3ext_FeatherReader *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyObject *__pyx_getprop_7feather_3ext_6Column_name(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_7feather_3ext_6Column_4name_1__get__(o); } static PyObject *__pyx_getprop_7feather_3ext_6Column_type(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_7feather_3ext_6Column_4type_1__get__(o); } static PyObject *__pyx_getprop_7feather_3ext_6Column_user_metadata(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_7feather_3ext_6Column_13user_metadata_1__get__(o); } static PyObject *__pyx_getprop_7feather_3ext_6Column_null_count(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_7feather_3ext_6Column_10null_count_1__get__(o); } static PyMethodDef __pyx_methods_7feather_3ext_Column[] = { {"read", (PyCFunction)__pyx_pw_7feather_3ext_6Column_3read, METH_NOARGS, __pyx_doc_7feather_3ext_6Column_2read}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_7feather_3ext_Column[] = { {(char *)"name", __pyx_getprop_7feather_3ext_6Column_name, 0, (char *)0, 0}, {(char *)"type", __pyx_getprop_7feather_3ext_6Column_type, 0, (char *)0, 0}, {(char *)"user_metadata", __pyx_getprop_7feather_3ext_6Column_user_metadata, 0, (char *)0, 0}, {(char *)"null_count", __pyx_getprop_7feather_3ext_6Column_null_count, 0, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_7feather_3ext_Column = { PyVarObject_HEAD_INIT(0, 0) "feather.ext.Column", /*tp_name*/ sizeof(struct __pyx_obj_7feather_3ext_Column), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_7feather_3ext_Column, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_7feather_3ext_Column, /*tp_traverse*/ __pyx_tp_clear_7feather_3ext_Column, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_7feather_3ext_Column, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_7feather_3ext_Column, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_7feather_3ext_Column, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_7feather_3ext_FeatherReader(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_7feather_3ext_FeatherReader *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_7feather_3ext_FeatherReader *)o); new((void*)&(p->reader)) std::unique_ptr (); if (unlikely(__pyx_pw_7feather_3ext_13FeatherReader_1__cinit__(o, a, k) < 0)) { Py_DECREF(o); o = 0; } return o; } static void __pyx_tp_dealloc_7feather_3ext_FeatherReader(PyObject *o) { struct __pyx_obj_7feather_3ext_FeatherReader *p = (struct __pyx_obj_7feather_3ext_FeatherReader *)o; #if PY_VERSION_HEX >= 0x030400a1 if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif __Pyx_call_destructor(p->reader); (*Py_TYPE(o)->tp_free)(o); } static PyObject *__pyx_getprop_7feather_3ext_13FeatherReader_num_rows(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_7feather_3ext_13FeatherReader_8num_rows_1__get__(o); } static PyObject *__pyx_getprop_7feather_3ext_13FeatherReader_num_columns(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_7feather_3ext_13FeatherReader_11num_columns_1__get__(o); } static PyMethodDef __pyx_methods_7feather_3ext_FeatherReader[] = { {"get_column", (PyCFunction)__pyx_pw_7feather_3ext_13FeatherReader_3get_column, METH_O, __pyx_doc_7feather_3ext_13FeatherReader_2get_column}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_7feather_3ext_FeatherReader[] = { {(char *)"num_rows", __pyx_getprop_7feather_3ext_13FeatherReader_num_rows, 0, (char *)0, 0}, {(char *)"num_columns", __pyx_getprop_7feather_3ext_13FeatherReader_num_columns, 0, (char *)0, 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_type_7feather_3ext_FeatherReader = { PyVarObject_HEAD_INIT(0, 0) "feather.ext.FeatherReader", /*tp_name*/ sizeof(struct __pyx_obj_7feather_3ext_FeatherReader), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_7feather_3ext_FeatherReader, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_7feather_3ext_FeatherReader, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_7feather_3ext_FeatherReader, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_7feather_3ext_FeatherReader, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif "ext", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_Categorical, __pyx_k_Categorical, sizeof(__pyx_k_Categorical), 0, 0, 1, 1}, {&__pyx_n_s_DatetimeIndex, __pyx_k_DatetimeIndex, sizeof(__pyx_k_DatetimeIndex), 0, 0, 1, 1}, {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1}, {&__pyx_n_s_FeatherError, __pyx_k_FeatherError, sizeof(__pyx_k_FeatherError), 0, 0, 1, 1}, {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, {&__pyx_kp_s_M8_ns, __pyx_k_M8_ns, sizeof(__pyx_k_M8_ns), 0, 0, 1, 0}, {&__pyx_n_s_NaT, __pyx_k_NaT, sizeof(__pyx_k_NaT), 0, 0, 1, 1}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_Series, __pyx_k_Series, sizeof(__pyx_k_Series), 0, 0, 1, 1}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_kp_b__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 0, 0}, {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1}, {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1}, {&__pyx_n_s_categories, __pyx_k_categories, sizeof(__pyx_k_categories), 0, 0, 1, 1}, {&__pyx_n_s_codes, __pyx_k_codes, sizeof(__pyx_k_codes), 0, 0, 1, 1}, {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_encode_file_path, __pyx_k_encode_file_path, sizeof(__pyx_k_encode_file_path), 0, 0, 1, 1}, {&__pyx_n_s_fastpath, __pyx_k_fastpath, sizeof(__pyx_k_fastpath), 0, 0, 1, 1}, {&__pyx_n_s_feather_compat, __pyx_k_feather_compat, sizeof(__pyx_k_feather_compat), 0, 0, 1, 1}, {&__pyx_n_s_feather_ext, __pyx_k_feather_ext, sizeof(__pyx_k_feather_ext), 0, 0, 1, 1}, {&__pyx_n_s_frombytes, __pyx_k_frombytes, sizeof(__pyx_k_frombytes), 0, 0, 1, 1}, {&__pyx_n_s_i8, __pyx_k_i8, sizeof(__pyx_k_i8), 0, 0, 1, 1}, {&__pyx_n_s_iloc, __pyx_k_iloc, sizeof(__pyx_k_iloc), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_is_categorical_dtype, __pyx_k_is_categorical_dtype, sizeof(__pyx_k_is_categorical_dtype), 0, 0, 1, 1}, {&__pyx_n_s_is_datetime64_any_dtype, __pyx_k_is_datetime64_any_dtype, sizeof(__pyx_k_is_datetime64_any_dtype), 0, 0, 1, 1}, {&__pyx_n_s_isnull, __pyx_k_isnull, sizeof(__pyx_k_isnull), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_num_columns, __pyx_k_num_columns, sizeof(__pyx_k_num_columns), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_ordered, __pyx_k_ordered, sizeof(__pyx_k_ordered), 0, 0, 1, 1}, {&__pyx_n_s_pandas, __pyx_k_pandas, sizeof(__pyx_k_pandas), 0, 0, 1, 1}, {&__pyx_n_s_pd, __pyx_k_pd, sizeof(__pyx_k_pd), 0, 0, 1, 1}, {&__pyx_n_s_pdapi, __pyx_k_pdapi, sizeof(__pyx_k_pdapi), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, {&__pyx_kp_s_prior_column_had_a_different_num, __pyx_k_prior_column_had_a_different_num, sizeof(__pyx_k_prior_column_had_a_different_num), 0, 0, 1, 0}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_tobytes, __pyx_k_tobytes, sizeof(__pyx_k_tobytes), 0, 0, 1, 1}, {&__pyx_n_s_tz, __pyx_k_tz, sizeof(__pyx_k_tz), 0, 0, 1, 1}, {&__pyx_n_s_tz_convert, __pyx_k_tz_convert, sizeof(__pyx_k_tz_convert), 0, 0, 1, 1}, {&__pyx_n_s_tz_localize, __pyx_k_tz_localize, sizeof(__pyx_k_tz_localize), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_utc, __pyx_k_utc, sizeof(__pyx_k_utc), 0, 0, 1, 1}, {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1}, {&__pyx_n_s_view, __pyx_k_view, sizeof(__pyx_k_view), 0, 0, 1, 1}, {&__pyx_n_s_zone, __pyx_k_zone, sizeof(__pyx_k_zone), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) __PYX_ERR(0, 38, __pyx_L1_error) __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 90, __pyx_L1_error) __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 225, __pyx_L1_error) __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 252, __pyx_L1_error) __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 231, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "feather/ext.pyx":90 * if self.num_rows >= 0: * if len(col) != self.num_rows: * raise ValueError('prior column had a different number of rows') # <<<<<<<<<<<<<< * else: * self.num_rows = len(col) */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_prior_column_had_a_different_num); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "feather/ext.pyx":134 * mask_to_file = update_mask_with_datatype_nulls(mask, col_values) * * self.write_ndarray(col_values.view('i8'), mask_to_file, &values) # <<<<<<<<<<<<<< * * metadata.unit = TimeUnit_NANOSECOND */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_n_s_i8); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "feather/ext.pyx":279 * tz = frombytes(ts.timezone()) * if tz: * values = (pd.DatetimeIndex(values).tz_localize('utc') # <<<<<<<<<<<<<< * .tz_convert(tz)) * result = pd.Series(values) */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_utc); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 803, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); /* "../../../anaconda3/lib/python3.5/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initext(void); /*proto*/ PyMODINIT_FUNC initext(void) #else PyMODINIT_FUNC PyInit_ext(void); /*proto*/ PyMODINIT_FUNC PyInit_ext(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ext(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("ext", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_feather__ext) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "feather.ext")) { if (unlikely(PyDict_SetItemString(modules, "feather.ext", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ __pyx_vtabptr_7feather_3ext_FeatherWriter = &__pyx_vtable_7feather_3ext_FeatherWriter; __pyx_vtable_7feather_3ext_FeatherWriter.write_category = (PyObject *(*)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, PyObject *))__pyx_f_7feather_3ext_13FeatherWriter_write_category; __pyx_vtable_7feather_3ext_FeatherWriter.write_primitive = (PyObject *(*)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, PyObject *))__pyx_f_7feather_3ext_13FeatherWriter_write_primitive; __pyx_vtable_7feather_3ext_FeatherWriter.write_timestamp = (PyObject *(*)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, PyObject *))__pyx_f_7feather_3ext_13FeatherWriter_write_timestamp; __pyx_vtable_7feather_3ext_FeatherWriter.write_ndarray = (int (*)(struct __pyx_obj_7feather_3ext_FeatherWriter *, PyObject *, PyObject *, feather::PrimitiveArray *))__pyx_f_7feather_3ext_13FeatherWriter_write_ndarray; if (PyType_Ready(&__pyx_type_7feather_3ext_FeatherWriter) < 0) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_type_7feather_3ext_FeatherWriter.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_7feather_3ext_FeatherWriter.tp_dict, __pyx_vtabptr_7feather_3ext_FeatherWriter) < 0) __PYX_ERR(0, 69, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "FeatherWriter", (PyObject *)&__pyx_type_7feather_3ext_FeatherWriter) < 0) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_ptype_7feather_3ext_FeatherWriter = &__pyx_type_7feather_3ext_FeatherWriter; __pyx_vtabptr_7feather_3ext_Column = &__pyx_vtable_7feather_3ext_Column; __pyx_vtable_7feather_3ext_Column.init = (PyObject *(*)(struct __pyx_obj_7feather_3ext_Column *, struct __pyx_obj_7feather_3ext_FeatherReader *, int))__pyx_f_7feather_3ext_6Column_init; if (PyType_Ready(&__pyx_type_7feather_3ext_Column) < 0) __PYX_ERR(0, 163, __pyx_L1_error) __pyx_type_7feather_3ext_Column.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_7feather_3ext_Column.tp_dict, __pyx_vtabptr_7feather_3ext_Column) < 0) __PYX_ERR(0, 163, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "Column", (PyObject *)&__pyx_type_7feather_3ext_Column) < 0) __PYX_ERR(0, 163, __pyx_L1_error) __pyx_ptype_7feather_3ext_Column = &__pyx_type_7feather_3ext_Column; if (PyType_Ready(&__pyx_type_7feather_3ext_FeatherReader) < 0) __PYX_ERR(0, 230, __pyx_L1_error) __pyx_type_7feather_3ext_FeatherReader.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "FeatherReader", (PyObject *)&__pyx_type_7feather_3ext_FeatherReader) < 0) __PYX_ERR(0, 230, __pyx_L1_error) __pyx_ptype_7feather_3ext_FeatherReader = &__pyx_type_7feather_3ext_FeatherReader; /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error) __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(4, 8, __pyx_L1_error) __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(5, 15, __pyx_L1_error) __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error) __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error) __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error) __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error) __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "feather/ext.pyx":26 * from libfeather cimport * * * import pandas as pd # <<<<<<<<<<<<<< * from feather.compat import pdapi * */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_pandas, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_1) < 0) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":27 * * import pandas as pd * from feather.compat import pdapi # <<<<<<<<<<<<<< * * from numpy cimport ndarray */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_pdapi); __Pyx_GIVEREF(__pyx_n_s_pdapi); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pdapi); __pyx_t_2 = __Pyx_Import(__pyx_n_s_feather_compat, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pdapi); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pdapi, __pyx_t_1) < 0) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "feather/ext.pyx":31 * from numpy cimport ndarray * cimport numpy as cnp * import numpy as np # <<<<<<<<<<<<<< * * from feather.compat import frombytes, tobytes, encode_file_path */ __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "feather/ext.pyx":33 * import numpy as np * * from feather.compat import frombytes, tobytes, encode_file_path # <<<<<<<<<<<<<< * import six * */ __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_frombytes); __Pyx_GIVEREF(__pyx_n_s_frombytes); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_frombytes); __Pyx_INCREF(__pyx_n_s_tobytes); __Pyx_GIVEREF(__pyx_n_s_tobytes); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_tobytes); __Pyx_INCREF(__pyx_n_s_encode_file_path); __Pyx_GIVEREF(__pyx_n_s_encode_file_path); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_encode_file_path); __pyx_t_1 = __Pyx_Import(__pyx_n_s_feather_compat, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_frombytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_frombytes, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_tobytes, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_encode_file_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_encode_file_path, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":34 * * from feather.compat import frombytes, tobytes, encode_file_path * import six # <<<<<<<<<<<<<< * * cnp.import_array() */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":36 * import six * * cnp.import_array() # <<<<<<<<<<<<<< * * class FeatherError(Exception): */ import_array(); /* "feather/ext.pyx":38 * cnp.import_array() * * class FeatherError(Exception): # <<<<<<<<<<<<<< * pass * */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_builtin_Exception); __Pyx_GIVEREF(__pyx_builtin_Exception); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception); __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_FeatherError, __pyx_n_s_FeatherError, (PyObject *) NULL, __pyx_n_s_feather_ext, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_FeatherError, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_FeatherError, __pyx_t_4) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "feather/ext.pyx":67 * return mask | datatype_nulls * * set_numpy_nan(np.nan) # <<<<<<<<<<<<<< * * cdef class FeatherWriter: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_nan); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; feather::py::set_numpy_nan(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "feather/ext.pyx":1 * # Copyright 2016 Feather Developers # <<<<<<<<<<<<<< * # * # Licensed under the Apache License, Version 2.0 (the "License"); */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "string.from_py":13 * * @cname("__pyx_convert_string_from_py_std__in_string") * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< * cdef Py_ssize_t length * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init feather.ext", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init feather.ext"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* GetModuleGlobalName */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallOneArg */ #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif /* PyErrFetchRestore */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; } #endif /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } #if PY_VERSION_HEX >= 0x03030000 if (cause) { #else if (cause && cause != Py_None) { #endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* PyObjectCallNoArg */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* GetAttr */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } /* GetAttr3 */ static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { PyObject *r = __Pyx_GetAttr(o, n); if (unlikely(!r)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); r = d; Py_INCREF(d); } return r; bad: return NULL; } /* KeywordStringCheck */ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; #if CYTHON_COMPILING_IN_PYPY if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) goto invalid_keyword; return 1; #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; } /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* RaiseNoneIterError */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } /* ExtTypeTest */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } /* SetVTable */ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); #endif if (!ob) goto bad; if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* CalculateMetaclass */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); for (i=0; i < nbases; i++) { PyTypeObject *tmptype; PyObject *tmp = PyTuple_GET_ITEM(bases, i); tmptype = Py_TYPE(tmp); #if PY_MAJOR_VERSION < 3 if (tmptype == &PyClass_Type) continue; #endif if (!metaclass) { metaclass = tmptype; continue; } if (PyType_IsSubtype(metaclass, tmptype)) continue; if (PyType_IsSubtype(tmptype, metaclass)) { metaclass = tmptype; continue; } PyErr_SetString(PyExc_TypeError, "metaclass conflict: " "the metaclass of a derived class " "must be a (non-strict) subclass " "of the metaclasses of all its bases"); return NULL; } if (!metaclass) { #if PY_MAJOR_VERSION < 3 metaclass = &PyClass_Type; #else metaclass = &PyType_Type; #endif } Py_INCREF((PyObject*) metaclass); return (PyObject*) metaclass; } /* Py3ClassCreate */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); if (prep) { PyObject *pargs = PyTuple_Pack(2, name, bases); if (unlikely(!pargs)) { Py_DECREF(prep); return NULL; } ns = PyObject_Call(prep, pargs, mkw); Py_DECREF(prep); Py_DECREF(pargs); } else { if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; PyErr_Clear(); ns = PyDict_New(); } } else { ns = PyDict_New(); } if (unlikely(!ns)) return NULL; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; return ns; bad: Py_DECREF(ns); return NULL; } static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass) { PyObject *result, *margs; PyObject *owned_metaclass = NULL; if (allow_py2_metaclass) { owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); if (owned_metaclass) { metaclass = owned_metaclass; } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { PyErr_Clear(); } else { return NULL; } } if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); Py_XDECREF(owned_metaclass); if (unlikely(!metaclass)) return NULL; owned_metaclass = metaclass; } margs = PyTuple_Pack(3, name, bases, dict); if (unlikely(!margs)) { result = NULL; } else { result = PyObject_Call(metaclass, margs, mkw); Py_DECREF(margs); } Py_XDECREF(owned_metaclass); return result; } /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_code = __pyx_find_code_object(c_line ? c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? c_line : py_line, py_code); } py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____feather_3a__3a_ColumnType_3a__3a_type(enum feather::ColumnType::type value) { const enum feather::ColumnType::type neg_one = (enum feather::ColumnType::type) -1, const_zero = (enum feather::ColumnType::type) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum feather::ColumnType::type) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum feather::ColumnType::type) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(enum feather::ColumnType::type) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(enum feather::ColumnType::type) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum feather::ColumnType::type) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(enum feather::ColumnType::type), little, !is_unsigned); } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) { const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int64_t) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int64_t) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int64_t) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int64_t), little, !is_unsigned); } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } /* None */ #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return ::std::complex< float >(x, y); } #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { return x + y*(__pyx_t_float_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { __pyx_t_float_complex z; z.real = x; z.imag = y; return z; } #endif /* None */ #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { __pyx_t_float_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrtf(z.real*z.real + z.imag*z.imag); #else return hypotf(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { __pyx_t_float_complex z; float r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { float denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(a, a); case 3: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, a); case 4: z = __Pyx_c_prodf(a, a); return __Pyx_c_prodf(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_absf(a); theta = atan2f(a.imag, a.real); } lnr = logf(r); z_r = expf(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cosf(z_theta); z.imag = z_r * sinf(z_theta); return z; } #endif #endif /* None */ #if CYTHON_CCOMPLEX #ifdef __cplusplus static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return ::std::complex< double >(x, y); } #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { return x + y*(__pyx_t_double_complex)_Complex_I; } #endif #else static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { __pyx_t_double_complex z; z.real = x; z.imag = y; return z; } #endif /* None */ #if CYTHON_CCOMPLEX #else static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { return (a.real == b.real) && (a.imag == b.imag); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real + b.real; z.imag = a.imag + b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real - b.real; z.imag = a.imag - b.imag; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; z.real = a.real * b.real - a.imag * b.imag; z.imag = a.real * b.imag + a.imag * b.real; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double denom = b.real * b.real + b.imag * b.imag; z.real = (a.real * b.real + a.imag * b.imag) / denom; z.imag = (a.imag * b.real - a.real * b.imag) / denom; return z; } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = -a.real; z.imag = -a.imag; return z; } static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { return (a.real == 0) && (a.imag == 0); } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { __pyx_t_double_complex z; z.real = a.real; z.imag = -a.imag; return z; } #if 1 static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { #if !defined(HAVE_HYPOT) || defined(_MSC_VER) return sqrt(z.real*z.real + z.imag*z.imag); #else return hypot(z.real, z.imag); #endif } static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { __pyx_t_double_complex z; double r, lnr, theta, z_r, z_theta; if (b.imag == 0 && b.real == (int)b.real) { if (b.real < 0) { double denom = a.real * a.real + a.imag * a.imag; a.real = a.real / denom; a.imag = -a.imag / denom; b.real = -b.real; } switch ((int)b.real) { case 0: z.real = 1; z.imag = 0; return z; case 1: return a; case 2: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(a, a); case 3: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, a); case 4: z = __Pyx_c_prod(a, a); return __Pyx_c_prod(z, z); } } if (a.imag == 0) { if (a.real == 0) { return a; } r = a.real; theta = 0; } else { r = __Pyx_c_abs(a); theta = atan2(a.imag, a.real); } lnr = log(r); z_r = exp(lnr * b.real - theta * b.imag); z_theta = theta * b.real + lnr * b.imag; z.real = z_r * cos(z_theta); z.imag = z_r * sin(z_theta); return z; } #endif #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(enum NPY_TYPES) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(enum NPY_TYPES) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } /* ModuleImport */ #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", module_name, class_name, basicsize, size); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", module_name, class_name, basicsize, size); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #endif /* InitStrings */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { #if PY_VERSION_HEX < 0x03030000 char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ feather-format-0.3.1/feather/__init__.py0000664000175100017510000000140113004702052020107 0ustar wesmwesm00000000000000# Copyright 2016 Feather Developers # # 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. # flake8: noqa from feather.api import read_dataframe, write_dataframe from feather.ext import FeatherError, FeatherReader, FeatherWriter from feather.version import version as __version__ feather-format-0.3.1/feather/interop.h0000664000175100017510000005372513004772715017664 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. // Functions for NumPy / pandas conversion #include #include "feather/api.h" #include #include #include #include #include #include namespace feather { namespace py { // ---------------------------------------------------------------------- // Serialization template struct npy_traits { }; template <> struct npy_traits { typedef uint8_t value_type; static constexpr PrimitiveType::type feather_type = PrimitiveType::BOOL; static constexpr bool supports_nulls = false; static inline bool isnull(uint8_t v) { return false; } }; #define NPY_INT_DECL(TYPE, FTYPE, T) \ template <> \ struct npy_traits { \ typedef T value_type; \ static constexpr PrimitiveType::type feather_type = PrimitiveType::FTYPE; \ static constexpr bool supports_nulls = false; \ static inline bool isnull(T v) { \ return false; \ } \ }; NPY_INT_DECL(INT8, INT8, int8_t); NPY_INT_DECL(INT16, INT16, int16_t); NPY_INT_DECL(INT32, INT32, int32_t); NPY_INT_DECL(INT64, INT64, int64_t); NPY_INT_DECL(UINT8, UINT8, uint8_t); NPY_INT_DECL(UINT16, UINT16, uint16_t); NPY_INT_DECL(UINT32, UINT32, uint32_t); NPY_INT_DECL(UINT64, UINT64, uint64_t); #if NPY_INT64 != NPY_LONGLONG NPY_INT_DECL(LONGLONG, INT64, int64_t); NPY_INT_DECL(ULONGLONG, UINT64, uint64_t); #endif template <> struct npy_traits { typedef float value_type; static constexpr PrimitiveType::type feather_type = PrimitiveType::FLOAT; static constexpr bool supports_nulls = true; static inline bool isnull(float v) { return v != v; } }; template <> struct npy_traits { typedef double value_type; static constexpr PrimitiveType::type feather_type = PrimitiveType::DOUBLE; static constexpr bool supports_nulls = true; static inline bool isnull(double v) { return v != v; } }; template <> struct npy_traits { typedef PyObject* value_type; static constexpr bool supports_nulls = true; }; template class FeatherSerializer { public: FeatherSerializer(PyArrayObject* arr, PyArrayObject* mask, PrimitiveArray* out) : arr_(arr), mask_(mask), out_(out), null_bitmap_(nullptr) {} Status Convert(); int stride() const { return PyArray_STRIDES(arr_)[0]; } Status InitNullBitmap() { int null_bytes = util::bytes_for_bits(out_->length); auto buffer = std::make_shared(); RETURN_NOT_OK(buffer->Resize(null_bytes)); out_->buffers.push_back(buffer); util::fill_buffer(buffer->mutable_data(), 0, null_bytes); out_->nulls = buffer->data(); null_bitmap_ = buffer->mutable_data(); return Status::OK(); } bool is_strided() const { npy_intp* astrides = PyArray_STRIDES(arr_); return astrides[0] != PyArray_DESCR(arr_)->elsize; } private: Status ConvertData(); Status ConvertObjectStrings() { PyObject** objects = reinterpret_cast(PyArray_DATA(arr_)); auto offsets_buffer = std::make_shared(); RETURN_NOT_OK(offsets_buffer->Resize(sizeof(int32_t) * (out_->length + 1))); int32_t* offsets = reinterpret_cast(offsets_buffer->mutable_data()); BufferBuilder data_builder; Status s; PyObject* obj; int length; int offset = 0; int64_t null_count = 0; for (int64_t i = 0; i < out_->length; ++i) { obj = objects[i]; if (PyUnicode_Check(obj)) { obj = PyUnicode_AsUTF8String(obj); if (obj == NULL) { PyErr_Clear(); return Status::Invalid("failed converting unicode to UTF8"); } length = PyBytes_GET_SIZE(obj); s = data_builder.Append( reinterpret_cast(PyBytes_AS_STRING(obj)), length); Py_DECREF(obj); if (!s.ok()) { return s; } util::set_bit(null_bitmap_, i); } else if (PyBytes_Check(obj)) { length = PyBytes_GET_SIZE(obj); RETURN_NOT_OK(data_builder.Append( reinterpret_cast(PyBytes_AS_STRING(obj)), length)); util::set_bit(null_bitmap_, i); } else { // NULL // No change to offset length = 0; ++null_count; } offsets[i] = offset; offset += length; } // End offset offsets[out_->length] = offset; std::shared_ptr data_buffer = data_builder.Finish(); out_->type = PrimitiveType::UTF8; out_->values = data_buffer->data(); out_->buffers.push_back(data_buffer); out_->offsets = offsets; out_->buffers.push_back(offsets_buffer); out_->null_count = null_count; return Status::OK(); } Status ConvertBooleans() { out_->type = PrimitiveType::BOOL; PyObject** objects = reinterpret_cast(PyArray_DATA(arr_)); int nbytes = util::bytes_for_bits(out_->length); auto buffer = std::make_shared(); RETURN_NOT_OK(buffer->Resize(nbytes)); out_->buffers.push_back(buffer); uint8_t* bitmap = buffer->mutable_data(); util::fill_buffer(bitmap, 0, nbytes); int64_t null_count = 0; for (int64_t i = 0; i < out_->length; ++i) { if (objects[i] == Py_True) { util::set_bit(bitmap, i); util::set_bit(null_bitmap_, i); } else if (objects[i] == Py_False) { util::set_bit(null_bitmap_, i); } else { ++null_count; } } out_->type = PrimitiveType::BOOL; out_->values = bitmap; out_->null_count = null_count; return Status::OK(); } PyArrayObject* arr_; PyArrayObject* mask_; PrimitiveArray* out_; uint8_t* null_bitmap_; }; // Returns null count static int64_t MaskToBitmap(PyArrayObject* mask, int64_t length, uint8_t* bitmap) { int64_t null_count = 0; const uint8_t* mask_values = static_cast(PyArray_DATA(mask)); // TODO(wesm): strided null mask for (int i = 0; i < length; ++i) { if (mask_values[i]) { ++null_count; } else { util::set_bit(bitmap, i); } } return null_count; } template static int64_t ValuesToBitmap(const void* data, int64_t length, uint8_t* bitmap) { typedef npy_traits traits; typedef typename traits::value_type T; int64_t null_count = 0; const T* values = reinterpret_cast(data); // TODO(wesm): striding for (int i = 0; i < length; ++i) { if (traits::isnull(values[i])) { ++null_count; } else { util::set_bit(bitmap, i); } } return null_count; } template inline Status FeatherSerializer::Convert() { typedef npy_traits traits; out_->length = PyArray_SIZE(arr_); out_->type = traits::feather_type; if (mask_ != nullptr || traits::supports_nulls) { RETURN_NOT_OK(InitNullBitmap()); } int64_t null_count = 0; if (mask_ != nullptr) { null_count = MaskToBitmap(mask_, out_->length, null_bitmap_); } else if (traits::supports_nulls) { null_count = ValuesToBitmap(PyArray_DATA(arr_), out_->length, null_bitmap_); } out_->null_count = null_count; RETURN_NOT_OK(ConvertData()); return Status::OK(); } PyObject* numpy_nan = nullptr; void set_numpy_nan(PyObject* nan) { Py_INCREF(nan); numpy_nan = nan; } static inline bool PyObject_is_null(const PyObject* obj) { if (obj == Py_None || obj == numpy_nan) { return true; } if (PyFloat_Check(obj)) { double val = PyFloat_AS_DOUBLE(obj); return val != val; } return false; } static inline bool PyObject_is_string(const PyObject* obj) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_Check(obj) || PyBytes_Check(obj); #else return PyString_Check(obj) || PyUnicode_Check(obj); #endif } template <> inline Status FeatherSerializer::Convert() { // Python object arrays are annoying, since we could have one of: // // * Strings // * Booleans with nulls // * Mixed type (not supported at the moment by feather format) // // Additionally, nulls may be encoded either as np.nan or None. So we have to // do some type inference and conversion out_->length = PyArray_SIZE(arr_); RETURN_NOT_OK(InitNullBitmap()); // TODO: mask not supported here const PyObject** objects = reinterpret_cast(PyArray_DATA(arr_)); for (int64_t i = 0; i < out_->length; ++i) { if (PyObject_is_null(objects[i])) { continue; } else if (PyObject_is_string(objects[i])) { return ConvertObjectStrings(); } else if (PyBool_Check(objects[i])) { return ConvertBooleans(); } else { std::stringstream ss; ss << "unhandled python type, index " << i; return Status::Invalid(ss.str()); } } return Status::Invalid("Unable to infer type of object array, were all null"); } template inline Status FeatherSerializer::ConvertData() { if (is_strided()) { return Status::Invalid("no support for strided data yet"); } out_->values = static_cast(PyArray_DATA(arr_)); return Status::OK(); } template <> inline Status FeatherSerializer::ConvertData() { if (is_strided()) { return Status::Invalid("no support for strided data yet"); } int nbytes = util::bytes_for_bits(out_->length); auto buffer = std::make_shared(); RETURN_NOT_OK(buffer->Resize(nbytes)); out_->buffers.push_back(buffer); const uint8_t* values = reinterpret_cast(PyArray_DATA(arr_)); uint8_t* bitmap = buffer->mutable_data(); util::fill_buffer(bitmap, 0, nbytes); for (int i = 0; i < out_->length; ++i) { if (values[i] > 0) { util::set_bit(bitmap, i); } } out_->values = bitmap; return Status::OK(); } template <> inline Status FeatherSerializer::ConvertData() { return Status::Invalid("NYI"); } #define TO_FEATHER_CASE(TYPE) \ case NPY_##TYPE: \ { \ FeatherSerializer converter(arr, mask, out); \ RETURN_NOT_OK(converter.Convert()); \ } \ break; Status pandas_masked_to_primitive(PyObject* ao, PyObject* mo, PrimitiveArray* out) { PyArrayObject* arr = reinterpret_cast(ao); PyArrayObject* mask = nullptr; if (mo != nullptr) { mask = reinterpret_cast(mo); } if (arr->nd != 1) { return Status::Invalid("only handle 1-dimensional arrays"); } int type_num = PyArray_DESCR(arr)->type_num; #if (NPY_INT64 == NPY_LONGLONG) && (NPY_SIZEOF_LONGLONG == 8) // GH #129, on i386 / Apple Python, both LONGLONG and INT64 can be observed // in the wild, which is buggy. We set U/LONGLONG to U/INT64 so things work // properly. if (type_num == NPY_LONGLONG) { type_num = NPY_INT64; } if (type_num == NPY_ULONGLONG) { type_num = NPY_UINT64; } #endif switch(type_num) { TO_FEATHER_CASE(BOOL); TO_FEATHER_CASE(INT8); TO_FEATHER_CASE(INT16); TO_FEATHER_CASE(INT32); TO_FEATHER_CASE(INT64); #if (NPY_INT64 != NPY_LONGLONG) TO_FEATHER_CASE(LONGLONG); #endif TO_FEATHER_CASE(UINT8); TO_FEATHER_CASE(UINT16); TO_FEATHER_CASE(UINT32); TO_FEATHER_CASE(UINT64); #if (NPY_UINT64 != NPY_ULONGLONG) TO_FEATHER_CASE(ULONGLONG); #endif TO_FEATHER_CASE(FLOAT32); TO_FEATHER_CASE(FLOAT64); TO_FEATHER_CASE(OBJECT); default: std::stringstream ss; ss << "unsupported type " << type_num << std::endl; return Status::Invalid(ss.str()); } return Status::OK(); } Status pandas_to_primitive(PyObject* ao, PrimitiveArray* out) { return pandas_masked_to_primitive(ao, nullptr, out); } // ---------------------------------------------------------------------- // Deserialization template struct feather_traits { }; template <> struct feather_traits { static constexpr int npy_type = NPY_BOOL; static constexpr bool supports_nulls = false; static constexpr bool is_boolean = true; static constexpr bool is_integer = false; static constexpr bool is_floating = false; }; #define INT_DECL(TYPE) \ template <> \ struct feather_traits { \ static constexpr int npy_type = NPY_##TYPE; \ static constexpr bool supports_nulls = false; \ static constexpr double na_value = NAN; \ static constexpr bool is_boolean = false; \ static constexpr bool is_integer = true; \ static constexpr bool is_floating = false; \ typedef typename npy_traits::value_type T; \ }; INT_DECL(INT8); INT_DECL(INT16); INT_DECL(INT32); INT_DECL(INT64); INT_DECL(UINT8); INT_DECL(UINT16); INT_DECL(UINT32); INT_DECL(UINT64); template <> struct feather_traits { static constexpr int npy_type = NPY_FLOAT32; static constexpr bool supports_nulls = true; static constexpr float na_value = NAN; static constexpr bool is_boolean = false; static constexpr bool is_integer = false; static constexpr bool is_floating = true; typedef typename npy_traits::value_type T; }; template <> struct feather_traits { static constexpr int npy_type = NPY_FLOAT64; static constexpr bool supports_nulls = true; static constexpr double na_value = NAN; static constexpr bool is_boolean = false; static constexpr bool is_integer = false; static constexpr bool is_floating = true; typedef typename npy_traits::value_type T; }; template <> struct feather_traits { static constexpr int npy_type = NPY_OBJECT; static constexpr bool supports_nulls = true; static constexpr bool is_boolean = false; static constexpr bool is_integer = false; static constexpr bool is_floating = false; }; static inline PyObject* make_pystring(const uint8_t* data, int32_t length) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromStringAndSize(reinterpret_cast(data), length); #else return PyString_FromStringAndSize(reinterpret_cast(data), length); #endif } template class FeatherDeserializer { public: FeatherDeserializer(const PrimitiveArray* arr) : arr_(arr) {} PyObject* Convert() { ConvertValues(); return out_; } // Floating point specialization template inline typename std::enable_if::is_floating, void>::type ConvertValues() { typedef typename feather_traits::T T; npy_intp dims[1] = {static_cast(arr_->length)}; out_ = PyArray_SimpleNew(1, dims, feather_traits::npy_type); if (out_ == NULL) { // Error occurred, trust that SimpleNew set the error state return; } if (arr_->null_count > 0) { T* out_values = reinterpret_cast(PyArray_DATA(out_)); const T* in_values = reinterpret_cast(arr_->values); for (int64_t i = 0; i < arr_->length; ++i) { out_values[i] = util::bit_not_set(arr_->nulls, i) ? NAN : in_values[i]; } } else { memcpy(PyArray_DATA(out_), arr_->values, arr_->length * ByteSize(arr_->type)); } } // Integer specialization template inline typename std::enable_if::is_integer, void>::type ConvertValues() { typedef typename feather_traits::T T; npy_intp dims[1] = {static_cast(arr_->length)}; if (arr_->null_count > 0) { out_ = PyArray_SimpleNew(1, dims, NPY_FLOAT64); if (out_ == NULL) return; // Upcast to double, set NaN as appropriate double* out_values = reinterpret_cast(PyArray_DATA(out_)); const T* in_values = reinterpret_cast(arr_->values); for (int i = 0; i < arr_->length; ++i) { out_values[i] = util::bit_not_set(arr_->nulls, i) ? (double) NAN : in_values[i]; } } else { out_ = PyArray_SimpleNew(1, dims, feather_traits::npy_type); if (out_ == NULL) return; memcpy(PyArray_DATA(out_), arr_->values, arr_->length * ByteSize(arr_->type)); } } // Boolean specialization template inline typename std::enable_if::is_boolean, void>::type ConvertValues() { npy_intp dims[1] = {static_cast(arr_->length)}; if (arr_->null_count > 0) { out_ = PyArray_SimpleNew(1, dims, NPY_OBJECT); if (out_ == NULL) return; PyObject** out_values = reinterpret_cast(PyArray_DATA(out_)); for (int64_t i = 0; i < arr_->length; ++i) { if (util::bit_not_set(arr_->nulls, i)) { Py_INCREF(Py_None); out_values[i] = Py_None; } else if (util::get_bit(arr_->values, i)) { // True Py_INCREF(Py_True); out_values[i] = Py_True; } else { // False Py_INCREF(Py_False); out_values[i] = Py_False; } } } else { out_ = PyArray_SimpleNew(1, dims, feather_traits::npy_type); if (out_ == NULL) return; uint8_t* out_values = reinterpret_cast(PyArray_DATA(out_)); for (int64_t i = 0; i < arr_->length; ++i) { out_values[i] = util::get_bit(arr_->values, i) ? 1 : 0; } } } // UTF8 template inline typename std::enable_if::type ConvertValues() { npy_intp dims[1] = {static_cast(arr_->length)}; out_ = PyArray_SimpleNew(1, dims, NPY_OBJECT); if (out_ == NULL) return; PyObject** out_values = reinterpret_cast(PyArray_DATA(out_)); int32_t offset; int32_t length; if (arr_->null_count > 0) { for (int64_t i = 0; i < arr_->length; ++i) { if (util::bit_not_set(arr_->nulls, i)) { Py_INCREF(Py_None); out_values[i] = Py_None; } else { offset = arr_->offsets[i]; length = arr_->offsets[i + 1] - offset; out_values[i] = make_pystring(arr_->values + offset, length); if (out_values[i] == nullptr) return; } } } else { for (int64_t i = 0; i < arr_->length; ++i) { offset = arr_->offsets[i]; length = arr_->offsets[i + 1] - offset; out_values[i] = make_pystring(arr_->values + offset, length); if (out_values[i] == nullptr) return; } } } private: const PrimitiveArray* arr_; PyObject* out_; }; PyObject* get_null_mask(const PrimitiveArray& arr) { npy_intp dims[1] = {static_cast(arr.length)}; PyObject* out = PyArray_SimpleNew(1, dims, NPY_BOOL); if (out == NULL) return out; uint8_t* out_values = reinterpret_cast(PyArray_DATA(out)); if (arr.null_count > 0) { for (int64_t i = 0; i < arr.length; ++i) { out_values[i] = util::bit_not_set(arr.nulls, i); } } else { for (int64_t i = 0; i < arr.length; ++i) { out_values[i] = 0; } } return out; } #define FROM_RAW_FEATHER_CASE(TYPE) \ case PrimitiveType::TYPE: \ { \ npy_intp dims[1] = {static_cast(arr.length)}; \ PyObject* out = PyArray_SimpleNew(1, dims, \ feather_traits::npy_type); \ if (out == NULL) return out; \ memcpy(PyArray_DATA(out), arr.values, \ arr.length * ByteSize(arr.type)); \ return out; \ } \ break; PyObject* raw_primitive_to_pandas(const PrimitiveArray& arr) { switch(arr.type) { FROM_RAW_FEATHER_CASE(INT8); FROM_RAW_FEATHER_CASE(INT16); FROM_RAW_FEATHER_CASE(INT32); FROM_RAW_FEATHER_CASE(INT64); FROM_RAW_FEATHER_CASE(UINT8); FROM_RAW_FEATHER_CASE(UINT16); FROM_RAW_FEATHER_CASE(UINT32); FROM_RAW_FEATHER_CASE(UINT64); default: break; } PyErr_SetString(PyExc_NotImplementedError, "Feather type raw reading not implemented"); return NULL; } #define FROM_FEATHER_CASE(TYPE) \ case PrimitiveType::TYPE: \ { \ FeatherDeserializer converter(&arr); \ return converter.Convert(); \ } \ break; PyObject* primitive_to_pandas(const PrimitiveArray& arr) { switch(arr.type) { FROM_FEATHER_CASE(BOOL); FROM_FEATHER_CASE(INT8); FROM_FEATHER_CASE(INT16); FROM_FEATHER_CASE(INT32); FROM_FEATHER_CASE(INT64); FROM_FEATHER_CASE(UINT8); FROM_FEATHER_CASE(UINT16); FROM_FEATHER_CASE(UINT32); FROM_FEATHER_CASE(UINT64); FROM_FEATHER_CASE(FLOAT); FROM_FEATHER_CASE(DOUBLE); FROM_FEATHER_CASE(UTF8); // FROM_FEATHER_CASE(CATEGORY); default: break; } PyErr_SetString(PyExc_NotImplementedError, "Feather type reading not implemented"); return NULL; } } // namespace py } // namespace feather feather-format-0.3.1/feather/api.py0000664000175100017510000000545713004702052017140 0ustar wesmwesm00000000000000# Copyright 2016 Feather Developers # # 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. import six from distutils.version import LooseVersion import pandas as pd from feather.compat import pdapi import feather.ext as ext if LooseVersion(pd.__version__) < '0.17.0': raise ImportError("feather requires pandas >= 0.17.0") def write_dataframe(df, path): ''' Write a pandas.DataFrame to Feather format ''' writer = ext.FeatherWriter(path) if isinstance(df, pd.SparseDataFrame): df = df.to_dense() if not df.columns.is_unique: raise ValueError("cannot serialize duplicate column names") # TODO(wesm): pipeline conversion to Arrow memory layout for i, name in enumerate(df.columns): col = df.iloc[:, i] if pdapi.is_object_dtype(col): inferred_type = pd.lib.infer_dtype(col) msg = ("cannot serialize column {n} " "named {name} with dtype {dtype}".format( n=i, name=name, dtype=inferred_type)) if inferred_type in ['mixed']: # allow columns with nulls + an inferable type inferred_type = pd.lib.infer_dtype(col[col.notnull()]) if inferred_type in ['mixed']: raise ValueError(msg) elif inferred_type not in ['unicode', 'string']: raise ValueError(msg) if not isinstance(name, six.string_types): name = str(name) writer.write_array(name, col) writer.close() def read_dataframe(path, columns=None): """ Read a pandas.DataFrame from Feather format Parameters ---------- path : string, path to read from columns : sequence, optional Only read a specific set of columns. If not provided, all columns are read Returns ------- df : pandas.DataFrame """ reader = ext.FeatherReader(path) if columns is not None: columns = set(columns) # TODO(wesm): pipeline conversion to Arrow memory layout data = {} names = [] for i in range(reader.num_columns): col = reader.get_column(i) name = col.name if columns is None or name in columns: arr = col.read() data[name] = arr names.append(name) # TODO(wesm): return pd.DataFrame(data, columns=names) feather-format-0.3.1/feather/tests/0000775000175100017510000000000013005023556017152 5ustar wesmwesm00000000000000feather-format-0.3.1/feather/tests/__init__.py0000664000175100017510000000000012674142144021257 0ustar wesmwesm00000000000000feather-format-0.3.1/feather/tests/test_reader.py0000664000175100017510000002675013004772715022046 0ustar wesmwesm00000000000000# Copyright 2016 Feather Developers # # 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. import os import unittest from numpy.testing import assert_array_equal import numpy as np from pandas.util.testing import assert_frame_equal import pandas as pd from feather.compat import guid from feather import FeatherReader, FeatherWriter import feather def random_path(): return 'feather_{}'.format(guid()) class TestFeather(unittest.TestCase): def test_versioning(self): assert feather.__version__ is not None class TestFeatherReader(unittest.TestCase): def setUp(self): self.test_files = [] def tearDown(self): for path in self.test_files: try: os.remove(path) except os.error: pass def test_file_not_exist(self): with self.assertRaises(feather.FeatherError): FeatherReader('test_invalid_file') def _get_null_counts(self, path, columns=None): reader = FeatherReader(path) counts = [] for i in range(reader.num_columns): col = reader.get_column(i) if columns == None or col.name in columns: counts.append(col.null_count) return counts def _check_pandas_roundtrip(self, df, expected=None, path=None, columns=None, null_counts=None): if path is None: path = random_path() self.test_files.append(path) feather.write_dataframe(df, path) if not os.path.exists(path): raise Exception('file not written') result = feather.read_dataframe(path, columns) if expected is None: expected = df assert_frame_equal(result, expected) if null_counts is None: null_counts = np.zeros(len(expected.columns)) np.testing.assert_array_equal(self._get_null_counts(path, columns), null_counts) def _assert_error_on_write(self, df, exc, path=None): # check that we are raising the exception # on writing if path is None: path = random_path() self.test_files.append(path) def f(): feather.write_dataframe(df, path) self.assertRaises(exc, f) def test_num_rows_attr(self): df = pd.DataFrame({'foo': [1, 2, 3, 4, 5]}) path = random_path() self.test_files.append(path) feather.write_dataframe(df, path) reader = feather.FeatherReader(path) assert reader.num_rows == len(df) df = pd.DataFrame({}) path = random_path() self.test_files.append(path) feather.write_dataframe(df, path) reader = feather.FeatherReader(path) assert reader.num_rows == 0 def test_float_no_nulls(self): data = {} numpy_dtypes = ['f4', 'f8'] num_values = 100 for dtype in numpy_dtypes: values = np.random.randn(num_values) data[dtype] = values.astype(dtype) df = pd.DataFrame(data) self._check_pandas_roundtrip(df) def test_float_nulls(self): num_values = 100 path = random_path() self.test_files.append(path) writer = FeatherWriter(path) null_mask = np.random.randint(0, 10, size=num_values) < 3 dtypes = ['f4', 'f8'] expected_cols = [] null_counts = [] for name in dtypes: values = np.random.randn(num_values).astype(name) writer.write_array(name, values, null_mask) values[null_mask] = np.nan expected_cols.append(values) null_counts.append(null_mask.sum()) writer.close() ex_frame = pd.DataFrame(dict(zip(dtypes, expected_cols)), columns=dtypes) result = feather.read_dataframe(path) assert_frame_equal(result, ex_frame) assert_array_equal(self._get_null_counts(path), null_counts) def test_integer_no_nulls(self): data = {} numpy_dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8'] num_values = 100 for dtype in numpy_dtypes: info = np.iinfo(dtype) values = np.random.randint(0, 100, size=num_values) data[dtype] = values.astype(dtype) df = pd.DataFrame(data) self._check_pandas_roundtrip(df) def test_platform_numpy_integers(self): data = {} numpy_dtypes = ['longlong'] num_values = 100 for dtype in numpy_dtypes: values = np.random.randint(0, 100, size=num_values) data[dtype] = values.astype(dtype) df = pd.DataFrame(data) self._check_pandas_roundtrip(df) def test_integer_with_nulls(self): # pandas requires upcast to float dtype path = random_path() self.test_files.append(path) int_dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8'] num_values = 100 writer = FeatherWriter(path) null_mask = np.random.randint(0, 10, size=num_values) < 3 expected_cols = [] for name in int_dtypes: values = np.random.randint(0, 100, size=num_values) writer.write_array(name, values, null_mask) expected = values.astype('f8') expected[null_mask] = np.nan expected_cols.append(expected) ex_frame = pd.DataFrame(dict(zip(int_dtypes, expected_cols)), columns=int_dtypes) writer.close() result = feather.read_dataframe(path) assert_frame_equal(result, ex_frame) def test_boolean_no_nulls(self): num_values = 100 np.random.seed(0) df = pd.DataFrame({'bools': np.random.randn(num_values) > 0}) self._check_pandas_roundtrip(df) def test_boolean_nulls(self): # pandas requires upcast to object dtype path = random_path() self.test_files.append(path) num_values = 100 np.random.seed(0) writer = FeatherWriter(path) mask = np.random.randint(0, 10, size=num_values) < 3 values = np.random.randint(0, 10, size=num_values) < 5 writer.write_array('bools', values, mask) expected = values.astype(object) expected[mask] = None writer.close() ex_frame = pd.DataFrame({'bools': expected}) result = feather.read_dataframe(path) assert_frame_equal(result, ex_frame) def test_boolean_object_nulls(self): repeats = 100 arr = np.array([False, None, True] * repeats, dtype=object) df = pd.DataFrame({'bools': arr}) self._check_pandas_roundtrip(df, null_counts=[1 * repeats]) def test_strings(self): repeats = 1000 # we hvae mixed bytes, unicode, strings values = [b'foo', None, u'bar', 'qux', np.nan] df = pd.DataFrame({'strings': values * repeats}) self._assert_error_on_write(df, ValueError) # embedded nulls are ok values = ['foo', None, 'bar', 'qux', None] df = pd.DataFrame({'strings': values * repeats}) expected = pd.DataFrame({'strings': values * repeats}) self._check_pandas_roundtrip(df, expected, null_counts=[2 * repeats]) values = ['foo', None, 'bar', 'qux', np.nan] df = pd.DataFrame({'strings': values * repeats}) expected = pd.DataFrame({'strings': values * repeats}) self._check_pandas_roundtrip(df, expected, null_counts=[2 * repeats]) def test_empty_strings(self): df = pd.DataFrame({'strings': [''] * 10}) self._check_pandas_roundtrip(df) def test_nan_as_null(self): # Create a nan that is not numpy.nan values = np.array(['foo', np.nan, np.nan * 2, 'bar'] * 10) df = pd.DataFrame({'strings': values}) self._check_pandas_roundtrip(df) def test_category(self): repeats = 1000 values = ['foo', None, u'bar', 'qux', np.nan] df = pd.DataFrame({'strings': values * repeats}) df['strings'] = df['strings'].astype('category') values = ['foo', None, 'bar', 'qux', None] expected = pd.DataFrame({'strings': pd.Categorical(values * repeats)}) result = self._check_pandas_roundtrip(df,expected, null_counts=[2 * repeats]) def test_timestamp(self): df = pd.DataFrame({'naive': pd.date_range('2016-03-28', periods=10)}) df['with_tz'] = (df.naive.dt.tz_localize('utc') .dt.tz_convert('America/Los_Angeles')) self._check_pandas_roundtrip(df) def test_timestamp_with_nulls(self): df = pd.DataFrame({'test': [pd.datetime(2016,1,1),None,pd.datetime(2016,1,3)]}) df['with_tz'] = df.test.dt.tz_localize('utc') self._check_pandas_roundtrip(df, null_counts=[1,1]) def test_out_of_float64_timestamp_with_nulls(self): df = pd.DataFrame({'test': pd.DatetimeIndex([1451606400000000001,None,14516064000030405])}) df['with_tz'] = df.test.dt.tz_localize('utc') self._check_pandas_roundtrip(df, null_counts=[1,1]) def test_non_string_columns(self): df = pd.DataFrame({0: [1, 2, 3, 4], 1: [True, False, True, False]}) expected = df.rename(columns=str) self._check_pandas_roundtrip(df, expected) def test_unicode_filename(self): # GH #209 name = (b'Besa_Kavaj\xc3\xab.feather').decode('utf-8') df = pd.DataFrame({'foo': [1, 2, 3, 4]}) self._check_pandas_roundtrip(df, path=name) def test_read_columns(self): data = {'foo': [1,2,3,4], 'boo': [5,6,7,8], 'woo': [1,3,5,7]} columns = list(data.keys())[1:3] df = pd.DataFrame(data) expected = pd.DataFrame({c:data[c] for c in columns}) self._check_pandas_roundtrip(df, expected, columns=columns) def test_overwritten_file(self): path = random_path() num_values = 100 np.random.seed(0) values = np.random.randint(0, 10, size=num_values) feather.write_dataframe(pd.DataFrame({'ints':values}), path) df = pd.DataFrame({'ints':values[0:num_values//2]}) self._check_pandas_roundtrip(df, path=path) def test_sparse_dataframe(self): # GH #221 data = {'A': [0,1,2], 'B': [1,0,1]} df = pd.DataFrame(data).to_sparse(fill_value=1) expected = df.to_dense() self._check_pandas_roundtrip(df, expected) def test_duplicate_columns(self): # https://github.com/wesm/feather/issues/53 # not currently able to handle duplicate columns df = pd.DataFrame(np.arange(12).reshape(4, 3), columns=list('aaa')).copy() self._assert_error_on_write(df, ValueError) def test_unsupported(self): # https://github.com/wesm/feather/issues/240 # serializing actual python objects # period df = pd.DataFrame({'a': pd.period_range('2013', freq='M', periods=3)}) self._assert_error_on_write(df, ValueError) # non-strings df = pd.DataFrame({'a': ['a', 1, 2.0]}) self._assert_error_on_write(df, ValueError) feather-format-0.3.1/feather/version.py0000664000175100017510000000011413005023556020043 0ustar wesmwesm00000000000000 # THIS FILE IS GENERATED FROM SETUP.PY version = '0.3.1' isrelease = 'True'feather-format-0.3.1/feather/libfeather.pxd0000664000175100017510000001443612756747223020662 0ustar wesmwesm00000000000000# Copyright 2016 Feather Developers # # 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. # distutils: language = c++ from libc.stdint cimport * from libcpp cimport bool as c_bool from libcpp.string cimport string from libcpp.vector cimport vector # This must be included for cerr and other things to work cdef extern from "": pass cdef extern from "" namespace "std" nogil: cdef cppclass shared_ptr[T]: T* get() void reset() void reset(T* p) shared_ptr[T] make_shared[T](T* p) cdef cppclass unique_ptr[T]: T* get() void reset() void reset(T* p) cdef extern from "feather/api.h" namespace "feather" nogil: cdef Status Status_OK "Status::OK"() cdef cppclass Status: Status() string ToString() c_bool ok() c_bool IsInvalid() c_bool IsOutOfMemory() c_bool IsIOError() enum PrimitiveType" feather::PrimitiveType::type": PrimitiveType_BOOL" feather::PrimitiveType::BOOL" PrimitiveType_INT8" feather::PrimitiveType::INT8" PrimitiveType_INT16" feather::PrimitiveType::INT16" PrimitiveType_INT32" feather::PrimitiveType::INT32" PrimitiveType_INT64" feather::PrimitiveType::INT64" PrimitiveType_UINT8" feather::PrimitiveType::UINT8" PrimitiveType_UINT16" feather::PrimitiveType::UINT16" PrimitiveType_UINT32" feather::PrimitiveType::UINT32" PrimitiveType_UINT64" feather::PrimitiveType::UINT64" PrimitiveType_FLOAT" feather::PrimitiveType::FLOAT" PrimitiveType_DOUBLE" feather::PrimitiveType::DOUBLE" PrimitiveType_UTF8" feather::PrimitiveType::UTF8" PrimitiveType_BINARY" feather::PrimitiveType::BINARY" PrimitiveType_CATEGORY" feather::PrimitiveType::CATEGORY" enum ColumnType" feather::ColumnType::type": ColumnType_PRIMITIVE" feather::ColumnType::PRIMITIVE" ColumnType_CATEGORY" feather::ColumnType::CATEGORY" ColumnType_TIMESTAMP" feather::ColumnType::TIMESTAMP" enum Encoding" feather::Encoding::type": Encoding_PLAIN" feather::Encoding::PLAIN" Encoding_DICTIONARY" feather::Encoding::DICTIONARY" enum TimeUnit" feather::TimeUnit::type": TimeUnit_SECOND" feather::TimeUnit::SECOND" TimeUnit_MILLISECOND" feather::TimeUnit::MILLISECOND" TimeUnit_MICROSECOND" feather::TimeUnit::MICROSECOND" TimeUnit_NANOSECOND" feather::TimeUnit::NANOSECOND" cdef cppclass TimestampMetadata: TimeUnit unit string timezone cdef cppclass TimeMetadata: TimeUnit unit cdef cppclass Buffer: pass cdef cppclass PrimitiveArray: PrimitiveType type int64_t length int64_t null_count const uint8_t* nulls const uint8_t* values vector[shared_ptr[Buffer]] buffers # For UTF8 and BINARY, not used otherwise const int32_t* offsets c_bool Equals(const PrimitiveArray& other) cdef cppclass CategoryArray: PrimitiveArray indices PrimitiveArray levels c_bool ordered cdef cppclass DictEncodedArray: PrimitiveArray dict_values PrimitiveArray indices cdef cppclass InputStream: pass cdef cppclass OutputStream: void Close() int64_t Tell() void Write(const uint8_t* data, int64_t length) cdef cppclass InMemoryOutputStream(OutputStream): InMemoryOutputStream(int64_t initial_capacity) shared_ptr[Buffer] Finish() cdef cppclass RandomAccessReader: int64_t Tell() void Seek(int64_t pos) shared_ptr[Buffer] ReadAt(int64_t position, int64_t nbytes) shared_ptr[Buffer] Read(int64_t nbytes) int64_t size() cdef cppclass LocalFileReader(RandomAccessReader): @staticmethod unique_ptr[LocalFileReader] Open(const string& path) void CloseFile() c_bool is_open() const string& path() cdef cppclass BufferReader(RandomAccessReader): BufferReader(const shared_ptr[Buffer]& buffer) cdef cppclass TableWriter: TableWriter() @staticmethod Status OpenFile(const string& abspath, unique_ptr[TableWriter]* out) void SetDescription(const string& desc) void SetNumRows(int64_t num_rows) Status AppendPlain(const string& name, const PrimitiveArray& values) Status AppendCategory(const string& name, const PrimitiveArray& values, const PrimitiveArray& levels, c_bool ordered) Status AppendTimestamp(const string& name, const PrimitiveArray& values, const TimestampMetadata& meta) Status AppendDate(const string& name, const PrimitiveArray& values) Status AppendTime(const string& name, const PrimitiveArray& values, const TimeMetadata& meta) Status Finalize() cdef cppclass CColumn" feather::Column": const PrimitiveArray& values() ColumnType type() string name() cdef cppclass CColumnMetadata" feather::metadata::Column": string name() const ColumnType type() const string user_metadata() const cdef cppclass CategoryColumn(CColumn): const PrimitiveArray& levels() cdef cppclass TimestampColumn(CColumn): TimeUnit unit() string timezone() cdef cppclass TableReader: TableReader(const shared_ptr[RandomAccessReader]& source) @staticmethod Status OpenFile(const string& abspath, unique_ptr[TableReader]* out) string GetDescription() c_bool HasDescription() int64_t num_rows() int64_t num_columns() Status GetColumn(int i, unique_ptr[CColumn]* out) Status GetColumnMetadata(int i, shared_ptr[CColumnMetadata]* out) feather-format-0.3.1/README.md0000664000175100017510000000357112756747223015677 0ustar wesmwesm00000000000000## Python interface to the Apache Arrow-based Feather File Format Feather efficiently stores pandas DataFrame objects on disk. ## Installing ```shell pip install feather-format ``` From [conda-forge][1]: ```shell conda install feather-format -c conda-forge ``` #### Mac notes Anaconda uses a default 10.5 deployment target which does not have C++11 properly available. This can be fixed by setting: ``` export MACOSX_DEPLOYMENT_TARGET=10.9 ``` Deployments targets as early as 10.7 can be used if the compiler supports C++11 and the correct mode is selected. For example using the following: ``` export MACOSX_DEPLOYMENT_TARGET=10.7 export CFLAGS="${CXXFLAGS} -stdlib=libc++ -std=c++11" export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -std=c++11" ``` This may be necessary in some other OS X environments. ## Build Building Feather requires a C++11 compiler. We've simplified the PyPI packaging to include libfeather (the C++ core library) to be built statically as part of the Python extension build, but this may change in the future. ### Static builds for easier packaging At the moment, the libfeather sources are being built and linked with the Cython extension, rather than building the `libfeather` shared library and linking to that. While we continue to do this, building from source requires you to symlink (or copy) the C++ sources. See: ```shell # Symlink the C++ library for the static build ln -s ../cpp/src src python setup.py build # To install it locally python setup.py install # Source distribution python setup.py sdist ``` To change this and instead link to an installed `libfeather.so`, look in `setup.py` and make the following change: ```python FEATHER_STATIC_BUILD = False ``` ## Limitations Some features of pandas are not supported in Feather: * Non-string column names * Row indexes * Object-type columns with non-homogeneous data [1]: https://conda-forge.github.iofeather-format-0.3.1/src/0000775000175100017510000000000013005023556015161 5ustar wesmwesm00000000000000feather-format-0.3.1/src/flatbuffers/0000775000175100017510000000000013005023556017464 5ustar wesmwesm00000000000000feather-format-0.3.1/src/flatbuffers/flatbuffers.h0000664000175100017510000014260012675071542022155 0ustar wesmwesm00000000000000/* * Copyright 2014 Google Inc. All rights reserved. * * 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. */ #ifndef FLATBUFFERS_H_ #define FLATBUFFERS_H_ #include #include #include #include #include #include #include #include #include #include #include /// @cond FLATBUFFERS_INTERNAL #if __cplusplus <= 199711L && \ (!defined(_MSC_VER) || _MSC_VER < 1600) && \ (!defined(__GNUC__) || \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400)) #error A C++11 compatible compiler with support for the auto typing is required for FlatBuffers. #error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ #endif #if !defined(__clang__) && \ defined(__GNUC__) && \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600) // Backwards compatability for g++ 4.4, and 4.5 which don't have the nullptr and constexpr // keywords. Note the __clang__ check is needed, because clang presents itself as an older GNUC // compiler. #ifndef nullptr_t const class nullptr_t { public: template inline operator T*() const { return 0; } private: void operator&() const; } nullptr = {}; #endif #ifndef constexpr #define constexpr const #endif #endif // The wire format uses a little endian encoding (since that's efficient for // the common platforms). #if !defined(FLATBUFFERS_LITTLEENDIAN) #if defined(__GNUC__) || defined(__clang__) #ifdef __BIG_ENDIAN__ #define FLATBUFFERS_LITTLEENDIAN 0 #else #define FLATBUFFERS_LITTLEENDIAN 1 #endif // __BIG_ENDIAN__ #elif defined(_MSC_VER) #if defined(_M_PPC) #define FLATBUFFERS_LITTLEENDIAN 0 #else #define FLATBUFFERS_LITTLEENDIAN 1 #endif #else #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN. #endif #endif // !defined(FLATBUFFERS_LITTLEENDIAN) #define FLATBUFFERS_VERSION_MAJOR 1 #define FLATBUFFERS_VERSION_MINOR 0 #define FLATBUFFERS_VERSION_REVISION 0 #define FLATBUFFERS_STRING_EXPAND(X) #X #define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) #if (!defined(_MSC_VER) || _MSC_VER > 1600) && \ (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) #define FLATBUFFERS_FINAL_CLASS final #else #define FLATBUFFERS_FINAL_CLASS #endif /// @endcond /// @file namespace flatbuffers { /// @cond FLATBUFFERS_INTERNAL // Our default offset / size type, 32bit on purpose on 64bit systems. // Also, using a consistent offset type maintains compatibility of serialized // offset values between 32bit and 64bit systems. typedef uint32_t uoffset_t; // Signed offsets for references that can go in both directions. typedef int32_t soffset_t; // Offset/index used in v-tables, can be changed to uint8_t in // format forks to save a bit of space if desired. typedef uint16_t voffset_t; typedef uintmax_t largest_scalar_t; // Pointer to relinquished memory. typedef std::unique_ptr> unique_ptr_t; // Wrapper for uoffset_t to allow safe template specialization. template struct Offset { uoffset_t o; Offset() : o(0) {} Offset(uoffset_t _o) : o(_o) {} Offset Union() const { return Offset(o); } }; inline void EndianCheck() { int endiantest = 1; // If this fails, see FLATBUFFERS_LITTLEENDIAN above. assert(*reinterpret_cast(&endiantest) == FLATBUFFERS_LITTLEENDIAN); (void)endiantest; } template T EndianScalar(T t) { #if FLATBUFFERS_LITTLEENDIAN return t; #else #if defined(_MSC_VER) #pragma push_macro("__builtin_bswap16") #pragma push_macro("__builtin_bswap32") #pragma push_macro("__builtin_bswap64") #define __builtin_bswap16 _byteswap_ushort #define __builtin_bswap32 _byteswap_ulong #define __builtin_bswap64 _byteswap_uint64 #endif // If you're on the few remaining big endian platforms, we make the bold // assumption you're also on gcc/clang, and thus have bswap intrinsics: if (sizeof(T) == 1) { // Compile-time if-then's. return t; } else if (sizeof(T) == 2) { auto r = __builtin_bswap16(*reinterpret_cast(&t)); return *reinterpret_cast(&r); } else if (sizeof(T) == 4) { auto r = __builtin_bswap32(*reinterpret_cast(&t)); return *reinterpret_cast(&r); } else if (sizeof(T) == 8) { auto r = __builtin_bswap64(*reinterpret_cast(&t)); return *reinterpret_cast(&r); } else { assert(0); } #if defined(_MSC_VER) #pragma pop_macro("__builtin_bswap16") #pragma pop_macro("__builtin_bswap32") #pragma pop_macro("__builtin_bswap64") #endif #endif } template T ReadScalar(const void *p) { return EndianScalar(*reinterpret_cast(p)); } template void WriteScalar(void *p, T t) { *reinterpret_cast(p) = EndianScalar(t); } template size_t AlignOf() { #ifdef _MSC_VER return __alignof(T); #else #ifndef alignof return __alignof__(T); #else return alignof(T); #endif #endif } // When we read serialized data from memory, in the case of most scalars, // we want to just read T, but in the case of Offset, we want to actually // perform the indirection and return a pointer. // The template specialization below does just that. // It is wrapped in a struct since function templates can't overload on the // return type like this. // The typedef is for the convenience of callers of this function // (avoiding the need for a trailing return decltype) template struct IndirectHelper { typedef T return_type; static const size_t element_stride = sizeof(T); static return_type Read(const uint8_t *p, uoffset_t i) { return EndianScalar((reinterpret_cast(p))[i]); } }; template struct IndirectHelper> { typedef const T *return_type; static const size_t element_stride = sizeof(uoffset_t); static return_type Read(const uint8_t *p, uoffset_t i) { p += i * sizeof(uoffset_t); return reinterpret_cast(p + ReadScalar(p)); } }; template struct IndirectHelper { typedef const T *return_type; static const size_t element_stride = sizeof(T); static return_type Read(const uint8_t *p, uoffset_t i) { return reinterpret_cast(p + i * sizeof(T)); } }; // An STL compatible iterator implementation for Vector below, effectively // calling Get() for every element. template struct VectorIterator : public std::iterator < std::input_iterator_tag, typename std::conditional < bConst, const typename IndirectHelper::return_type, typename IndirectHelper::return_type > ::type, uoffset_t > { typedef std::iterator::return_type, typename IndirectHelper::return_type>::type, uoffset_t> super_type; public: VectorIterator(const uint8_t *data, uoffset_t i) : data_(data + IndirectHelper::element_stride * i) {}; VectorIterator(const VectorIterator &other) : data_(other.data_) {} VectorIterator(VectorIterator &&other) : data_(std::move(other.data_)) {} VectorIterator &operator=(const VectorIterator &other) { data_ = other.data_; return *this; } VectorIterator &operator=(VectorIterator &&other) { data_ = other.data_; return *this; } bool operator==(const VectorIterator& other) const { return data_ == other.data_; } bool operator!=(const VectorIterator& other) const { return data_ != other.data_; } ptrdiff_t operator-(const VectorIterator& other) const { return (data_ - other.data_) / IndirectHelper::element_stride; } typename super_type::value_type operator *() const { return IndirectHelper::Read(data_, 0); } typename super_type::value_type operator->() const { return IndirectHelper::Read(data_, 0); } VectorIterator &operator++() { data_ += IndirectHelper::element_stride; return *this; } VectorIterator operator++(int) { VectorIterator temp(data_); data_ += IndirectHelper::element_stride; return temp; } private: const uint8_t *data_; }; // This is used as a helper type for accessing vectors. // Vector::data() assumes the vector elements start after the length field. template class Vector { public: typedef VectorIterator iterator; typedef VectorIterator const_iterator; uoffset_t size() const { return EndianScalar(length_); } // Deprecated: use size(). Here for backwards compatibility. uoffset_t Length() const { return size(); } typedef typename IndirectHelper::return_type return_type; return_type Get(uoffset_t i) const { assert(i < size()); return IndirectHelper::Read(Data(), i); } return_type operator[](uoffset_t i) const { return Get(i); } // If this is a Vector of enums, T will be its storage type, not the enum // type. This function makes it convenient to retrieve value with enum // type E. template E GetEnum(uoffset_t i) const { return static_cast(Get(i)); } const void *GetStructFromOffset(size_t o) const { return reinterpret_cast(Data() + o); } iterator begin() { return iterator(Data(), 0); } const_iterator begin() const { return const_iterator(Data(), 0); } iterator end() { return iterator(Data(), size()); } const_iterator end() const { return const_iterator(Data(), size()); } // Change elements if you have a non-const pointer to this object. // Scalars only. See reflection.h, and the documentation. void Mutate(uoffset_t i, T val) { assert(i < size()); WriteScalar(data() + i, val); } // Change an element of a vector of tables (or strings). // "val" points to the new table/string, as you can obtain from // e.g. reflection::AddFlatBuffer(). void MutateOffset(uoffset_t i, const uint8_t *val) { assert(i < size()); assert(sizeof(T) == sizeof(uoffset_t)); WriteScalar(data() + i, val - (Data() + i * sizeof(uoffset_t))); } // The raw data in little endian format. Use with care. const uint8_t *Data() const { return reinterpret_cast(&length_ + 1); } uint8_t *Data() { return reinterpret_cast(&length_ + 1); } // Similarly, but typed, much like std::vector::data const T *data() const { return reinterpret_cast(Data()); } T *data() { return reinterpret_cast(Data()); } template return_type LookupByKey(K key) const { void *search_result = std::bsearch(&key, Data(), size(), IndirectHelper::element_stride, KeyCompare); if (!search_result) { return nullptr; // Key not found. } const uint8_t *element = reinterpret_cast(search_result); return IndirectHelper::Read(element, 0); } protected: // This class is only used to access pre-existing data. Don't ever // try to construct these manually. Vector(); uoffset_t length_; private: template static int KeyCompare(const void *ap, const void *bp) { const K *key = reinterpret_cast(ap); const uint8_t *data = reinterpret_cast(bp); auto table = IndirectHelper::Read(data, 0); // std::bsearch compares with the operands transposed, so we negate the // result here. return -table->KeyCompareWithValue(*key); } }; // Represent a vector much like the template above, but in this case we // don't know what the element types are (used with reflection.h). class VectorOfAny { public: uoffset_t size() const { return EndianScalar(length_); } const uint8_t *Data() const { return reinterpret_cast(&length_ + 1); } uint8_t *Data() { return reinterpret_cast(&length_ + 1); } protected: VectorOfAny(); uoffset_t length_; }; // Convenient helper function to get the length of any vector, regardless // of wether it is null or not (the field is not set). template static inline size_t VectorLength(const Vector *v) { return v ? v->Length() : 0; } struct String : public Vector { const char *c_str() const { return reinterpret_cast(Data()); } std::string str() const { return std::string(c_str(), Length()); } bool operator <(const String &o) const { return strcmp(c_str(), o.c_str()) < 0; } }; // Simple indirection for buffer allocation, to allow this to be overridden // with custom allocation (see the FlatBufferBuilder constructor). class simple_allocator { public: virtual ~simple_allocator() {} virtual uint8_t *allocate(size_t size) const { return new uint8_t[size]; } virtual void deallocate(uint8_t *p) const { delete[] p; } }; // This is a minimal replication of std::vector functionality, // except growing from higher to lower addresses. i.e push_back() inserts data // in the lowest address in the vector. class vector_downward { public: explicit vector_downward(size_t initial_size, const simple_allocator &allocator) : reserved_(initial_size), buf_(allocator.allocate(reserved_)), cur_(buf_ + reserved_), allocator_(allocator) { assert((initial_size & (sizeof(largest_scalar_t) - 1)) == 0); } ~vector_downward() { if (buf_) allocator_.deallocate(buf_); } void clear() { if (buf_ == nullptr) buf_ = allocator_.allocate(reserved_); cur_ = buf_ + reserved_; } // Relinquish the pointer to the caller. unique_ptr_t release() { // Actually deallocate from the start of the allocated memory. std::function deleter( std::bind(&simple_allocator::deallocate, allocator_, buf_)); // Point to the desired offset. unique_ptr_t retval(data(), deleter); // Don't deallocate when this instance is destroyed. buf_ = nullptr; cur_ = nullptr; return retval; } size_t growth_policy(size_t bytes) { return (bytes / 2) & ~(sizeof(largest_scalar_t) - 1); } uint8_t *make_space(size_t len) { if (len > static_cast(cur_ - buf_)) { auto old_size = size(); auto largest_align = AlignOf(); reserved_ += (std::max)(len, growth_policy(reserved_)); // Round up to avoid undefined behavior from unaligned loads and stores. reserved_ = (reserved_ + (largest_align - 1)) & ~(largest_align - 1); auto new_buf = allocator_.allocate(reserved_); auto new_cur = new_buf + reserved_ - old_size; memcpy(new_cur, cur_, old_size); cur_ = new_cur; allocator_.deallocate(buf_); buf_ = new_buf; } cur_ -= len; // Beyond this, signed offsets may not have enough range: // (FlatBuffers > 2GB not supported). assert(size() < (1UL << (sizeof(soffset_t) * 8 - 1)) - 1); return cur_; } uoffset_t size() const { assert(cur_ != nullptr && buf_ != nullptr); return static_cast(reserved_ - (cur_ - buf_)); } uint8_t *data() const { assert(cur_ != nullptr); return cur_; } uint8_t *data_at(size_t offset) { return buf_ + reserved_ - offset; } // push() & fill() are most frequently called with small byte counts (<= 4), // which is why we're using loops rather than calling memcpy/memset. void push(const uint8_t *bytes, size_t num) { auto dest = make_space(num); for (size_t i = 0; i < num; i++) dest[i] = bytes[i]; } void fill(size_t zero_pad_bytes) { auto dest = make_space(zero_pad_bytes); for (size_t i = 0; i < zero_pad_bytes; i++) dest[i] = 0; } void pop(size_t bytes_to_remove) { cur_ += bytes_to_remove; } private: // You shouldn't really be copying instances of this class. vector_downward(const vector_downward &); vector_downward &operator=(const vector_downward &); size_t reserved_; uint8_t *buf_; uint8_t *cur_; // Points at location between empty (below) and used (above). const simple_allocator &allocator_; }; // Converts a Field ID to a virtual table offset. inline voffset_t FieldIndexToOffset(voffset_t field_id) { // Should correspond to what EndTable() below builds up. const int fixed_fields = 2; // Vtable size and Object Size. return (field_id + fixed_fields) * sizeof(voffset_t); } // Computes how many bytes you'd have to pad to be able to write an // "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in // memory). inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) { return ((~buf_size) + 1) & (scalar_size - 1); } /// @endcond /// @addtogroup flatbuffers_cpp_api /// @{ /// @class FlatBufferBuilder /// @brief Helper class to hold data needed in creation of a FlatBuffer. /// To serialize data, you typically call one of the `Create*()` functions in /// the generated code, which in turn call a sequence of `StartTable`/ /// `PushElement`/`AddElement`/`EndTable`, or the builtin `CreateString`/ /// `CreateVector` functions. Do this is depth-first order to build up a tree to /// the root. `Finish()` wraps up the buffer ready for transport. class FlatBufferBuilder /// @cond FLATBUFFERS_INTERNAL FLATBUFFERS_FINAL_CLASS /// @endcond { public: /// @brief Default constructor for FlatBufferBuilder. /// @param[in] initial_size The initial size of the buffer, in bytes. Defaults /// to`1024`. /// @param[in] allocator A pointer to the `simple_allocator` that should be /// used. Defaults to `nullptr`, which means the `default_allocator` will be /// be used. explicit FlatBufferBuilder(uoffset_t initial_size = 1024, const simple_allocator *allocator = nullptr) : buf_(initial_size, allocator ? *allocator : default_allocator), nested(false), finished(false), minalign_(1), force_defaults_(false) { offsetbuf_.reserve(16); // Avoid first few reallocs. vtables_.reserve(16); EndianCheck(); } /// @brief Reset all the state in this FlatBufferBuilder so it can be reused /// to construct another buffer. void Clear() { buf_.clear(); offsetbuf_.clear(); nested = false; finished = false; vtables_.clear(); minalign_ = 1; } /// @brief The current size of the serialized buffer, counting from the end. /// @return Returns an `uoffset_t` with the current size of the buffer. uoffset_t GetSize() const { return buf_.size(); } /// @brief Get the serialized buffer (after you call `Finish()`). /// @return Returns an `uint8_t` pointer to the FlatBuffer data inside the /// buffer. uint8_t *GetBufferPointer() const { Finished(); return buf_.data(); } /// @brief Get a pointer to an unfinished buffer. /// @return Returns a `uint8_t` pointer to the unfinished buffer. uint8_t *GetCurrentBufferPointer() const { return buf_.data(); } /// @brief Get the released pointer to the serialized buffer. /// @warning Do NOT attempt to use this FlatBufferBuilder afterwards! /// @return The `unique_ptr` returned has a special allocator that knows how /// to deallocate this pointer (since it points to the middle of an /// allocation). Thus, do not mix this pointer with other `unique_ptr`'s, or /// call `release()`/`reset()` on it. unique_ptr_t ReleaseBufferPointer() { Finished(); return buf_.release(); } /// @cond FLATBUFFERS_INTERNAL void Finished() const { // If you get this assert, you're attempting to get access a buffer // which hasn't been finished yet. Be sure to call // FlatBufferBuilder::Finish with your root table. // If you really need to access an unfinished buffer, call // GetCurrentBufferPointer instead. assert(finished); } /// @endcond /// @brief In order to save space, fields that are set to their default value /// don't get serialized into the buffer. /// @param[in] bool fd When set to `true`, always serializes default values. void ForceDefaults(bool fd) { force_defaults_ = fd; } /// @cond FLATBUFFERS_INTERNAL void Pad(size_t num_bytes) { buf_.fill(num_bytes); } void Align(size_t elem_size) { if (elem_size > minalign_) minalign_ = elem_size; buf_.fill(PaddingBytes(buf_.size(), elem_size)); } void PushFlatBuffer(const uint8_t *bytes, size_t size) { PushBytes(bytes, size); finished = true; } void PushBytes(const uint8_t *bytes, size_t size) { buf_.push(bytes, size); } void PopBytes(size_t amount) { buf_.pop(amount); } template void AssertScalarT() { // The code assumes power of 2 sizes and endian-swap-ability. static_assert(std::is_scalar::value // The Offset type is essentially a scalar but fails is_scalar. || sizeof(T) == sizeof(Offset), "T must be a scalar type"); } // Write a single aligned scalar to the buffer template uoffset_t PushElement(T element) { AssertScalarT(); T litle_endian_element = EndianScalar(element); Align(sizeof(T)); PushBytes(reinterpret_cast(&litle_endian_element), sizeof(T)); return GetSize(); } template uoffset_t PushElement(Offset off) { // Special case for offsets: see ReferTo below. return PushElement(ReferTo(off.o)); } // When writing fields, we track where they are, so we can create correct // vtables later. void TrackField(voffset_t field, uoffset_t off) { FieldLoc fl = { off, field }; offsetbuf_.push_back(fl); } // Like PushElement, but additionally tracks the field this represents. template void AddElement(voffset_t field, T e, T def) { // We don't serialize values equal to the default. if (e == def && !force_defaults_) return; auto off = PushElement(e); TrackField(field, off); } template void AddOffset(voffset_t field, Offset off) { if (!off.o) return; // An offset of 0 means NULL, don't store. AddElement(field, ReferTo(off.o), static_cast(0)); } template void AddStruct(voffset_t field, const T *structptr) { if (!structptr) return; // Default, don't store. Align(AlignOf()); PushBytes(reinterpret_cast(structptr), sizeof(T)); TrackField(field, GetSize()); } void AddStructOffset(voffset_t field, uoffset_t off) { TrackField(field, off); } // Offsets initially are relative to the end of the buffer (downwards). // This function converts them to be relative to the current location // in the buffer (when stored here), pointing upwards. uoffset_t ReferTo(uoffset_t off) { // Align to ensure GetSize() below is correct. Align(sizeof(uoffset_t)); // Offset must refer to something already in buffer. assert(off && off <= GetSize()); return GetSize() - off + sizeof(uoffset_t); } void NotNested() { // If you hit this, you're trying to construct a Table/Vector/String // during the construction of its parent table (between the MyTableBuilder // and table.Finish(). // Move the creation of these sub-objects to above the MyTableBuilder to // not get this assert. // Ignoring this assert may appear to work in simple cases, but the reason // it is here is that storing objects in-line may cause vtable offsets // to not fit anymore. It also leads to vtable duplication. assert(!nested); } // From generated code (or from the parser), we call StartTable/EndTable // with a sequence of AddElement calls in between. uoffset_t StartTable() { NotNested(); nested = true; return GetSize(); } // This finishes one serialized object by generating the vtable if it's a // table, comparing it against existing vtables, and writing the // resulting vtable offset. uoffset_t EndTable(uoffset_t start, voffset_t numfields) { // If you get this assert, a corresponding StartTable wasn't called. assert(nested); // Write the vtable offset, which is the start of any Table. // We fill it's value later. auto vtableoffsetloc = PushElement(0); // Write a vtable, which consists entirely of voffset_t elements. // It starts with the number of offsets, followed by a type id, followed // by the offsets themselves. In reverse: buf_.fill(numfields * sizeof(voffset_t)); auto table_object_size = vtableoffsetloc - start; assert(table_object_size < 0x10000); // Vtable use 16bit offsets. PushElement(static_cast(table_object_size)); PushElement(FieldIndexToOffset(numfields)); // Write the offsets into the table for (auto field_location = offsetbuf_.begin(); field_location != offsetbuf_.end(); ++field_location) { auto pos = static_cast(vtableoffsetloc - field_location->off); // If this asserts, it means you've set a field twice. assert(!ReadScalar(buf_.data() + field_location->id)); WriteScalar(buf_.data() + field_location->id, pos); } offsetbuf_.clear(); auto vt1 = reinterpret_cast(buf_.data()); auto vt1_size = ReadScalar(vt1); auto vt_use = GetSize(); // See if we already have generated a vtable with this exact same // layout before. If so, make it point to the old one, remove this one. for (auto it = vtables_.begin(); it != vtables_.end(); ++it) { auto vt2 = reinterpret_cast(buf_.data_at(*it)); auto vt2_size = *vt2; if (vt1_size != vt2_size || memcmp(vt2, vt1, vt1_size)) continue; vt_use = *it; buf_.pop(GetSize() - vtableoffsetloc); break; } // If this is a new vtable, remember it. if (vt_use == GetSize()) { vtables_.push_back(vt_use); } // Fill the vtable offset we created above. // The offset points from the beginning of the object to where the // vtable is stored. // Offsets default direction is downward in memory for future format // flexibility (storing all vtables at the start of the file). WriteScalar(buf_.data_at(vtableoffsetloc), static_cast(vt_use) - static_cast(vtableoffsetloc)); nested = false; return vtableoffsetloc; } // This checks a required field has been set in a given table that has // just been constructed. template void Required(Offset table, voffset_t field) { auto table_ptr = buf_.data_at(table.o); auto vtable_ptr = table_ptr - ReadScalar(table_ptr); bool ok = ReadScalar(vtable_ptr + field) != 0; // If this fails, the caller will show what field needs to be set. assert(ok); (void)ok; } uoffset_t StartStruct(size_t alignment) { Align(alignment); return GetSize(); } uoffset_t EndStruct() { return GetSize(); } void ClearOffsets() { offsetbuf_.clear(); } // Aligns such that when "len" bytes are written, an object can be written // after it with "alignment" without padding. void PreAlign(size_t len, size_t alignment) { buf_.fill(PaddingBytes(GetSize() + len, alignment)); } template void PreAlign(size_t len) { AssertScalarT(); PreAlign(len, sizeof(T)); } /// @endcond /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const char pointer to the data to be stored as a string. /// @param[in] len The number of bytes that should be stored from `str`. /// @return Returns the offset in the buffer where the string starts. Offset CreateString(const char *str, size_t len) { NotNested(); PreAlign(len + 1); // Always 0-terminated. buf_.fill(1); PushBytes(reinterpret_cast(str), len); PushElement(static_cast(len)); return Offset(GetSize()); } /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const char pointer to a C-string to add to the buffer. /// @return Returns the offset in the buffer where the string starts. Offset CreateString(const char *str) { return CreateString(str, strlen(str)); } /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const reference to a std::string to store in the buffer. /// @return Returns the offset in the buffer where the string starts. Offset CreateString(const std::string &str) { return CreateString(str.c_str(), str.length()); } /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const pointer to a `String` struct to add to the buffer. /// @return Returns the offset in the buffer where the string starts Offset CreateString(const String *str) { return CreateString(str->c_str(), str->Length()); } /// @cond FLATBUFFERS_INTERNAL uoffset_t EndVector(size_t len) { assert(nested); // Hit if no corresponding StartVector. nested = false; return PushElement(static_cast(len)); } void StartVector(size_t len, size_t elemsize) { NotNested(); nested = true; PreAlign(len * elemsize); PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t. } // Call this right before StartVector/CreateVector if you want to force the // alignment to be something different than what the element size would // normally dictate. // This is useful when storing a nested_flatbuffer in a vector of bytes, // or when storing SIMD floats, etc. void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { PreAlign(len * elemsize, alignment); } uint8_t *ReserveElements(size_t len, size_t elemsize) { return buf_.make_space(len * elemsize); } /// @endcond /// @brief Serialize an array into a FlatBuffer `vector`. /// @tparam T The data type of the array elements. /// @param[in] v A pointer to the array of type `T` to serialize into the /// buffer as a `vector`. /// @param[in] len The number of elements to serialize. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template Offset> CreateVector(const T *v, size_t len) { StartVector(len, sizeof(T)); for (auto i = len; i > 0; ) { PushElement(v[--i]); } return Offset>(EndVector(len)); } /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. /// @tparam T The data type of the `std::vector` elements. /// @param v A const reference to the `std::vector` to serialize into the /// buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template Offset> CreateVector(const std::vector &v) { return CreateVector(v.data(), v.size()); } /// @brief Serialize an array of structs into a FlatBuffer `vector`. /// @tparam T The data type of the struct array elements. /// @param[in] v A pointer to the array of type `T` to serialize into the /// buffer as a `vector`. /// @param[in] len The number of elements to serialize. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template Offset> CreateVectorOfStructs( const T *v, size_t len) { StartVector(len * sizeof(T) / AlignOf(), AlignOf()); PushBytes(reinterpret_cast(v), sizeof(T) * len); return Offset>(EndVector(len)); } /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector`. /// @tparam T The data type of the `std::vector` struct elements. /// @param[in]] v A const reference to the `std::vector` of structs to /// serialize into the buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template Offset> CreateVectorOfStructs( const std::vector &v) { return CreateVectorOfStructs(v.data(), v.size()); } /// @cond FLATBUFFERS_INTERNAL template struct TableKeyComparator { TableKeyComparator(vector_downward& buf) : buf_(buf) {} bool operator()(const Offset &a, const Offset &b) const { auto table_a = reinterpret_cast(buf_.data_at(a.o)); auto table_b = reinterpret_cast(buf_.data_at(b.o)); return table_a->KeyCompareLessThan(table_b); } vector_downward& buf_; private: TableKeyComparator& operator= (const TableKeyComparator&); }; /// @endcond /// @brief Serialize an array of `table` offsets as a `vector` in the buffer /// in sorted order. /// @tparam T The data type that the offset refers to. /// @param[in] v An array of type `Offset` that contains the `table` /// offsets to store in the buffer in sorted order. /// @param[in] len The number of elements to store in the `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template Offset>> CreateVectorOfSortedTables( Offset *v, size_t len) { std::sort(v, v + len, TableKeyComparator(buf_)); return CreateVector(v, len); } /// @brief Serialize an array of `table` offsets as a `vector` in the buffer /// in sorted order. /// @tparam T The data type that the offset refers to. /// @param[in] v An array of type `Offset` that contains the `table` /// offsets to store in the buffer in sorted order. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template Offset>> CreateVectorOfSortedTables( std::vector> *v) { return CreateVectorOfSortedTables(v->data(), v->size()); } /// @brief Specialized version of `CreateVector` for non-copying use cases. /// Write the data any time later to the returned buffer pointer `buf`. /// @param[in] len The number of elements to store in the `vector`. /// @param[in] elemsize The size of each element in the `vector`. /// @param[out] buf A pointer to a `uint8_t` pointer that can be /// written to at a later time to serialize the data into a `vector` /// in the buffer. uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, uint8_t **buf) { NotNested(); StartVector(len, elemsize); *buf = buf_.make_space(len * elemsize); return EndVector(len); } /// @brief Specialized version of `CreateVector` for non-copying use cases. /// Write the data any time later to the returned buffer pointer `buf`. /// @tparam T The data type of the data that will be stored in the buffer /// as a `vector`. /// @param[in] len The number of elements to store in the `vector`. /// @param[out] buf A pointer to a pointer of type `T` that can be /// written to at a later time to serialize the data into a `vector` /// in the buffer. template Offset> CreateUninitializedVector( size_t len, T **buf) { return CreateUninitializedVector(len, sizeof(T), reinterpret_cast(buf)); } /// @brief The length of a FlatBuffer file header. static const size_t kFileIdentifierLength = 4; /// @brief Finish serializing a buffer by writing the root offset. /// @param[in] file_identifier If a `file_identifier` is given, the buffer /// will be prefixed with a standard FlatBuffers file header. template void Finish(Offset root, const char *file_identifier = nullptr) { NotNested(); // This will cause the whole buffer to be aligned. PreAlign(sizeof(uoffset_t) + (file_identifier ? kFileIdentifierLength : 0), minalign_); if (file_identifier) { assert(strlen(file_identifier) == kFileIdentifierLength); buf_.push(reinterpret_cast(file_identifier), kFileIdentifierLength); } PushElement(ReferTo(root.o)); // Location of root. finished = true; } private: // You shouldn't really be copying instances of this class. FlatBufferBuilder(const FlatBufferBuilder &); FlatBufferBuilder &operator=(const FlatBufferBuilder &); struct FieldLoc { uoffset_t off; voffset_t id; }; simple_allocator default_allocator; vector_downward buf_; // Accumulating offsets of table members while it is being built. std::vector offsetbuf_; // Ensure objects are not nested. bool nested; // Ensure the buffer is finished before it is being accessed. bool finished; std::vector vtables_; // todo: Could make this into a map? size_t minalign_; bool force_defaults_; // Serialize values equal to their defaults anyway. }; /// @} /// @cond FLATBUFFERS_INTERNAL // Helpers to get a typed pointer to the root object contained in the buffer. template T *GetMutableRoot(void *buf) { EndianCheck(); return reinterpret_cast(reinterpret_cast(buf) + EndianScalar(*reinterpret_cast(buf))); } template const T *GetRoot(const void *buf) { return GetMutableRoot(const_cast(buf)); } // Helper to see if the identifier in a buffer has the expected value. inline bool BufferHasIdentifier(const void *buf, const char *identifier) { return strncmp(reinterpret_cast(buf) + sizeof(uoffset_t), identifier, FlatBufferBuilder::kFileIdentifierLength) == 0; } // Helper class to verify the integrity of a FlatBuffer class Verifier FLATBUFFERS_FINAL_CLASS { public: Verifier(const uint8_t *buf, size_t buf_len, size_t _max_depth = 64, size_t _max_tables = 1000000) : buf_(buf), end_(buf + buf_len), depth_(0), max_depth_(_max_depth), num_tables_(0), max_tables_(_max_tables) {} // Central location where any verification failures register. bool Check(bool ok) const { #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE assert(ok); #endif return ok; } // Verify any range within the buffer. bool Verify(const void *elem, size_t elem_len) const { return Check(elem_len <= (size_t) (end_ - buf_) && elem >= buf_ && elem <= end_ - elem_len); } // Verify a range indicated by sizeof(T). template bool Verify(const void *elem) const { return Verify(elem, sizeof(T)); } // Verify a pointer (may be NULL) of a table type. template bool VerifyTable(const T *table) { return !table || table->Verify(*this); } // Verify a pointer (may be NULL) of any vector type. template bool Verify(const Vector *vec) const { const uint8_t *end; return !vec || VerifyVector(reinterpret_cast(vec), sizeof(T), &end); } // Verify a pointer (may be NULL) of a vector to struct. template bool Verify(const Vector *vec) const { return Verify(reinterpret_cast *>(vec)); } // Verify a pointer (may be NULL) to string. bool Verify(const String *str) const { const uint8_t *end; return !str || (VerifyVector(reinterpret_cast(str), 1, &end) && Verify(end, 1) && // Must have terminator Check(*end == '\0')); // Terminating byte must be 0. } // Common code between vectors and strings. bool VerifyVector(const uint8_t *vec, size_t elem_size, const uint8_t **end) const { // Check we can read the size field. if (!Verify(vec)) return false; // Check the whole array. If this is a string, the byte past the array // must be 0. auto size = ReadScalar(vec); auto byte_size = sizeof(size) + elem_size * size; *end = vec + byte_size; return Verify(vec, byte_size); } // Special case for string contents, after the above has been called. bool VerifyVectorOfStrings(const Vector> *vec) const { if (vec) { for (uoffset_t i = 0; i < vec->size(); i++) { if (!Verify(vec->Get(i))) return false; } } return true; } // Special case for table contents, after the above has been called. template bool VerifyVectorOfTables(const Vector> *vec) { if (vec) { for (uoffset_t i = 0; i < vec->size(); i++) { if (!vec->Get(i)->Verify(*this)) return false; } } return true; } // Verify this whole buffer, starting with root type T. template bool VerifyBuffer() { // Call T::Verify, which must be in the generated code for this type. return Verify(buf_) && reinterpret_cast(buf_ + ReadScalar(buf_))-> Verify(*this); } // Called at the start of a table to increase counters measuring data // structure depth and amount, and possibly bails out with false if // limits set by the constructor have been hit. Needs to be balanced // with EndTable(). bool VerifyComplexity() { depth_++; num_tables_++; return Check(depth_ <= max_depth_ && num_tables_ <= max_tables_); } // Called at the end of a table to pop the depth count. bool EndTable() { depth_--; return true; } private: const uint8_t *buf_; const uint8_t *end_; size_t depth_; size_t max_depth_; size_t num_tables_; size_t max_tables_; }; // "structs" are flat structures that do not have an offset table, thus // always have all members present and do not support forwards/backwards // compatible extensions. class Struct FLATBUFFERS_FINAL_CLASS { public: template T GetField(uoffset_t o) const { return ReadScalar(&data_[o]); } template T GetPointer(uoffset_t o) const { auto p = &data_[o]; return reinterpret_cast(p + ReadScalar(p)); } template T GetStruct(uoffset_t o) const { return reinterpret_cast(&data_[o]); } const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } private: uint8_t data_[1]; }; // "tables" use an offset table (possibly shared) that allows fields to be // omitted and added at will, but uses an extra indirection to read. class Table { public: // This gets the field offset for any of the functions below it, or 0 // if the field was not present. voffset_t GetOptionalFieldOffset(voffset_t field) const { // The vtable offset is always at the start. auto vtable = data_ - ReadScalar(data_); // The first element is the size of the vtable (fields + type id + itself). auto vtsize = ReadScalar(vtable); // If the field we're accessing is outside the vtable, we're reading older // data, so it's the same as if the offset was 0 (not present). return field < vtsize ? ReadScalar(vtable + field) : 0; } template T GetField(voffset_t field, T defaultval) const { auto field_offset = GetOptionalFieldOffset(field); return field_offset ? ReadScalar(data_ + field_offset) : defaultval; } template P GetPointer(voffset_t field) { auto field_offset = GetOptionalFieldOffset(field); auto p = data_ + field_offset; return field_offset ? reinterpret_cast

(p + ReadScalar(p)) : nullptr; } template P GetPointer(voffset_t field) const { return const_cast(this)->GetPointer

(field); } template P GetStruct(voffset_t field) const { auto field_offset = GetOptionalFieldOffset(field); auto p = const_cast(data_ + field_offset); return field_offset ? reinterpret_cast

(p) : nullptr; } template bool SetField(voffset_t field, T val) { auto field_offset = GetOptionalFieldOffset(field); if (!field_offset) return false; WriteScalar(data_ + field_offset, val); return true; } bool SetPointer(voffset_t field, const uint8_t *val) { auto field_offset = GetOptionalFieldOffset(field); if (!field_offset) return false; WriteScalar(data_ + field_offset, val - (data_ + field_offset)); return true; } uint8_t *GetAddressOf(voffset_t field) { auto field_offset = GetOptionalFieldOffset(field); return field_offset ? data_ + field_offset : nullptr; } const uint8_t *GetAddressOf(voffset_t field) const { return const_cast

(this)->GetAddressOf(field); } uint8_t *GetVTable() { return data_ - ReadScalar(data_); } bool CheckField(voffset_t field) const { return GetOptionalFieldOffset(field) != 0; } // Verify the vtable of this table. // Call this once per table, followed by VerifyField once per field. bool VerifyTableStart(Verifier &verifier) const { // Check the vtable offset. if (!verifier.Verify(data_)) return false; auto vtable = data_ - ReadScalar(data_); // Check the vtable size field, then check vtable fits in its entirety. return verifier.VerifyComplexity() && verifier.Verify(vtable) && verifier.Verify(vtable, ReadScalar(vtable)); } // Verify a particular field. template bool VerifyField(const Verifier &verifier, voffset_t field) const { // Calling GetOptionalFieldOffset should be safe now thanks to // VerifyTable(). auto field_offset = GetOptionalFieldOffset(field); // Check the actual field. return !field_offset || verifier.Verify(data_ + field_offset); } // VerifyField for required fields. template bool VerifyFieldRequired(const Verifier &verifier, voffset_t field) const { auto field_offset = GetOptionalFieldOffset(field); return verifier.Check(field_offset != 0) && verifier.Verify(data_ + field_offset); } private: // private constructor & copy constructor: you obtain instances of this // class by pointing to existing data only Table(); Table(const Table &other); uint8_t data_[1]; }; // Helper function to test if a field is present, using any of the field // enums in the generated code. // `table` must be a generated table type. Since this is a template parameter, // this is not typechecked to be a subclass of Table, so beware! // Note: this function will return false for fields equal to the default // value, since they're not stored in the buffer (unless force_defaults was // used). template bool IsFieldPresent(const T *table, voffset_t field) { // Cast, since Table is a private baseclass of any table types. return reinterpret_cast(table)->CheckField(field); } // Utility function for reverse lookups on the EnumNames*() functions // (in the generated C++ code) // names must be NULL terminated. inline int LookupEnum(const char **names, const char *name) { for (const char **p = names; *p; p++) if (!strcmp(*p, name)) return static_cast(p - names); return -1; } // These macros allow us to layout a struct with a guarantee that they'll end // up looking the same on different compilers and platforms. // It does this by disallowing the compiler to do any padding, and then // does padding itself by inserting extra padding fields that make every // element aligned to its own size. // Additionally, it manually sets the alignment of the struct as a whole, // which is typically its largest element, or a custom size set in the schema // by the force_align attribute. // These are used in the generated code only. #if defined(_MSC_VER) #define MANUALLY_ALIGNED_STRUCT(alignment) \ __pragma(pack(1)); \ struct __declspec(align(alignment)) #define STRUCT_END(name, size) \ __pragma(pack()); \ static_assert(sizeof(name) == size, "compiler breaks packing rules") #elif defined(__GNUC__) || defined(__clang__) #define MANUALLY_ALIGNED_STRUCT(alignment) \ _Pragma("pack(1)") \ struct __attribute__((aligned(alignment))) #define STRUCT_END(name, size) \ _Pragma("pack()") \ static_assert(sizeof(name) == size, "compiler breaks packing rules") #else #error Unknown compiler, please define structure alignment macros #endif // String which identifies the current version of FlatBuffers. // flatbuffer_version_string is used by Google developers to identify which // applications uploaded to Google Play are using this library. This allows // the development team at Google to determine the popularity of the library. // How it works: Applications that are uploaded to the Google Play Store are // scanned for this version string. We track which applications are using it // to measure popularity. You are free to remove it (of course) but we would // appreciate if you left it in. // Weak linkage is culled by VS & doesn't work on cygwin. #if !defined(_WIN32) && !defined(__CYGWIN__) extern volatile __attribute__((weak)) const char *flatbuffer_version_string; volatile __attribute__((weak)) const char *flatbuffer_version_string = "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); #endif // !defined(_WIN32) && !defined(__CYGWIN__) /// @endcond } // namespace flatbuffers #endif // FLATBUFFERS_H_ feather-format-0.3.1/src/feather/0000775000175100017510000000000013005023556016577 5ustar wesmwesm00000000000000feather-format-0.3.1/src/feather/io.h0000664000175100017510000001112512756750540017373 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_IO_H #define FEATHER_IO_H #include #include #include #include #include "feather/compatibility.h" namespace feather { class Buffer; class OwnedMutableBuffer; class Status; class FileInterface; // ---------------------------------------------------------------------- // Input interfaces // An abstract read-only file interface capable of performing Seeks (as opposed // to being an input stream) class RandomAccessReader { public: virtual ~RandomAccessReader() {} virtual Status Tell(int64_t* pos) const = 0; virtual Status Seek(int64_t pos) = 0; // Read data from source at position (seeking if necessary), returning copy // only if necessary. Lifetime of read data is managed by the returned Buffer // instance Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out); // Read bytes from source at current position virtual Status Read(int64_t nbytes, std::shared_ptr* out) = 0; int64_t size() { return size_; } protected: int64_t size_; }; // File interface that interacts with a file on disk using operating-system // level seek and read calls. class LocalFileReader : public RandomAccessReader { public: LocalFileReader(); virtual ~LocalFileReader(); Status Open(const std::string& path); void CloseFile(); Status Tell(int64_t* pos) const override; Status Seek(int64_t pos) override; Status Read(int64_t nbytes, std::shared_ptr* out) override; protected: std::unique_ptr impl_; }; class MemoryMapReader : public LocalFileReader { public: MemoryMapReader() : LocalFileReader(), data_(nullptr), pos_(0) {} virtual ~MemoryMapReader(); Status Open(const std::string& path); void CloseFile(); Status Tell(int64_t* pos) const override; Status Seek(int64_t pos) override; Status Read(int64_t nbytes, std::shared_ptr* out) override; private: uint8_t* data_; int64_t pos_; }; // ---------------------------------------------------------------------- // A file-like object that reads from virtual address space class BufferReader : public RandomAccessReader { public: explicit BufferReader(const std::shared_ptr& buffer); Status Tell(int64_t* pos) const override; Status Seek(int64_t pos) override; Status Read(int64_t nbytes, std::shared_ptr* out) override; protected: const uint8_t* Head() { return data_ + pos_; } std::shared_ptr buffer_; const uint8_t* data_; int64_t pos_; }; // ---------------------------------------------------------------------- // Output interfaces // Abstract output stream class OutputStream { public: virtual ~OutputStream() {} // Close the output stream virtual Status Close() = 0; virtual Status Tell(int64_t* pos) const = 0; virtual Status Write(const uint8_t* data, int64_t length) = 0; // Call Write and add additional padding bytes if length is not a multiple of // the alignment parameter Status WritePadded(const uint8_t* data, int64_t length, int64_t* bytes_written); }; // An output stream that is an in-memory class InMemoryOutputStream : public OutputStream { public: explicit InMemoryOutputStream(int64_t initial_capacity); virtual ~InMemoryOutputStream() {} Status Close() override; Status Tell(int64_t* pos) const override; Status Write(const uint8_t* data, int64_t length) override; // Hand off the buffered data to a new owner std::shared_ptr Finish(); private: uint8_t* Head(); std::shared_ptr buffer_; int64_t size_; int64_t capacity_; }; class FileOutputStream : public OutputStream { public: FileOutputStream(); ~FileOutputStream(); Status Open(const std::string& path); Status Close() override; Status Tell(int64_t* pos) const override; Status Write(const uint8_t* data, int64_t length) override; // Hand off the buffered data to a new owner std::shared_ptr Finish(); private: std::unique_ptr impl_; }; } // namespace feather #endif // FEATHER_IO_H feather-format-0.3.1/src/feather/types.h0000664000175100017510000001051113004702052020104 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_TYPES_H #define FEATHER_TYPES_H #include #include #include #include namespace feather { class Buffer; // Feather enums, decoupled from some of the unpleasantness of // flatbuffers. This is also here so we can choose later to hide the // flatbuffers dependency to C++ users of libfeather (otherwise they have to // include/link libflatbuffers.a) struct PrimitiveType { enum type { BOOL = 0, INT8 = 1, INT16 = 2, INT32 = 3, INT64 = 4, UINT8 = 5, UINT16 = 6, UINT32 = 7, UINT64 = 8, FLOAT = 9, DOUBLE = 10, UTF8 = 11, BINARY = 12 }; }; const int TYPE_BYTE_SIZE[] = { 1, // BOOL 1, // INT8 2, 4, 8, 1, // UINT8 2, 4, 8, // UINT64 4, // FLOAT 8, // DOUBLE 1, // UTF8 1 // BINARY }; static inline bool IsVariableLength(PrimitiveType::type type) { return type == PrimitiveType::UTF8 || type == PrimitiveType::BINARY; } static inline bool IsInteger(PrimitiveType::type type) { return (static_cast(type) >= static_cast(PrimitiveType::INT8)) && (static_cast(type) <= static_cast(PrimitiveType::UINT64)); } static inline int ByteSize(PrimitiveType::type type) { switch (type) { case PrimitiveType::BOOL: case PrimitiveType::INT8: case PrimitiveType::INT16: case PrimitiveType::INT32: case PrimitiveType::INT64: case PrimitiveType::UINT8: case PrimitiveType::UINT16: case PrimitiveType::UINT32: case PrimitiveType::UINT64: case PrimitiveType::FLOAT: case PrimitiveType::DOUBLE: case PrimitiveType::UTF8: case PrimitiveType::BINARY: return TYPE_BYTE_SIZE[static_cast(type)]; default: return 0; } } struct ColumnType { enum type { PRIMITIVE, CATEGORY, TIMESTAMP, DATE, TIME }; }; struct Encoding { enum type { PLAIN = 0, /// Data is stored dictionary-encoded /// dictionary size: /// dictionary data: /// dictionary index: /// /// TODO: do we care about storing the index values in a smaller typeclass DICTIONARY = 1 }; }; struct TimeUnit { enum type { SECOND = 0, MILLISECOND = 1, MICROSECOND = 2, NANOSECOND = 3 }; }; struct ArrayMetadata { ArrayMetadata() {} ArrayMetadata(PrimitiveType::type type, Encoding::type encoding, int64_t offset, int64_t length, int64_t null_count, int64_t total_bytes) : type(type), encoding(encoding), offset(offset), length(length), null_count(null_count), total_bytes(total_bytes) {} bool Equals(const ArrayMetadata& other) const; PrimitiveType::type type; Encoding::type encoding; int64_t offset; int64_t length; int64_t null_count; int64_t total_bytes; }; struct CategoryMetadata { ArrayMetadata levels; bool ordered; }; struct TimestampMetadata { TimeUnit::type unit; // A timezone name known to the Olson timezone database. For display purposes // because the actual data is all UTC std::string timezone; }; struct DateMetadata { }; struct TimeMetadata { TimeUnit::type unit; }; struct PrimitiveArray { PrimitiveType::type type; int64_t length; int64_t null_count; // For ownership of any memory attached to this array std::vector > buffers; // If null_count == 0, treated as nullptr const uint8_t* nulls; const uint8_t* values; // For UTF8 and BINARY, not used otherwise const int32_t* offsets; bool Equals(const PrimitiveArray& other) const; }; struct CategoryArray { PrimitiveArray indices; PrimitiveArray levels; bool ordered; }; struct DictEncodedArray { PrimitiveArray dict_values; PrimitiveArray indices; }; } // namespace feather #endif // FEATHER_TYPES_H feather-format-0.3.1/src/feather/metadata.cc0000664000175100017510000003516112756750540020710 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include "feather/metadata.h" #include #include "feather/buffer.h" #include "feather/common.h" #include "feather/metadata_generated.h" #include "feather/status.h" namespace feather { namespace metadata { typedef flatbuffers::FlatBufferBuilder FBB; typedef flatbuffers::Offset FBString; typedef std::vector> ColumnVector; // ---------------------------------------------------------------------- // Primitive array const fbs::Type TYPE_FB_TO_FEATHER[] = { fbs::Type_BOOL, fbs::Type_INT8, fbs::Type_INT16, fbs::Type_INT32, fbs::Type_INT64, fbs::Type_UINT8, fbs::Type_UINT16, fbs::Type_UINT32, fbs::Type_UINT64, fbs::Type_FLOAT, fbs::Type_DOUBLE, fbs::Type_UTF8, fbs::Type_BINARY, fbs::Type_CATEGORY, fbs::Type_TIMESTAMP, fbs::Type_DATE, fbs::Type_TIME }; static inline fbs::Type ToFlatbufferEnum(PrimitiveType::type type) { return TYPE_FB_TO_FEATHER[type]; } static inline PrimitiveType::type FromFlatbufferEnum(fbs::Type type) { return static_cast(static_cast(type)); } const fbs::Encoding ENCODING_ENUM_MAPPING[] = { fbs::Encoding_PLAIN, fbs::Encoding_DICTIONARY }; static inline fbs::Encoding ToFlatbufferEnum(Encoding::type encoding) { return ENCODING_ENUM_MAPPING[encoding]; } static inline Encoding::type FromFlatbufferEnum(fbs::Encoding enc) { return static_cast(static_cast(enc)); } static inline ColumnType::type ColumnTypeFromFB(fbs::TypeMetadata type) { switch (type) { case fbs::TypeMetadata_CategoryMetadata: return ColumnType::CATEGORY; case fbs::TypeMetadata_TimestampMetadata: return ColumnType::TIMESTAMP; case fbs::TypeMetadata_DateMetadata: return ColumnType::DATE; case fbs::TypeMetadata_TimeMetadata: return ColumnType::TIME; default: return ColumnType::PRIMITIVE; } } static inline fbs::TimeUnit ToFlatbufferEnum(TimeUnit::type unit) { return static_cast(static_cast(unit)); } static inline TimeUnit::type FromFlatbufferEnum(fbs::TimeUnit unit) { return static_cast(static_cast(unit)); } static inline flatbuffers::Offset GetPrimitiveArray( FBB& fbb, const ArrayMetadata& array) { return fbs::CreatePrimitiveArray(fbb, ToFlatbufferEnum(array.type), ToFlatbufferEnum(array.encoding), array.offset, array.length, array.null_count, array.total_bytes); } // Convert Feather enums to Flatbuffer enums const fbs::TypeMetadata COLUMN_TYPE_ENUM_MAPPING[] = { fbs::TypeMetadata_NONE, // PRIMITIVE fbs::TypeMetadata_CategoryMetadata, // CATEGORY fbs::TypeMetadata_TimestampMetadata, // TIMESTAMP fbs::TypeMetadata_DateMetadata, // DATE fbs::TypeMetadata_TimeMetadata // TIME }; fbs::TypeMetadata ToFlatbufferEnum(ColumnType::type column_type) { return COLUMN_TYPE_ENUM_MAPPING[column_type]; } // ---------------------------------------------------------------------- // TableBuilder class TableBuilder::Impl { public: explicit Impl(int64_t num_rows) : finished_(false), num_rows_(num_rows) {} FBB& fbb() { return fbb_; } Status Finish() { if (finished_) { return Status::Invalid("can only call this once"); } FBString desc = 0; if (!description_.empty()) { desc = fbb_.CreateString(description_); } flatbuffers::Offset metadata = 0; auto root = fbs::CreateCTable(fbb_, desc, num_rows_, fbb_.CreateVector(columns_), kFeatherVersion, metadata); fbb_.Finish(root); finished_ = true; return Status::OK(); } void set_description(const std::string& description) { description_ = description; } void set_num_rows(int64_t num_rows) { num_rows_ = num_rows; } void add_column(const flatbuffers::Offset& col) { columns_.push_back(col); } private: flatbuffers::FlatBufferBuilder fbb_; ColumnVector columns_; bool finished_; std::string description_; int64_t num_rows_; }; TableBuilder::TableBuilder(int64_t num_rows) { impl_.reset(new Impl(num_rows)); } TableBuilder::TableBuilder() { impl_.reset(new Impl(0)); } std::shared_ptr TableBuilder::GetBuffer() const { return std::make_shared(impl_->fbb().GetBufferPointer(), static_cast(impl_->fbb().GetSize())); } std::unique_ptr TableBuilder::AddColumn(const std::string& name) { return std::unique_ptr(new ColumnBuilder(this, name)); } void TableBuilder::SetDescription(const std::string& description) { impl_->set_description(description); } void TableBuilder::SetNumRows(int64_t num_rows) { impl_->set_num_rows(num_rows); } void TableBuilder::Finish() { impl_->Finish(); } // ---------------------------------------------------------------------- // ColumnBuilder class ColumnBuilder::Impl { public: Impl(FBB* builder, const std::string& name) : name_(name), type_(ColumnType::PRIMITIVE) { fbb_ = builder; } flatbuffers::Offset CreateColumnMetadata() { switch (type_) { case ColumnType::PRIMITIVE: // flatbuffer void return 0; case ColumnType::CATEGORY: { auto cat_meta = fbs::CreateCategoryMetadata(fbb(), GetPrimitiveArray(fbb(), meta_category_.levels), meta_category_.ordered); return cat_meta.Union(); } case ColumnType::TIMESTAMP: { // flatbuffer void flatbuffers::Offset tz = 0; if (!meta_timestamp_.timezone.empty()) { tz = fbb().CreateString(meta_timestamp_.timezone); } auto ts_meta = fbs::CreateTimestampMetadata(fbb(), ToFlatbufferEnum(meta_timestamp_.unit), tz); return ts_meta.Union(); } case ColumnType::DATE: { auto date_meta = fbs::CreateDateMetadata(fbb()); return date_meta.Union(); } case ColumnType::TIME: { auto time_meta = fbs::CreateTimeMetadata(fbb(), ToFlatbufferEnum(meta_time_.unit)); return time_meta.Union(); } default: // null return flatbuffers::Offset(); } } flatbuffers::Offset Finish() { FBB& buf = fbb(); // values auto values = GetPrimitiveArray(buf, values_); flatbuffers::Offset metadata = CreateColumnMetadata(); return fbs::CreateColumn(buf, buf.CreateString(name_), values, ToFlatbufferEnum(type_), // metadata_type metadata, buf.CreateString(user_metadata_)); } void set_values(const ArrayMetadata& values) { values_ = values; } void set_user_metadata(const std::string& data) { user_metadata_ = data; } void set_category(const ArrayMetadata& levels, bool ordered) { type_ = ColumnType::CATEGORY; meta_category_.levels = levels; meta_category_.ordered = ordered; } void set_timestamp(TimeUnit::type unit) { type_ = ColumnType::TIMESTAMP; meta_timestamp_.unit = unit; } void set_timestamp(TimeUnit::type unit, const std::string& timezone) { set_timestamp(unit); meta_timestamp_.timezone = timezone; } void set_date() { type_ = ColumnType::DATE; } void set_time(TimeUnit::type unit) { type_ = ColumnType::TIME; meta_time_.unit = unit; } FBB& fbb() { return *fbb_; } private: std::string name_; ArrayMetadata values_; std::string user_metadata_; // Column metadata // Is this a primitive type, or one of the types having metadata? Default is // primitive ColumnType::type type_; // Type-specific metadata union CategoryMetadata meta_category_; // DateMetadata meta_date_; // not used? TimeMetadata meta_time_; TimestampMetadata meta_timestamp_; FBB* fbb_; }; void ColumnBuilder::Finish() { auto result = impl_->Finish(); // horrible coupling, but can clean this up later parent_->impl_->add_column(result); } ColumnBuilder::ColumnBuilder(TableBuilder* parent, const std::string& name) : parent_(parent) { impl_.reset(new Impl(&parent->impl_->fbb(), name)); } ColumnBuilder::~ColumnBuilder() {} void ColumnBuilder::SetValues(const ArrayMetadata& values) { impl_->set_values(values); } void ColumnBuilder::SetUserMetadata(const std::string& data) { impl_->set_user_metadata(data); } void ColumnBuilder::SetCategory(const ArrayMetadata& levels, bool ordered) { impl_->set_category(levels, ordered); } void ColumnBuilder::SetTimestamp(TimeUnit::type unit) { impl_->set_timestamp(unit); } void ColumnBuilder::SetTimestamp(TimeUnit::type unit, const std::string& timezone) { impl_->set_timestamp(unit, timezone); } void ColumnBuilder::SetDate() { impl_->set_date(); } void ColumnBuilder::SetTime(TimeUnit::type unit) { impl_->set_time(unit); } // ---------------------------------------------------------------------- // Table bool Table::Open(const std::shared_ptr& buffer) { buffer_ = buffer; // Verify the buffer // Initiatilize the Flatbuffer interface table_ = static_cast(fbs::GetCTable(buffer->data())); return true; } std::string Table::description() const { if (!has_description()) { return std::string(""); } const fbs::CTable* table = static_cast(table_); return table->description()->str(); } bool Table::has_description() const { // null represented as 0 flatbuffer offset const fbs::CTable* table = static_cast(table_); return table->description() != 0; } int64_t Table::num_rows() const { const fbs::CTable* table = static_cast(table_); return table->num_rows(); } int Table::version() const { const fbs::CTable* table = static_cast(table_); return table->version(); } size_t Table::num_columns() const { const fbs::CTable* table = static_cast(table_); return table->columns()->size(); } std::shared_ptr Table::GetColumn(int i) const { const fbs::CTable* table = static_cast(table_); const fbs::Column* col = table->columns()->Get(i); // Construct the right column wrapper for the logical type switch (col->metadata_type()) { case fbs::TypeMetadata_NONE: return Column::Make(col); case fbs::TypeMetadata_CategoryMetadata: return CategoryColumn::Make(col); case fbs::TypeMetadata_TimestampMetadata: return TimestampColumn::Make(col); case fbs::TypeMetadata_DateMetadata: return DateColumn::Make(col); case fbs::TypeMetadata_TimeMetadata: return TimeColumn::Make(col); default: break; } // suppress compiler warning return std::shared_ptr(); } std::shared_ptr Table::GetColumnNamed(const std::string& name) const { // Not yet implemented return std::shared_ptr(); } // ---------------------------------------------------------------------- // Column void FromFlatbuffer(const fbs::PrimitiveArray* values, ArrayMetadata& out) { out.type = FromFlatbufferEnum(values->type()); out.encoding = FromFlatbufferEnum(values->encoding()); out.offset = values->offset(); out.length = values->length(); out.null_count = values->null_count(); out.total_bytes = values->total_bytes(); } void Column::Init(const void* fbs_column) { const fbs::Column* column = static_cast(fbs_column); name_ = column->name()->str(); type_ = ColumnTypeFromFB(column->metadata_type()); FromFlatbuffer(column->values(), values_); auto user_meta = column->user_metadata(); if (user_meta->size() > 0) { user_metadata_ = user_meta->str(); } } std::shared_ptr Column::Make(const void* fbs_column) { auto result = std::make_shared(); result->Init(fbs_column); return result; } std::string Column::name() const { return name_; } ColumnType::type Column::type() const { return type_; } PrimitiveType::type Column::values_type() const { return values_.type; } std::string Column::user_metadata() const { return user_metadata_; } // ---------------------------------------------------------------------- // Category column std::shared_ptr CategoryColumn::Make(const void* fbs_column) { const fbs::Column* column = static_cast(fbs_column); auto result = std::make_shared(); result->Init(fbs_column); // Category metadata auto meta = static_cast(column->metadata()); FromFlatbuffer(meta->levels(), result->metadata_.levels); result->metadata_.ordered = meta->ordered(); return result; } // ---------------------------------------------------------------------- // Timestamp column std::shared_ptr TimestampColumn::Make(const void* fbs_column) { const fbs::Column* column = static_cast(fbs_column); auto result = std::make_shared(); result->Init(fbs_column); auto meta = static_cast(column->metadata()); result->metadata_.unit = FromFlatbufferEnum(meta->unit()); auto tz = meta->timezone(); // flatbuffer non-null if (tz != 0) { result->metadata_.timezone = tz->str(); } else { result->metadata_.timezone = ""; } return result; } TimeUnit::type TimestampColumn::unit() const { return metadata_.unit; } std::string TimestampColumn::timezone() const { return metadata_.timezone; } // ---------------------------------------------------------------------- // Date column std::shared_ptr DateColumn::Make(const void* fbs_column) { auto result = std::make_shared(); result->Init(fbs_column); return result; } std::shared_ptr TimeColumn::Make(const void* fbs_column) { const fbs::Column* column = static_cast(fbs_column); auto result = std::make_shared(); result->Init(fbs_column); auto meta = static_cast(column->metadata()); result->metadata_.unit = FromFlatbufferEnum(meta->unit()); return result; } TimeUnit::type TimeColumn::unit() const { return metadata_.unit; } } // namespace metadata } // namespace feather feather-format-0.3.1/src/feather/status.h0000664000175100017510000000735113004702052020273 0ustar wesmwesm00000000000000// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. // // A Status encapsulates the result of an operation. It may indicate success, // or it may indicate an error with an associated error message. // // Multiple threads can invoke const methods on a Status without // external synchronization, but if any of the threads may call a // non-const method, all threads accessing the same Status must use // external synchronization. // Adapted from Kudu github.com/cloudera/kudu #ifndef FEATHER_STATUS_H_ #define FEATHER_STATUS_H_ #include #include #include namespace feather { #define RETURN_NOT_OK(s) do { \ Status _s = (s); \ if (!_s.ok()) return _s; \ } while (0); enum class StatusCode: char { OK = 0, OutOfMemory = 1, KeyError = 2, Invalid = 3, IOError = 4, NotImplemented = 10 }; class Status { public: // Create a success status. Status() : state_(NULL) { } ~Status() { delete[] state_; } // Copy the specified status. Status(const Status& s); void operator=(const Status& s); // Return a success status. static Status OK() { return Status(); } // Return error status of an appropriate type. static Status OutOfMemory(const std::string& msg, int16_t posix_code = -1) { return Status(StatusCode::OutOfMemory, msg, posix_code); } static Status KeyError(const std::string& msg) { return Status(StatusCode::KeyError, msg, -1); } static Status IOError(const std::string& msg) { return Status(StatusCode::IOError, msg, -1); } static Status NotImplemented(const std::string& msg) { return Status(StatusCode::NotImplemented, msg, -1); } static Status Invalid(const std::string& msg) { return Status(StatusCode::Invalid, msg, -1); } // Returns true iff the status indicates success. bool ok() const { return (state_ == NULL); } bool IsOutOfMemory() const { return code() == StatusCode::OutOfMemory; } bool IsKeyError() const { return code() == StatusCode::KeyError; } bool IsIOError() const { return code() == StatusCode::IOError; } bool IsInvalid() const { return code() == StatusCode::Invalid; } bool IsNotImplemented() const { return code() == StatusCode::NotImplemented; } // Return a string representation of this status suitable for printing. // Returns the string "OK" for success. std::string ToString() const; // Return a string representation of the status code, without the message // text or posix code information. std::string CodeAsString() const; // Get the POSIX code associated with this Status, or -1 if there is none. int16_t posix_code() const; private: // OK status has a NULL state_. Otherwise, state_ is a new[] array // of the following form: // state_[0..3] == length of message // state_[4] == code // state_[5..6] == posix_code // state_[7..] == message const char* state_; StatusCode code() const { return ((state_ == NULL) ? StatusCode::OK : static_cast(state_[4])); } Status(StatusCode code, const std::string& msg, int16_t posix_code); static const char* CopyState(const char* s); }; inline Status::Status(const Status& s) { state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_); } inline void Status::operator=(const Status& s) { // The following condition catches both aliasing (when this == &s), // and the common case where both s and *this are ok. if (state_ != s.state_) { delete[] state_; state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_); } } } // namespace feather #endif // FEATHER_STATUS_H_ feather-format-0.3.1/src/feather/io.cc0000664000175100017510000003377613004772706017544 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifdef _FILE_OFFSET_BITS #undef _FILE_OFFSET_BITS #endif #define _FILE_OFFSET_BITS 64 #include "feather/io.h" #if _WIN32 || _WIN64 #if _WIN64 #define ENVIRONMENT64 #else #define ENVIRONMENT32 #endif #endif // sys/mman.h not present in Visual Studio or Cygwin #ifdef _WIN32 #ifndef NOMINMAX #define NOMINMAX #endif #include "feather/mman.h" #undef Realloc #undef Free #include #else #include #endif #include #include #include #ifndef _MSC_VER // POSIX-like platforms #include #ifndef errno_t #define errno_t int #endif #endif // defines that #if defined(__MINGW32__) #define FEATHER_WRITE_SHMODE S_IRUSR | S_IWUSR #elif defined(_MSC_VER) // Visual Studio #else // gcc / clang on POSIX platforms #define FEATHER_WRITE_SHMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH #endif // ---------------------------------------------------------------------- // Standard library #include #include #include #include #include #include #if defined(_MSC_VER) #include #include #endif // ---------------------------------------------------------------------- // file compatibility stuff #if defined(__MINGW32__) // MinGW // nothing #elif defined(_MSC_VER) // Visual Studio #include #else // POSIX / Linux // nothing #endif #include // POSIX systems do not have this #ifndef O_BINARY #define O_BINARY 0 #endif // ---------------------------------------------------------------------- // other feather includes #include "feather/buffer.h" #include "feather/common.h" #include "feather/status.h" namespace feather { // ---------------------------------------------------------------------- // Buffer and its subclasses // ---------------------------------------------------------------------- // BufferReader Status RandomAccessReader::ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out) { // TODO(wesm): boundchecking RETURN_NOT_OK(Seek(position)); return Read(nbytes, out); } BufferReader::BufferReader(const std::shared_ptr& buffer) : buffer_(buffer), data_(buffer->data()), pos_(0) { size_ = buffer->size(); } Status BufferReader::Tell(int64_t* pos) const { *pos = pos_; return Status::OK(); } Status BufferReader::Seek(int64_t pos) { if (pos < 0 || pos >= size_) { std::stringstream ss; ss << "Cannot seek to " << pos << "File is length " << size_; return Status::IOError(ss.str()); } pos_ = pos; return Status::OK(); } Status BufferReader::Read(int64_t nbytes, std::shared_ptr* out) { int64_t bytes_available = std::min(nbytes, size_ - pos_); *out = std::make_shared(Head(), bytes_available); pos_ += bytes_available; return Status::OK(); } // ---------------------------------------------------------------------- // Cross-platform file compatability layer static inline Status CheckOpenResult(int ret, int errno_actual, const char* filename, size_t filename_length) { if (ret == -1) { // TODO: errno codes to strings std::stringstream ss; ss << "Failed to open file: "; #if defined(_MSC_VER) // using wchar_t // this requires c++11 std::wstring_convert, wchar_t> converter; std::wstring wide_string(reinterpret_cast(filename), filename_length / sizeof(wchar_t)); std::string byte_string = converter.to_bytes(wide_string); ss << byte_string; #else ss << filename; #endif return Status::IOError(ss.str()); } return Status::OK(); } #define CHECK_LSEEK(retval) \ if ((retval) == -1) return Status::IOError("lseek failed"); static inline int64_t lseek64_compat(int fd, int64_t pos, int whence) { #if defined(_MSC_VER) return _lseeki64(fd, pos, whence); #else return lseek(fd, pos, whence); #endif } static inline Status FileOpenReadable(const std::string& filename, int* fd) { int ret; errno_t errno_actual = 0; #if defined(_MSC_VER) // https://msdn.microsoft.com/en-us/library/w64k0ytk.aspx // See GH #209. Here we are assuming that the filename has been encoded in // utf-16le so that unicode filenames can be supported const int nwchars = static_cast(filename.size()) / sizeof(wchar_t); std::vector wpath(nwchars + 1); memcpy(wpath.data(), filename.data(), filename.size()); memcpy(wpath.data() + nwchars, L"\0", sizeof(wchar_t)); errno_actual = _wsopen_s(fd, wpath.data(), _O_RDONLY | _O_BINARY, _SH_DENYNO, _S_IREAD); ret = *fd; #else ret = *fd = open(filename.c_str(), O_RDONLY | O_BINARY); errno_actual = errno; #endif return CheckOpenResult(ret, errno_actual, filename.c_str(), filename.size()); } static inline Status FileOpenWriteable(const std::string& filename, int* fd) { int ret; errno_t errno_actual = 0; #if defined(_MSC_VER) // https://msdn.microsoft.com/en-us/library/w64k0ytk.aspx // Same story with wchar_t as above const int nwchars = static_cast(filename.size()) / sizeof(wchar_t); std::vector wpath(nwchars + 1); memcpy(wpath.data(), filename.data(), filename.size()); memcpy(wpath.data() + nwchars, L"\0", sizeof(wchar_t)); errno_actual = _wsopen_s(fd, wpath.data(), _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC, _SH_DENYNO, _S_IWRITE); ret = *fd; #else ret = *fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_BINARY | O_TRUNC, FEATHER_WRITE_SHMODE); #endif return CheckOpenResult(ret, errno_actual, filename.c_str(), filename.size()); } static inline Status FileTell(int fd, int64_t* pos) { int64_t current_pos; #if defined(_MSC_VER) current_pos = _telli64(fd); if (current_pos == -1) { return Status::IOError("_telli64 failed"); } #else current_pos = lseek64_compat(fd, 0, SEEK_CUR); CHECK_LSEEK(current_pos); #endif *pos = current_pos; return Status::OK(); } static inline Status FileSeek(int fd, int64_t pos) { int64_t ret = lseek64_compat(fd, pos, SEEK_SET); CHECK_LSEEK(ret); return Status::OK(); } static inline Status FileRead(int fd, uint8_t* buffer, int64_t nbytes, int64_t* bytes_read) { #if defined(_MSC_VER) if (nbytes > INT32_MAX) { return Status::IOError("Unable to read > 2GB blocks yet"); } *bytes_read = _read(fd, buffer, static_cast(nbytes)); #else *bytes_read = read(fd, buffer, nbytes); #endif if (*bytes_read == -1) { // TODO(wesm): errno to string return Status::IOError("Error reading bytes from file"); } return Status::OK(); } static inline Status FileWrite(int fd, const uint8_t* buffer, int64_t nbytes) { int ret; #if defined(_MSC_VER) if (nbytes > INT32_MAX) { return Status::IOError("Unable to write > 2GB blocks to file yet"); } ret = _write(fd, buffer, static_cast(nbytes)); #else ret = write(fd, buffer, nbytes); #endif if (ret == -1) { // TODO(wesm): errno to string return Status::IOError("Error writing bytes to file"); } return Status::OK(); } static inline Status FileGetSize(int fd, int64_t* size) { int64_t ret; // Save current position int64_t current_position = lseek64_compat(fd, 0, SEEK_CUR); CHECK_LSEEK(current_position); // move to end of the file ret = lseek64_compat(fd, 0, SEEK_END); CHECK_LSEEK(ret); // Get file length ret = lseek64_compat(fd, 0, SEEK_CUR); CHECK_LSEEK(ret); *size = ret; // Restore file position ret = lseek64_compat(fd, current_position, SEEK_SET); CHECK_LSEEK(ret); return Status::OK(); } static inline Status FileClose(int fd) { int ret; #if defined(_MSC_VER) ret = _close(fd); #else ret = close(fd); #endif if (ret == -1) { return Status::IOError("error closing file"); } return Status::OK(); } class FileInterface { public: FileInterface() : fd_(-1), is_open_(false), size_(-1) {} ~FileInterface() {} Status OpenWritable(const std::string& path) { RETURN_NOT_OK(FileOpenWriteable(path, &fd_)); path_ = path; is_open_ = true; return Status::OK(); } Status OpenReadable(const std::string& path) { RETURN_NOT_OK(FileOpenReadable(path, &fd_)); RETURN_NOT_OK(FileGetSize(fd_, &size_)); // The position should be 0 after GetSize // RETURN_NOT_OK(Seek(0)); path_ = path; is_open_ = true; return Status::OK(); } Status Close() { if (is_open_) { RETURN_NOT_OK(FileClose(fd_)); is_open_ = false; } return Status::OK(); } Status Read(int64_t nbytes, std::shared_ptr* out) { auto buffer = std::make_shared(); RETURN_NOT_OK(buffer->Resize(nbytes)); int64_t bytes_read = 0; RETURN_NOT_OK(FileRead(fd_, buffer->mutable_data(), nbytes, &bytes_read)); // heuristic if (bytes_read < nbytes / 2) { RETURN_NOT_OK(buffer->Resize(bytes_read)); } *out = buffer; return Status::OK(); } Status Seek(int64_t pos) { return FileSeek(fd_, pos); } Status Tell(int64_t* pos) const { return FileTell(fd_, pos); } Status Write(const uint8_t* data, int64_t length) { return FileWrite(fd_, data, length); } int fd() const { return fd_;} bool is_open() const { return is_open_;} const std::string& path() const { return path_;} int64_t size() const { return size_;} private: std::string path_; // File descriptor int fd_; bool is_open_; int64_t size_; }; // ---------------------------------------------------------------------- // LocalFileReader methods LocalFileReader::LocalFileReader() { impl_.reset(new FileInterface()); } LocalFileReader::~LocalFileReader() { CloseFile(); } Status LocalFileReader::Open(const std::string& path) { RETURN_NOT_OK(impl_->OpenReadable(path)); size_ = impl_->size(); return Status::OK(); } void LocalFileReader::CloseFile() { impl_->Close(); } Status LocalFileReader::Seek(int64_t pos) { return impl_->Seek(pos); } Status LocalFileReader::Tell(int64_t* pos) const { return impl_->Tell(pos); } Status LocalFileReader::Read(int64_t nbytes, std::shared_ptr* out) { return impl_->Read(nbytes, out); } // ---------------------------------------------------------------------- // MemoryMapReader methods MemoryMapReader::~MemoryMapReader() { CloseFile(); } Status MemoryMapReader::Open(const std::string& path) { RETURN_NOT_OK(LocalFileReader::Open(path)); #ifdef ENVIRONMENT32 if (size_ > std::numeric_limits::max()) { return Status::IOError("Cannot read files > 2 GB in 32-bit Windows"); } #endif void* ptr = mmap(nullptr, size_, PROT_READ, MAP_SHARED, impl_->fd(), 0); if (ptr == MAP_FAILED) { return Status::IOError("Memory mapping file failed"); } data_ = reinterpret_cast(ptr); pos_ = 0; return Status::OK(); } void MemoryMapReader::CloseFile() { if (data_ != nullptr) { munmap(data_, size_); } LocalFileReader::CloseFile(); } Status MemoryMapReader::Seek(int64_t pos) { pos_ = pos; return Status::OK(); } Status MemoryMapReader::Tell(int64_t* pos) const { *pos = pos_; return Status::OK(); } Status MemoryMapReader::Read(int64_t nbytes, std::shared_ptr* out) { nbytes = std::min(nbytes, size_ - pos_); *out = std::shared_ptr(new Buffer(data_ + pos_, nbytes)); return Status::OK(); } // ---------------------------------------------------------------------- // Generic output stream static const uint8_t kPaddingBytes[kFeatherDefaultAlignment] = {0}; Status OutputStream::WritePadded(const uint8_t* data, int64_t length, int64_t* bytes_written) { RETURN_NOT_OK(Write(data, length)); int64_t remainder = PaddedLength(length) - length; if (remainder != 0) { RETURN_NOT_OK(Write(kPaddingBytes, remainder)); } *bytes_written = length + remainder; return Status::OK(); } // ---------------------------------------------------------------------- // In-memory output stream InMemoryOutputStream::InMemoryOutputStream(int64_t initial_capacity) : size_(0), capacity_(initial_capacity) { if (initial_capacity == 0) { initial_capacity = 1024; } buffer_.reset(new OwnedMutableBuffer()); buffer_->Resize(initial_capacity); } Status InMemoryOutputStream::Close() { return Status::OK(); } uint8_t* InMemoryOutputStream::Head() { return buffer_->mutable_data() + size_; } Status InMemoryOutputStream::Write(const uint8_t* data, int64_t length) { if (size_ + length > capacity_) { int64_t new_capacity = capacity_ * 2; while (new_capacity < size_ + length) { new_capacity *= 2; } RETURN_NOT_OK(buffer_->Resize(new_capacity)); capacity_ = new_capacity; } memcpy(Head(), data, length); size_ += length; return Status::OK(); } Status InMemoryOutputStream::Tell(int64_t* pos) const { *pos = size_; return Status::OK(); } std::shared_ptr InMemoryOutputStream::Finish() { buffer_->Resize(size_); std::shared_ptr result = buffer_; buffer_.reset(); // TODO(wesm): raise exceptions if user calls Write after Finish size_ = 0; capacity_ = 0; return result; } // ---------------------------------------------------------------------- // FileOutputStream FileOutputStream::FileOutputStream() { impl_.reset(new FileInterface()); } FileOutputStream::~FileOutputStream() {} Status FileOutputStream::Open(const std::string& path) { return impl_->OpenWritable(path); } Status FileOutputStream::Close() { return impl_->Close(); } Status FileOutputStream::Tell(int64_t* pos) const { return impl_->Tell(pos); } Status FileOutputStream::Write(const uint8_t* data, int64_t length) { return impl_->Write(data, length); } } // namespace feather feather-format-0.3.1/src/feather/reader.cc0000664000175100017510000001545112756750540020372 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include "feather/reader.h" #include #include #include #include "feather/buffer.h" #include "feather/common.h" #include "feather/io.h" #include "feather/status.h" namespace feather { TableReader::TableReader() {} Status TableReader::Open(const std::shared_ptr& source) { source_ = source; int magic_size = static_cast(strlen(FEATHER_MAGIC_BYTES)); int footer_size = magic_size + sizeof(uint32_t); // Pathological issue where the file is smaller than if (source->size() < magic_size + footer_size) { return Status::Invalid("File is too small to be a well-formed file"); } std::shared_ptr buffer; RETURN_NOT_OK(source->Read(magic_size, &buffer)); if (memcmp(buffer->data(), FEATHER_MAGIC_BYTES, magic_size)) { return Status::Invalid("Not a feather file"); } // Now get the footer and verify RETURN_NOT_OK(source->ReadAt(source->size() - footer_size, footer_size, &buffer)); if (memcmp(buffer->data() + sizeof(uint32_t), FEATHER_MAGIC_BYTES, magic_size)) { return Status::Invalid("Feather file footer incomplete"); } uint32_t metadata_length = *reinterpret_cast(buffer->data()); if (source->size() < magic_size + footer_size + metadata_length) { return Status::Invalid("File is smaller than indicated metadata size"); } RETURN_NOT_OK(source->ReadAt(source->size() - footer_size - metadata_length, metadata_length, &buffer)); if (!metadata_.Open(buffer)) { return Status::Invalid("Invalid file metadata"); } if (metadata_.version() < kFeatherVersion) { std::cout << "This Feather file is old" << " and will not be readable beyond the 0.3.0 release" << std::endl; } return Status::OK(); } Status TableReader::OpenFile(const std::string& abspath, std::unique_ptr* out) { auto reader = std::unique_ptr(new MemoryMapReader()); RETURN_NOT_OK(reader->Open(abspath)); std::shared_ptr source(reader.release()); out->reset(new TableReader()); return (*out)->Open(source); } bool TableReader::HasDescription() const { return metadata_.has_description(); } std::string TableReader::GetDescription() const { return metadata_.description(); } int TableReader::version() const { return metadata_.version(); } int64_t TableReader::num_rows() const { return metadata_.num_rows(); } int64_t TableReader::num_columns() const { return metadata_.num_columns(); } // XXX: Hack for Feather 0.3.0 for backwards compatibility with old files // Size in-file of written byte buffer static int64_t GetOutputLength(int64_t nbytes) { if (kFeatherVersion < 2) { // Feather files < 0.3.0 return nbytes; } else { return PaddedLength(nbytes); } } Status TableReader::GetPrimitiveArray(const ArrayMetadata& meta, PrimitiveArray* out) const { // Buffer data from the source (may or may not perform a copy depending on // input source) std::shared_ptr buffer; RETURN_NOT_OK(source_->ReadAt(meta.offset, meta.total_bytes, &buffer)); const uint8_t* data = buffer->data(); // If there are nulls, the null bitmask is first if (meta.null_count > 0) { out->nulls = data; data += GetOutputLength(util::bytes_for_bits(meta.length)); } else { out->nulls = nullptr; } if (IsVariableLength(meta.type)) { out->offsets = reinterpret_cast(data); data += GetOutputLength((meta.length + 1) * sizeof(int32_t)); } // TODO(wesm): dictionary encoded values // The value bytes are last out->values = data; out->type = meta.type; out->length = meta.length; out->null_count = meta.null_count; // Hold on to this data out->buffers.push_back(buffer); return Status::OK(); } Status TableReader::GetPrimitive(std::shared_ptr col_meta, std::unique_ptr* out) const { auto values_meta = col_meta->values(); PrimitiveArray values; RETURN_NOT_OK(GetPrimitiveArray(values_meta, &values)); out->reset(new Column(col_meta->type(), col_meta, values)); return Status::OK(); } Status TableReader::GetCategory(std::shared_ptr col_meta, std::unique_ptr* out) const { PrimitiveArray values, levels; auto cat_meta = static_cast(col_meta.get()); auto values_meta = cat_meta->values(); RETURN_NOT_OK(GetPrimitiveArray(values_meta, &values)); auto levels_meta = cat_meta->levels(); RETURN_NOT_OK(GetPrimitiveArray(levels_meta, &levels)); out->reset(new CategoryColumn(col_meta, values, levels, cat_meta->ordered())); return Status::OK(); } Status TableReader::GetTimestamp(std::shared_ptr col_meta, std::unique_ptr* out) const { PrimitiveArray values; auto ts_meta = static_cast(col_meta.get()); auto values_meta = ts_meta->values(); RETURN_NOT_OK(GetPrimitiveArray(values_meta, &values)); out->reset(new TimestampColumn(col_meta, values)); return Status::OK(); } Status TableReader::GetTime(std::shared_ptr col_meta, std::unique_ptr* out) const { PrimitiveArray values; auto time_meta = static_cast(col_meta.get()); auto values_meta = time_meta->values(); RETURN_NOT_OK(GetPrimitiveArray(values_meta, &values)); out->reset(new TimeColumn(col_meta, values)); return Status::OK(); } Status TableReader::GetColumn(int i, std::unique_ptr* out) const { std::shared_ptr col_meta = metadata_.GetColumn(i); switch (col_meta->type()) { case ColumnType::PRIMITIVE: RETURN_NOT_OK(GetPrimitive(col_meta, out)); break; case ColumnType::CATEGORY: RETURN_NOT_OK(GetCategory(col_meta, out)); break; case ColumnType::TIMESTAMP: RETURN_NOT_OK(GetTimestamp(col_meta, out)); break; case ColumnType::DATE: RETURN_NOT_OK(GetPrimitive(col_meta, out)); break; case ColumnType::TIME: RETURN_NOT_OK(GetTime(col_meta, out)); break; default: out->reset(nullptr); break; } return Status::OK(); } Status TableReader::GetColumnMetadata(int i, std::shared_ptr* out) const { *out = metadata_.GetColumn(i); return Status::OK(); } } // namespace feather feather-format-0.3.1/src/feather/common.h0000664000175100017510000000355313004702052020240 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_COMMON_H #define FEATHER_COMMON_H #include "feather/compatibility.h" namespace feather { static constexpr const char* FEATHER_MAGIC_BYTES = "FEA1"; static constexpr const int kFeatherDefaultAlignment = 8; static constexpr const int kFeatherVersion = 2; static inline int64_t PaddedLength(int64_t nbytes) { static const int64_t alignment = kFeatherDefaultAlignment; return ((nbytes + alignment - 1) / alignment) * alignment; } namespace util { static inline size_t ceil_byte(size_t size) { return (size + 7) & ~7; } static inline int64_t bytes_for_bits(int64_t size) { return ((size + 7) & ~7) / 8; } static constexpr uint8_t BITMASK[] = {1, 2, 4, 8, 16, 32, 64, 128}; static inline bool get_bit(const uint8_t* bits, int i) { return (bits[i / 8] & BITMASK[i % 8]) != 0; } static inline bool bit_not_set(const uint8_t* bits, int i) { return (bits[i / 8] & BITMASK[i % 8]) == 0; } static inline void clear_bit(uint8_t* bits, int i) { bits[i / 8] &= ~BITMASK[i % 8]; } static inline void set_bit(uint8_t* bits, int i) { bits[i / 8] |= BITMASK[i % 8]; } static inline void* fill_buffer(void* buffer, int value, size_t n) { if (buffer && n) ::memset(buffer, value, n); return buffer; } } // namespace util } // namespace feather #endif // FEATHER_COMMON_H feather-format-0.3.1/src/feather/feather-c.cc0000664000175100017510000001326412756747223020772 0ustar wesmwesm00000000000000/* * Copyright 2016 Feather Developers * * 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. */ #include #include #include #include "feather/reader.h" #include "feather/types.h" #include "feather/writer.h" #include "feather/feather-c.h" using feather::Column; using feather::ColumnType; using feather::PrimitiveArray; using feather::PrimitiveType; using feather::Status; using feather::TableReader; using feather::TableWriter; static PrimitiveType::type FromCFeatherType(feather_type ctype) { return static_cast(static_cast(ctype)); } static feather_type ToCFeatherType(PrimitiveType::type type) { return static_cast(static_cast(type)); } static feather_column_type ToCFeatherColumnType(ColumnType::type type) { return static_cast(static_cast(type)); } static Status ToCFeatherArray(const PrimitiveArray& values, feather_array_t* out) { out->type = ToCFeatherType(values.type); out->length = values.length; out->null_count = values.null_count; out->nulls = values.nulls; out->values = values.values; out->offsets = values.offsets; return Status::OK(); } static Status FromCFeatherArray(feather_array_t* carr, PrimitiveArray* out) { out->type = FromCFeatherType(carr->type); out->length = carr->length; out->null_count = carr->null_count; out->nulls = carr->nulls; out->values = carr->values; out->offsets = carr->offsets; return Status::OK(); } #ifdef __cplusplus extern "C" { #if 0 /* confuse emacs indentation */ } #endif #endif static feather_status get_feather_status(const Status& s) { if (s.ok()) { return FEATHER_OK; } else if (s.IsOutOfMemory()) { return FEATHER_OOM; } else if (s.IsKeyError()) { return FEATHER_KEY_ERROR; } else if (s.IsInvalid()) { return FEATHER_INVALID; } else if (s.IsIOError()) { return FEATHER_IO_ERROR; } else if (s.IsNotImplemented()) { return FEATHER_NOT_IMPLEMENTED; } else { return FEATHER_UNKNOWN; } } #define FEATHER_CHECK_STATUS(s) do { \ Status _s = (s); \ if (!_s.ok()) return get_feather_status(_s); \ } while (0); #define FEATHER_CHECK_MALLOC(ptr) do { \ if ((ptr) == nullptr) { \ return FEATHER_OOM; \ } \ } while (0); /* Writer C API */ feather_status feather_writer_open_file(const char* path, feather_writer_t** out) { std::unique_ptr writer; try { std::string str_path(path); FEATHER_CHECK_STATUS(TableWriter::OpenFile(str_path, &writer)); } catch (const std::exception& e) { (void) e; return FEATHER_OOM; } *out = reinterpret_cast(writer.release()); return FEATHER_OK; } void feather_writer_set_num_rows(feather_writer_t* self, int64_t num_rows) { reinterpret_cast(self)->SetNumRows(num_rows); } feather_status feather_writer_append_plain(feather_writer_t* self, const char* name, feather_array_t* values) { TableWriter* writer = reinterpret_cast(self); PrimitiveArray cpp_values; FEATHER_CHECK_STATUS(FromCFeatherArray(values, &cpp_values)); try { std::string cpp_name(name); return get_feather_status(writer->AppendPlain(cpp_name, cpp_values)); } catch (const std::exception& e) { (void) e; return FEATHER_OOM; } } feather_status feather_writer_close(feather_writer_t* self) { return get_feather_status( reinterpret_cast(self)->Finalize()); } feather_status feather_writer_free(feather_writer_t* self) { delete reinterpret_cast(self); return FEATHER_OK; } /* Reader C API */ feather_status feather_column_free(feather_column_t* self) { delete reinterpret_cast(self->data); return FEATHER_OK; } feather_status feather_reader_open_file(const char* path, feather_reader_t** out) { std::unique_ptr reader; try { std::string str_path(path); FEATHER_CHECK_STATUS(TableReader::OpenFile(str_path, &reader)); } catch (const std::exception& e) { (void) e; return FEATHER_OOM; } *out = reinterpret_cast(reader.release()); return FEATHER_OK; } int64_t feather_reader_num_rows(feather_reader_t* self) { return reinterpret_cast(self)->num_rows(); } int64_t feather_reader_num_columns(feather_reader_t* self) { return reinterpret_cast(self)->num_columns(); } feather_status feather_reader_get_column(feather_reader_t* self, int i, feather_column_t* out) { TableReader* reader = reinterpret_cast(self); std::unique_ptr col; FEATHER_CHECK_STATUS(reader->GetColumn(i, &col)); out->type = ToCFeatherColumnType(col->type()); out->name = col->name().c_str(); FEATHER_CHECK_STATUS(ToCFeatherArray(col->values(), &out->values)); out->data = reinterpret_cast(col.release()); return FEATHER_OK; } feather_status feather_reader_close(feather_reader_t* self) { return FEATHER_OK; } feather_status feather_reader_free(feather_reader_t* self) { delete reinterpret_cast(self); return FEATHER_OK; } #ifdef __cplusplus #if 0 /* confuse emacs indentation */ { #endif } #endif feather-format-0.3.1/src/feather/buffer.h0000664000175100017510000000754312756747223020252 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_BUFFER_H #define FEATHER_BUFFER_H #include #include #include #include #include #include "feather/compatibility.h" #include "feather/status.h" namespace feather { class Status; // ---------------------------------------------------------------------- // Buffer classes // Immutable API for a chunk of bytes which may or may not be owned by the // class instance class Buffer : public std::enable_shared_from_this { public: Buffer(const uint8_t* data, int64_t size) : data_(data), size_(size) {} // An offset into data that is owned by another buffer, but we want to be // able to retain a valid pointer to it even after other shared_ptr's to the // parent buffer have been destroyed Buffer(const std::shared_ptr& parent, int64_t offset, int64_t size); std::shared_ptr get_shared_ptr() { return shared_from_this(); } const uint8_t* data() const { return data_; } int64_t size() const { return size_; } // Returns true if this Buffer is referencing memory (possibly) owned by some // other buffer bool is_shared() const { return static_cast(parent_); } const std::shared_ptr parent() const { return parent_; } protected: const uint8_t* data_; int64_t size_; // nullptr by default, but may be set std::shared_ptr parent_; }; // A Buffer whose contents can be mutated class MutableBuffer : public Buffer { public: MutableBuffer(uint8_t* data, int64_t size) : Buffer(data, size) { mutable_data_ = data; } uint8_t* mutable_data() { return mutable_data_; } // Get a read-only view of this buffer std::shared_ptr GetImmutableView(); protected: MutableBuffer() : Buffer(nullptr, 0), mutable_data_(nullptr) {} uint8_t* mutable_data_; }; // A MutableBuffer whose memory is owned by the class instance. For example, // for reading data out of files that you want to deallocate when this class is // garbage-collected class OwnedMutableBuffer : public MutableBuffer { public: OwnedMutableBuffer(); Status Resize(int64_t new_size); private: std::vector buffer_owner_; }; static constexpr int64_t MIN_BUFFER_CAPACITY = 1024; class BufferBuilder { public: BufferBuilder() : data_(nullptr), capacity_(0), size_(0) {} Status Append(const uint8_t* data, int length) { if (capacity_ < length + size_) { if (capacity_ == 0) { buffer_ = std::make_shared(); } capacity_ = std::max(MIN_BUFFER_CAPACITY, capacity_); while (capacity_ < length + size_) { capacity_ *= 2; } RETURN_NOT_OK(buffer_->Resize(capacity_)); data_ = buffer_->mutable_data(); } if (length > 0) { memcpy(data_ + size_, data, length); size_ += length; } return Status::OK(); } std::shared_ptr Finish() { std::shared_ptr result; if (data_ == nullptr) { result = std::make_shared(nullptr, 0); } else { result = buffer_; } buffer_.reset(); return result; } private: std::shared_ptr buffer_; uint8_t* data_; int64_t capacity_; int64_t size_; }; } // namespace feather #endif // FEATHER_BUFFER_H feather-format-0.3.1/src/feather/compatibility.h0000664000175100017510000000223112756747223021637 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_COMPATIBILITY_H_ #define FEATHER_COMPATIBILITY_H_ // Compatibility for older versions of gcc without full C++11 support #if defined(__GNUC__) && !defined(__clang__) # if __GNUC__ == 4 && __GNUC_MINOR__ < 6 # define FEATHER_CPP0X_COMPATIBLE # ifndef nullptr_t const class feather_nullptr_t { public: template inline operator T*() const { return 0; } private: void operator&() const; // NOLINT } nullptr = {}; # define nullptr_t feather_nullptr_t # endif # define constexpr # define override # endif #endif #endif /* FEATHER_COMPATIBILITY_H_ */ feather-format-0.3.1/src/feather/mman.h0000664000175100017510000001065012700356276017713 0ustar wesmwesm00000000000000// Copyright https://code.google.com/p/mman-win32/ // // Licensed under the MIT License; // You may obtain a copy of the License at // // https://opensource.org/licenses/MIT #ifndef _MMAN_WIN32_H #define _MMAN_WIN32_H // Allow use of features specific to Windows XP or later. #ifndef _WIN32_WINNT // Change this to the appropriate value to target other versions of Windows. #define _WIN32_WINNT 0x0501 #endif #include #include #include #include #define PROT_NONE 0 #define PROT_READ 1 #define PROT_WRITE 2 #define PROT_EXEC 4 #define MAP_FILE 0 #define MAP_SHARED 1 #define MAP_PRIVATE 2 #define MAP_TYPE 0xf #define MAP_FIXED 0x10 #define MAP_ANONYMOUS 0x20 #define MAP_ANON MAP_ANONYMOUS #define MAP_FAILED ((void *)-1) /* Flags for msync. */ #define MS_ASYNC 1 #define MS_SYNC 2 #define MS_INVALIDATE 4 #ifndef FILE_MAP_EXECUTE #define FILE_MAP_EXECUTE 0x0020 #endif static int __map_mman_error(const DWORD err, const int deferr) { if (err == 0) return 0; //TODO: implement return err; } static DWORD __map_mmap_prot_page(const int prot) { DWORD protect = 0; if (prot == PROT_NONE) return protect; if ((prot & PROT_EXEC) != 0) { protect = ((prot & PROT_WRITE) != 0) ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ; } else { protect = ((prot & PROT_WRITE) != 0) ? PAGE_READWRITE : PAGE_READONLY; } return protect; } static DWORD __map_mmap_prot_file(const int prot) { DWORD desiredAccess = 0; if (prot == PROT_NONE) return desiredAccess; if ((prot & PROT_READ) != 0) desiredAccess |= FILE_MAP_READ; if ((prot & PROT_WRITE) != 0) desiredAccess |= FILE_MAP_WRITE; if ((prot & PROT_EXEC) != 0) desiredAccess |= FILE_MAP_EXECUTE; return desiredAccess; } void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) { HANDLE fm, h; void * map = MAP_FAILED; #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4293) #endif const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)off : (DWORD)(off & 0xFFFFFFFFL); const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL); const DWORD protect = __map_mmap_prot_page(prot); const DWORD desiredAccess = __map_mmap_prot_file(prot); const off_t maxSize = off + (off_t)len; const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL); const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL); #ifdef _MSC_VER #pragma warning(pop) #endif errno = 0; if (len == 0 /* Unsupported flag combinations */ || (flags & MAP_FIXED) != 0 /* Usupported protection combinations */ || prot == PROT_EXEC) { errno = EINVAL; return MAP_FAILED; } h = ((flags & MAP_ANONYMOUS) == 0) ? (HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE; if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE) { errno = EBADF; return MAP_FAILED; } fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL); if (fm == NULL) { errno = __map_mman_error(GetLastError(), EPERM); return MAP_FAILED; } map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); CloseHandle(fm); if (map == NULL) { errno = __map_mman_error(GetLastError(), EPERM); return MAP_FAILED; } return map; } int munmap(void *addr, size_t len) { if (UnmapViewOfFile(addr)) return 0; errno = __map_mman_error(GetLastError(), EPERM); return -1; } int mprotect(void *addr, size_t len, int prot) { DWORD newProtect = __map_mmap_prot_page(prot); DWORD oldProtect = 0; if (VirtualProtect(addr, len, newProtect, &oldProtect)) return 0; errno = __map_mman_error(GetLastError(), EPERM); return -1; } int msync(void *addr, size_t len, int flags) { if (FlushViewOfFile(addr, len)) return 0; errno = __map_mman_error(GetLastError(), EPERM); return -1; } int mlock(const void *addr, size_t len) { if (VirtualLock((LPVOID)addr, len)) return 0; errno = __map_mman_error(GetLastError(), EPERM); return -1; } int munlock(const void *addr, size_t len) { if (VirtualUnlock((LPVOID)addr, len)) return 0; errno = __map_mman_error(GetLastError(), EPERM); return -1; } #endif feather-format-0.3.1/src/feather/metadata_generated.h0000664000175100017510000004442412750213352022557 0ustar wesmwesm00000000000000// automatically generated by the FlatBuffers compiler, do not modify #ifndef FLATBUFFERS_GENERATED_METADATA_FEATHER_FBS_H_ #define FLATBUFFERS_GENERATED_METADATA_FEATHER_FBS_H_ #include "flatbuffers/flatbuffers.h" namespace feather { namespace fbs { struct PrimitiveArray; struct CategoryMetadata; struct TimestampMetadata; struct DateMetadata; struct TimeMetadata; struct Column; struct CTable; enum Type { Type_BOOL = 0, Type_INT8 = 1, Type_INT16 = 2, Type_INT32 = 3, Type_INT64 = 4, Type_UINT8 = 5, Type_UINT16 = 6, Type_UINT32 = 7, Type_UINT64 = 8, Type_FLOAT = 9, Type_DOUBLE = 10, Type_UTF8 = 11, Type_BINARY = 12, Type_CATEGORY = 13, Type_TIMESTAMP = 14, Type_DATE = 15, Type_TIME = 16, Type_MIN = Type_BOOL, Type_MAX = Type_TIME }; inline const char **EnumNamesType() { static const char *names[] = { "BOOL", "INT8", "INT16", "INT32", "INT64", "UINT8", "UINT16", "UINT32", "UINT64", "FLOAT", "DOUBLE", "UTF8", "BINARY", "CATEGORY", "TIMESTAMP", "DATE", "TIME", nullptr }; return names; } inline const char *EnumNameType(Type e) { return EnumNamesType()[static_cast(e)]; } enum Encoding { Encoding_PLAIN = 0, /// Data is stored dictionary-encoded /// dictionary size: /// dictionary data: /// dictionary index: /// /// TODO: do we care about storing the index values in a smaller typeclass Encoding_DICTIONARY = 1, Encoding_MIN = Encoding_PLAIN, Encoding_MAX = Encoding_DICTIONARY }; inline const char **EnumNamesEncoding() { static const char *names[] = { "PLAIN", "DICTIONARY", nullptr }; return names; } inline const char *EnumNameEncoding(Encoding e) { return EnumNamesEncoding()[static_cast(e)]; } enum TimeUnit { TimeUnit_SECOND = 0, TimeUnit_MILLISECOND = 1, TimeUnit_MICROSECOND = 2, TimeUnit_NANOSECOND = 3, TimeUnit_MIN = TimeUnit_SECOND, TimeUnit_MAX = TimeUnit_NANOSECOND }; inline const char **EnumNamesTimeUnit() { static const char *names[] = { "SECOND", "MILLISECOND", "MICROSECOND", "NANOSECOND", nullptr }; return names; } inline const char *EnumNameTimeUnit(TimeUnit e) { return EnumNamesTimeUnit()[static_cast(e)]; } enum TypeMetadata { TypeMetadata_NONE = 0, TypeMetadata_CategoryMetadata = 1, TypeMetadata_TimestampMetadata = 2, TypeMetadata_DateMetadata = 3, TypeMetadata_TimeMetadata = 4, TypeMetadata_MIN = TypeMetadata_NONE, TypeMetadata_MAX = TypeMetadata_TimeMetadata }; inline const char **EnumNamesTypeMetadata() { static const char *names[] = { "NONE", "CategoryMetadata", "TimestampMetadata", "DateMetadata", "TimeMetadata", nullptr }; return names; } inline const char *EnumNameTypeMetadata(TypeMetadata e) { return EnumNamesTypeMetadata()[static_cast(e)]; } inline bool VerifyTypeMetadata(flatbuffers::Verifier &verifier, const void *union_obj, TypeMetadata type); struct PrimitiveArray FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_TYPE = 4, VT_ENCODING = 6, VT_OFFSET = 8, VT_LENGTH = 10, VT_NULL_COUNT = 12, VT_TOTAL_BYTES = 14 }; Type type() const { return static_cast(GetField(VT_TYPE, 0)); } Encoding encoding() const { return static_cast(GetField(VT_ENCODING, 0)); } /// Relative memory offset of the start of the array data excluding the size /// of the metadata int64_t offset() const { return GetField(VT_OFFSET, 0); } /// The number of logical values in the array int64_t length() const { return GetField(VT_LENGTH, 0); } /// The number of observed nulls int64_t null_count() const { return GetField(VT_NULL_COUNT, 0); } /// The total size of the actual data in the file int64_t total_bytes() const { return GetField(VT_TOTAL_BYTES, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_TYPE) && VerifyField(verifier, VT_ENCODING) && VerifyField(verifier, VT_OFFSET) && VerifyField(verifier, VT_LENGTH) && VerifyField(verifier, VT_NULL_COUNT) && VerifyField(verifier, VT_TOTAL_BYTES) && verifier.EndTable(); } }; struct PrimitiveArrayBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_type(Type type) { fbb_.AddElement(PrimitiveArray::VT_TYPE, static_cast(type), 0); } void add_encoding(Encoding encoding) { fbb_.AddElement(PrimitiveArray::VT_ENCODING, static_cast(encoding), 0); } void add_offset(int64_t offset) { fbb_.AddElement(PrimitiveArray::VT_OFFSET, offset, 0); } void add_length(int64_t length) { fbb_.AddElement(PrimitiveArray::VT_LENGTH, length, 0); } void add_null_count(int64_t null_count) { fbb_.AddElement(PrimitiveArray::VT_NULL_COUNT, null_count, 0); } void add_total_bytes(int64_t total_bytes) { fbb_.AddElement(PrimitiveArray::VT_TOTAL_BYTES, total_bytes, 0); } PrimitiveArrayBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } PrimitiveArrayBuilder &operator=(const PrimitiveArrayBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 6)); return o; } }; inline flatbuffers::Offset CreatePrimitiveArray(flatbuffers::FlatBufferBuilder &_fbb, Type type = Type_BOOL, Encoding encoding = Encoding_PLAIN, int64_t offset = 0, int64_t length = 0, int64_t null_count = 0, int64_t total_bytes = 0) { PrimitiveArrayBuilder builder_(_fbb); builder_.add_total_bytes(total_bytes); builder_.add_null_count(null_count); builder_.add_length(length); builder_.add_offset(offset); builder_.add_encoding(encoding); builder_.add_type(type); return builder_.Finish(); } struct CategoryMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_LEVELS = 4, VT_ORDERED = 6 }; /// The category codes are presumed to be integers that are valid indexes into /// the levels array const PrimitiveArray *levels() const { return GetPointer(VT_LEVELS); } bool ordered() const { return GetField(VT_ORDERED, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_LEVELS) && verifier.VerifyTable(levels()) && VerifyField(verifier, VT_ORDERED) && verifier.EndTable(); } }; struct CategoryMetadataBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_levels(flatbuffers::Offset levels) { fbb_.AddOffset(CategoryMetadata::VT_LEVELS, levels); } void add_ordered(bool ordered) { fbb_.AddElement(CategoryMetadata::VT_ORDERED, static_cast(ordered), 0); } CategoryMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CategoryMetadataBuilder &operator=(const CategoryMetadataBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 2)); return o; } }; inline flatbuffers::Offset CreateCategoryMetadata(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset levels = 0, bool ordered = false) { CategoryMetadataBuilder builder_(_fbb); builder_.add_levels(levels); builder_.add_ordered(ordered); return builder_.Finish(); } struct TimestampMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_UNIT = 4, VT_TIMEZONE = 6 }; TimeUnit unit() const { return static_cast(GetField(VT_UNIT, 0)); } /// Timestamp data is assumed to be UTC, but the time zone is stored here for /// presentation as localized const flatbuffers::String *timezone() const { return GetPointer(VT_TIMEZONE); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_UNIT) && VerifyField(verifier, VT_TIMEZONE) && verifier.Verify(timezone()) && verifier.EndTable(); } }; struct TimestampMetadataBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_unit(TimeUnit unit) { fbb_.AddElement(TimestampMetadata::VT_UNIT, static_cast(unit), 0); } void add_timezone(flatbuffers::Offset timezone) { fbb_.AddOffset(TimestampMetadata::VT_TIMEZONE, timezone); } TimestampMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TimestampMetadataBuilder &operator=(const TimestampMetadataBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 2)); return o; } }; inline flatbuffers::Offset CreateTimestampMetadata(flatbuffers::FlatBufferBuilder &_fbb, TimeUnit unit = TimeUnit_SECOND, flatbuffers::Offset timezone = 0) { TimestampMetadataBuilder builder_(_fbb); builder_.add_timezone(timezone); builder_.add_unit(unit); return builder_.Finish(); } struct DateMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } }; struct DateMetadataBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; DateMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DateMetadataBuilder &operator=(const DateMetadataBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 0)); return o; } }; inline flatbuffers::Offset CreateDateMetadata(flatbuffers::FlatBufferBuilder &_fbb) { DateMetadataBuilder builder_(_fbb); return builder_.Finish(); } struct TimeMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_UNIT = 4 }; TimeUnit unit() const { return static_cast(GetField(VT_UNIT, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_UNIT) && verifier.EndTable(); } }; struct TimeMetadataBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_unit(TimeUnit unit) { fbb_.AddElement(TimeMetadata::VT_UNIT, static_cast(unit), 0); } TimeMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TimeMetadataBuilder &operator=(const TimeMetadataBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 1)); return o; } }; inline flatbuffers::Offset CreateTimeMetadata(flatbuffers::FlatBufferBuilder &_fbb, TimeUnit unit = TimeUnit_SECOND) { TimeMetadataBuilder builder_(_fbb); builder_.add_unit(unit); return builder_.Finish(); } struct Column FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_NAME = 4, VT_VALUES = 6, VT_METADATA_TYPE = 8, VT_METADATA = 10, VT_USER_METADATA = 12 }; const flatbuffers::String *name() const { return GetPointer(VT_NAME); } const PrimitiveArray *values() const { return GetPointer(VT_VALUES); } TypeMetadata metadata_type() const { return static_cast(GetField(VT_METADATA_TYPE, 0)); } const void *metadata() const { return GetPointer(VT_METADATA); } /// This should (probably) be JSON const flatbuffers::String *user_metadata() const { return GetPointer(VT_USER_METADATA); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_NAME) && verifier.Verify(name()) && VerifyField(verifier, VT_VALUES) && verifier.VerifyTable(values()) && VerifyField(verifier, VT_METADATA_TYPE) && VerifyField(verifier, VT_METADATA) && VerifyTypeMetadata(verifier, metadata(), metadata_type()) && VerifyField(verifier, VT_USER_METADATA) && verifier.Verify(user_metadata()) && verifier.EndTable(); } }; struct ColumnBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_name(flatbuffers::Offset name) { fbb_.AddOffset(Column::VT_NAME, name); } void add_values(flatbuffers::Offset values) { fbb_.AddOffset(Column::VT_VALUES, values); } void add_metadata_type(TypeMetadata metadata_type) { fbb_.AddElement(Column::VT_METADATA_TYPE, static_cast(metadata_type), 0); } void add_metadata(flatbuffers::Offset metadata) { fbb_.AddOffset(Column::VT_METADATA, metadata); } void add_user_metadata(flatbuffers::Offset user_metadata) { fbb_.AddOffset(Column::VT_USER_METADATA, user_metadata); } ColumnBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ColumnBuilder &operator=(const ColumnBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 5)); return o; } }; inline flatbuffers::Offset CreateColumn(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset name = 0, flatbuffers::Offset values = 0, TypeMetadata metadata_type = TypeMetadata_NONE, flatbuffers::Offset metadata = 0, flatbuffers::Offset user_metadata = 0) { ColumnBuilder builder_(_fbb); builder_.add_user_metadata(user_metadata); builder_.add_metadata(metadata); builder_.add_values(values); builder_.add_name(name); builder_.add_metadata_type(metadata_type); return builder_.Finish(); } struct CTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_DESCRIPTION = 4, VT_NUM_ROWS = 6, VT_COLUMNS = 8, VT_VERSION = 10, VT_METADATA = 12 }; /// Some text (or a name) metadata about what the file is, optional const flatbuffers::String *description() const { return GetPointer(VT_DESCRIPTION); } int64_t num_rows() const { return GetField(VT_NUM_ROWS, 0); } const flatbuffers::Vector> *columns() const { return GetPointer> *>(VT_COLUMNS); } /// Version number of the Feather format int32_t version() const { return GetField(VT_VERSION, 0); } /// Table metadata (likely JSON), not yet used const flatbuffers::String *metadata() const { return GetPointer(VT_METADATA); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_DESCRIPTION) && verifier.Verify(description()) && VerifyField(verifier, VT_NUM_ROWS) && VerifyField(verifier, VT_COLUMNS) && verifier.Verify(columns()) && verifier.VerifyVectorOfTables(columns()) && VerifyField(verifier, VT_VERSION) && VerifyField(verifier, VT_METADATA) && verifier.Verify(metadata()) && verifier.EndTable(); } }; struct CTableBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_description(flatbuffers::Offset description) { fbb_.AddOffset(CTable::VT_DESCRIPTION, description); } void add_num_rows(int64_t num_rows) { fbb_.AddElement(CTable::VT_NUM_ROWS, num_rows, 0); } void add_columns(flatbuffers::Offset>> columns) { fbb_.AddOffset(CTable::VT_COLUMNS, columns); } void add_version(int32_t version) { fbb_.AddElement(CTable::VT_VERSION, version, 0); } void add_metadata(flatbuffers::Offset metadata) { fbb_.AddOffset(CTable::VT_METADATA, metadata); } CTableBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CTableBuilder &operator=(const CTableBuilder &); flatbuffers::Offset Finish() { auto o = flatbuffers::Offset(fbb_.EndTable(start_, 5)); return o; } }; inline flatbuffers::Offset CreateCTable(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset description = 0, int64_t num_rows = 0, flatbuffers::Offset>> columns = 0, int32_t version = 0, flatbuffers::Offset metadata = 0) { CTableBuilder builder_(_fbb); builder_.add_num_rows(num_rows); builder_.add_metadata(metadata); builder_.add_version(version); builder_.add_columns(columns); builder_.add_description(description); return builder_.Finish(); } inline bool VerifyTypeMetadata(flatbuffers::Verifier &verifier, const void *union_obj, TypeMetadata type) { switch (type) { case TypeMetadata_NONE: return true; case TypeMetadata_CategoryMetadata: return verifier.VerifyTable(reinterpret_cast(union_obj)); case TypeMetadata_TimestampMetadata: return verifier.VerifyTable(reinterpret_cast(union_obj)); case TypeMetadata_DateMetadata: return verifier.VerifyTable(reinterpret_cast(union_obj)); case TypeMetadata_TimeMetadata: return verifier.VerifyTable(reinterpret_cast(union_obj)); default: return false; } } inline const feather::fbs::CTable *GetCTable(const void *buf) { return flatbuffers::GetRoot(buf); } inline bool VerifyCTableBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer(); } inline void FinishCTableBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset root) { fbb.Finish(root); } } // namespace fbs } // namespace feather #endif // FLATBUFFERS_GENERATED_METADATA_FEATHER_FBS_H_ feather-format-0.3.1/src/feather/writer.cc0000664000175100017510000001440112756750540020436 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include "feather/writer.h" #include #include #include "feather/common.h" #include "feather/status.h" namespace feather { TableWriter::TableWriter() : initialized_stream_(false) {} Status TableWriter::Open(const std::shared_ptr& stream) { stream_ = stream; return Status::OK(); } Status TableWriter::OpenFile(const std::string& abspath, std::unique_ptr* out) { auto stream = std::unique_ptr(new FileOutputStream()); RETURN_NOT_OK(stream->Open(abspath)); std::shared_ptr sink(stream.release()); out->reset(new TableWriter()); return (*out)->Open(sink); } void TableWriter::SetDescription(const std::string& desc) { metadata_.SetDescription(desc); } void TableWriter::SetNumRows(int64_t num_rows) { metadata_.SetNumRows(num_rows); } Status TableWriter::Init() { if (!initialized_stream_) { int64_t bytes_written_unused; RETURN_NOT_OK(stream_->WritePadded( reinterpret_cast(FEATHER_MAGIC_BYTES), strlen(FEATHER_MAGIC_BYTES), &bytes_written_unused)); initialized_stream_ = true; } return Status::OK(); } Status TableWriter::Finalize() { if (!initialized_stream_) { RETURN_NOT_OK(Init()); } metadata_.Finish(); auto buffer = metadata_.GetBuffer(); // Writer metadata int64_t bytes_written; RETURN_NOT_OK(stream_->WritePadded(buffer->data(), buffer->size(), &bytes_written)); uint32_t buffer_size = static_cast(bytes_written); // Footer: metadata length, magic bytes RETURN_NOT_OK(stream_->Write(reinterpret_cast(&buffer_size), sizeof(uint32_t))); RETURN_NOT_OK(stream_->Write( reinterpret_cast(FEATHER_MAGIC_BYTES), strlen(FEATHER_MAGIC_BYTES))); return stream_->Close(); } Status TableWriter::AppendPrimitive(const PrimitiveArray& values, ArrayMetadata* meta) { if (!initialized_stream_) { RETURN_NOT_OK(Init()); } meta->type = values.type; meta->encoding = Encoding::PLAIN; RETURN_NOT_OK(stream_->Tell(&meta->offset)); meta->length = values.length; meta->null_count = values.null_count; meta->total_bytes = 0; int64_t bytes_written; // Write the null bitmask if (values.null_count > 0) { // We assume there is one bit for each value in values.nulls, aligned on a // byte boundary, and we write this much data into the stream size_t null_bytes = util::bytes_for_bits(values.length); RETURN_NOT_OK(stream_->WritePadded(values.nulls, null_bytes, &bytes_written)); meta->total_bytes += bytes_written; } size_t value_byte_size = ByteSize(values.type); size_t values_bytes; if (IsVariableLength(values.type)) { size_t offset_bytes = sizeof(int32_t) * (values.length + 1); values_bytes = values.offsets[values.length] * value_byte_size; // Write the variable-length offsets RETURN_NOT_OK(stream_->WritePadded(reinterpret_cast(values.offsets), offset_bytes, &bytes_written)); meta->total_bytes += bytes_written; } else { if (values.type == PrimitiveType::BOOL) { // Booleans are bit-packed values_bytes = util::bytes_for_bits(values.length); } else { values_bytes = values.length * value_byte_size; } } RETURN_NOT_OK(stream_->WritePadded(values.values, values_bytes, &bytes_written)); meta->total_bytes += bytes_written; return Status::OK(); } Status TableWriter::AppendPlain(const std::string& name, const PrimitiveArray& values) { // Prepare metadata payload ArrayMetadata meta; AppendPrimitive(values, &meta); // Append the metadata auto meta_builder = metadata_.AddColumn(name); meta_builder->SetValues(meta); meta_builder->Finish(); return Status::OK(); } Status TableWriter::AppendCategory(const std::string& name, const PrimitiveArray& values, const PrimitiveArray& levels, bool ordered) { if (!IsInteger(values.type)) { return Status::Invalid("Category values must be integers"); } ArrayMetadata values_meta, levels_meta; AppendPrimitive(values, &values_meta); AppendPrimitive(levels, &levels_meta); auto meta_builder = metadata_.AddColumn(name); meta_builder->SetValues(values_meta); meta_builder->SetCategory(levels_meta, ordered); meta_builder->Finish(); return Status::OK(); } Status TableWriter::AppendTimestamp(const std::string& name, const PrimitiveArray& values, const TimestampMetadata& meta) { if (values.type != PrimitiveType::INT64) return Status::Invalid("Timestamp values must be INT64"); ArrayMetadata values_meta; AppendPrimitive(values, &values_meta); auto meta_builder = metadata_.AddColumn(name); meta_builder->SetValues(values_meta); meta_builder->SetTimestamp(meta.unit, meta.timezone); meta_builder->Finish(); return Status::OK(); } Status TableWriter::AppendTime(const std::string& name, const PrimitiveArray& values, const TimeMetadata& meta) { if (values.type != PrimitiveType::INT64) return Status::Invalid("Timestamp values must be INT64"); ArrayMetadata values_meta; AppendPrimitive(values, &values_meta); auto meta_builder = metadata_.AddColumn(name); meta_builder->SetValues(values_meta); meta_builder->SetTime(meta.unit); meta_builder->Finish(); return Status::OK(); } Status TableWriter::AppendDate(const std::string& name, const PrimitiveArray& values) { if (values.type != PrimitiveType::INT32) return Status::Invalid("Date values must be INT32"); ArrayMetadata values_meta; AppendPrimitive(values, &values_meta); auto meta_builder = metadata_.AddColumn(name); meta_builder->SetValues(values_meta); meta_builder->SetDate(); meta_builder->Finish(); return Status::OK(); } } // namespace feather feather-format-0.3.1/src/feather/api.h0000664000175100017510000000170512756747223017544 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_API_H #define FEATHER_API_H #if _MSC_VER >= 1900 #undef timezone #endif #include "feather/compatibility.h" #include "feather/buffer.h" #include "feather/common.h" #include "feather/io.h" #include "feather/metadata.h" #include "feather/reader.h" #include "feather/status.h" #include "feather/types.h" #include "feather/writer.h" #endif // FEATHER_API_H feather-format-0.3.1/src/feather/types.cc0000664000175100017510000000406412674142144020264 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include "feather/types.h" #include #include "feather/common.h" namespace feather { bool ArrayMetadata::Equals(const ArrayMetadata& other) const { return this->type == other.type && this->encoding == other.encoding && this->offset == other.offset && this->length == other.length && this->null_count == other.null_count && this->total_bytes == other.total_bytes; } bool PrimitiveArray::Equals(const PrimitiveArray& other) const { // Should we even try comparing the data? if (this->type != other.type || this->length != other.length || this->null_count != other.null_count) { return false; } if (this->null_count > 0) { if (this->null_count != other.null_count || memcmp(this->nulls, other.nulls, util::bytes_for_bits(this->length)) != 0) { return false; } } // TODO(wesm): variable-length dimensions if (IsVariableLength(this->type)) { // One more offset than if (memcmp(this->offsets, other.offsets, (this->length + 1) * sizeof(int32_t)) != 0) { return false; } size_t total_bytes = this->offsets[this->length] * ByteSize(this->type); if (memcmp(this->values, other.values, total_bytes) != 0) { return false; } } else { // Fixed size, get the number of bytes from the length and value size if (memcmp(this->values, other.values, this->length * ByteSize(this->type)) != 0) { return false; } } return true; } } // namespace feather feather-format-0.3.1/src/feather/tests/0000775000175100017510000000000013005023556017741 5ustar wesmwesm00000000000000feather-format-0.3.1/src/feather/tests/writer-test.cc0000664000175100017510000002121512756747223022562 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include #include #include #include "feather/common.h" #include "feather/io.h" #include "feather/reader.h" #include "feather/status.h" #include "feather/writer.h" #include "feather/tests/test-common.h" using std::shared_ptr; using std::unique_ptr; using std::vector; namespace feather { class TestTableWriter : public ::testing::Test { public: void SetUp() { stream_ = std::make_shared(1024); writer_.reset(new TableWriter()); ASSERT_OK(writer_->Open(stream_)); } void Finish() { // Write table footer ASSERT_OK(writer_->Finalize()); output_ = stream_->Finish(); shared_ptr buffer(new BufferReader(output_)); reader_.reset(new TableReader()); ASSERT_OK(reader_->Open(buffer)); } protected: shared_ptr stream_; unique_ptr writer_; unique_ptr reader_; std::shared_ptr output_; }; TEST_F(TestTableWriter, EmptyTable) { Finish(); ASSERT_FALSE(reader_->HasDescription()); ASSERT_EQ("", reader_->GetDescription()); ASSERT_EQ(0, reader_->num_rows()); ASSERT_EQ(0, reader_->num_columns()); } TEST_F(TestTableWriter, SetNumRows) { writer_->SetNumRows(1000); Finish(); ASSERT_EQ(1000, reader_->num_rows()); } TEST_F(TestTableWriter, SetDescription) { std::string desc("contents of the file"); writer_->SetDescription(desc); Finish(); ASSERT_TRUE(reader_->HasDescription()); ASSERT_EQ(desc, reader_->GetDescription()); ASSERT_EQ(0, reader_->num_rows()); ASSERT_EQ(0, reader_->num_columns()); } PrimitiveArray MakePrimitive(PrimitiveType::type type, int64_t length, int64_t null_count, const uint8_t* nulls, const uint8_t* values, const int32_t* offsets) { PrimitiveArray result; result.type = type; result.length = length; result.null_count = null_count; result.nulls = nulls; result.values = values; result.offsets = offsets; return result; } TEST_F(TestTableWriter, PrimitiveRoundTrip) { int num_values = 1000; int num_nulls = 50; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector values_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_bytes(num_values * sizeof(int32_t), 0, &values_buffer); PrimitiveArray array = MakePrimitive(PrimitiveType::INT32, num_values, num_nulls, &null_buffer[0], &values_buffer[0], nullptr); // A non-nullable version of this PrimitiveArray nn_array = MakePrimitive(PrimitiveType::INT32, num_values, 0, nullptr, &values_buffer[0], nullptr); ASSERT_OK(writer_->AppendPlain("f0", array)); ASSERT_OK(writer_->AppendPlain("f1", nn_array)); Finish(); std::unique_ptr col; ASSERT_OK(reader_->GetColumn(0, &col)); ASSERT_TRUE(col->values().Equals(array)); ASSERT_EQ("f0", col->metadata()->name()); ASSERT_OK(reader_->GetColumn(1, &col)); ASSERT_TRUE(col->values().Equals(nn_array)); ASSERT_EQ("f1", col->metadata()->name()); } TEST_F(TestTableWriter, CategoryRoundtrip) { int num_values = 1000; int num_nulls = 50; int num_levels = 10; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector values_buffer; vector levels_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_bytes(num_values * sizeof(int32_t), 0, &values_buffer); test::random_bytes(num_levels * sizeof(uint8_t), 0, &levels_buffer); PrimitiveArray values = MakePrimitive(PrimitiveType::INT32, num_values, num_nulls, &null_buffer[0], &values_buffer[0], nullptr); PrimitiveArray levels = MakePrimitive(PrimitiveType::INT8, num_levels, 0, nullptr, &levels_buffer[0], nullptr); ASSERT_OK(writer_->AppendCategory("f0", values, levels, true)); Finish(); std::unique_ptr col; ASSERT_OK(reader_->GetColumn(0, &col)); ASSERT_EQ("f0", col->metadata()->name()); ASSERT_EQ(ColumnType::CATEGORY, col->type()); ASSERT_TRUE(col->values().Equals(values)); auto cat_col = static_cast(col.get()); ASSERT_TRUE(cat_col->levels().Equals(levels)); ASSERT_TRUE(cat_col->ordered()); } TEST_F(TestTableWriter, TimestampRoundtrip) { int num_values = 1000; int num_nulls = 50; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector values_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_bytes(num_values * sizeof(int64_t), 0, &values_buffer); PrimitiveArray values = MakePrimitive(PrimitiveType::INT64, num_values, num_nulls, &null_buffer[0], &values_buffer[0], nullptr); TimestampMetadata metadata; metadata.unit = TimeUnit::SECOND; metadata.timezone = std::string("America/Los_Angeles"); ASSERT_OK(writer_->AppendTimestamp("f0", values, metadata)); Finish(); std::unique_ptr col; ASSERT_OK(reader_->GetColumn(0, &col)); ASSERT_EQ("f0", col->metadata()->name()); ASSERT_EQ(ColumnType::TIMESTAMP, col->type()); ASSERT_TRUE(col->values().Equals(values)); auto ts_col = static_cast(col.get()); ASSERT_EQ(metadata.unit, ts_col->unit()); ASSERT_EQ(metadata.timezone, ts_col->timezone()); } TEST_F(TestTableWriter, DateRoundtrip) { int num_values = 1000; int num_nulls = 50; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector values_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_bytes(num_values * sizeof(int64_t), 0, &values_buffer); PrimitiveArray values = MakePrimitive(PrimitiveType::INT32, num_values, num_nulls, &null_buffer[0], &values_buffer[0], nullptr); ASSERT_OK(writer_->AppendDate("f0", values)); Finish(); std::unique_ptr col; ASSERT_OK(reader_->GetColumn(0, &col)); ASSERT_EQ("f0", col->metadata()->name()); ASSERT_EQ(ColumnType::DATE, col->type()); ASSERT_TRUE(col->values().Equals(values)); } TEST_F(TestTableWriter, TimeRoundtrip) { int num_values = 1000; int num_nulls = 50; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector values_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_bytes(num_values * sizeof(int64_t), 0, &values_buffer); PrimitiveArray values = MakePrimitive(PrimitiveType::INT64, num_values, num_nulls, &null_buffer[0], &values_buffer[0], nullptr); TimeMetadata metadata; metadata.unit = TimeUnit::SECOND; ASSERT_OK(writer_->AppendTime("f0", values, metadata)); Finish(); std::unique_ptr col; ASSERT_OK(reader_->GetColumn(0, &col)); ASSERT_EQ("f0", col->metadata()->name()); ASSERT_EQ(ColumnType::TIME, col->type()); ASSERT_TRUE(col->values().Equals(values)); auto ts_col = static_cast(col.get()); ASSERT_EQ(metadata.unit, ts_col->unit()); } TEST_F(TestTableWriter, VLenPrimitiveRoundTrip) { // UTF8 or BINARY int num_values = 1000; int num_nulls = 50; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector offsets_buffer; vector values_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_vlen_bytes(num_values, 10, 0, &offsets_buffer, &values_buffer); PrimitiveArray array = MakePrimitive(PrimitiveType::UTF8, num_values, num_nulls, &null_buffer[0], &values_buffer[0], &offsets_buffer[0]); // A non-nullable version PrimitiveArray nn_array = MakePrimitive(PrimitiveType::UTF8, num_values, 0, nullptr, &values_buffer[0], &offsets_buffer[0]); ASSERT_OK(writer_->AppendPlain("f0", array)); ASSERT_OK(writer_->AppendPlain("f1", nn_array)); Finish(); std::unique_ptr col; ASSERT_OK(reader_->GetColumn(0, &col)); ASSERT_TRUE(col->values().Equals(array)); ASSERT_EQ("f0", col->metadata()->name()); ASSERT_OK(reader_->GetColumn(1, &col)); ASSERT_TRUE(col->values().Equals(nn_array)); ASSERT_EQ("f1", col->metadata()->name()); } } // namespace feather feather-format-0.3.1/src/feather/tests/io-test.cc0000664000175100017510000000665412756750540021663 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include #include #include #include "feather/buffer.h" #include "feather/io.h" #include "feather/status.h" #include "feather/tests/test-common.h" namespace feather { TEST(TestBufferReader, Basics) { std::vector data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; auto data_buffer = std::make_shared(&data[0], data.size()); std::unique_ptr reader(new BufferReader(data_buffer)); int64_t pos; ASSERT_OK(reader->Tell(&pos)); ASSERT_EQ(0, pos); ASSERT_EQ(10, reader->size()); std::shared_ptr buffer; ASSERT_OK(reader->Read(4, &buffer)); ASSERT_EQ(4, buffer->size()); ASSERT_EQ(0, memcmp(buffer->data(), &data[0], buffer->size())); ASSERT_OK(reader->Tell(&pos)); ASSERT_EQ(4, pos); ASSERT_OK(reader->Read(10, &buffer)); ASSERT_EQ(6, buffer->size()); ASSERT_EQ(0, memcmp(buffer->data(), &data[4], buffer->size())); ASSERT_OK(reader->Tell(&pos)); ASSERT_EQ(10, pos); } TEST(TestInMemoryOutputStream, Basics) { std::unique_ptr stream(new InMemoryOutputStream(8)); std::vector data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; ASSERT_OK(stream->Write(&data[0], 4)); int64_t pos; ASSERT_OK(stream->Tell(&pos)); ASSERT_EQ(4, pos); ASSERT_OK(stream->Write(&data[4], data.size() - 4)); std::shared_ptr buffer = stream->Finish(); ASSERT_EQ(0, memcmp(buffer->data(), &data[0], data.size())); } TEST(TestInMemoryOutputStream, WritePadded) { std::unique_ptr stream(new InMemoryOutputStream(8)); std::vector data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; int64_t bytes_written; ASSERT_OK(stream->WritePadded(data.data(), static_cast(data.size()), &bytes_written)); ASSERT_EQ(16, bytes_written); int64_t pos; ASSERT_OK(stream->Tell(&pos)); ASSERT_EQ(16, pos); const uint8_t padding_bytes[16] = {0}; std::shared_ptr buffer = stream->Finish(); ASSERT_EQ(16, buffer->size()); ASSERT_EQ(0, memcmp(buffer->data() + data.size(), padding_bytes, buffer->size() - data.size())); } // TODO(wesm): These test are temporarily disabled on Windows because of the // utf16-le mess #if !defined (_MSC_VER) TEST(LocalFileReader, NonExistentFile) { LocalFileReader reader; Status s = reader.Open("foo"); ASSERT_FALSE(s.ok()); ASSERT_TRUE(s.IsIOError()); } TEST(FileOutputStream, NonExistentDirectory) { FileOutputStream writer; Status s = writer.Open("dir-does-not-exist/foo.feather"); ASSERT_FALSE(s.ok()); ASSERT_TRUE(s.IsIOError()); } #endif TEST(BufferBuilder, EmptyStrings) { BufferBuilder builder; builder.Append(nullptr, 0); builder.Append(nullptr, 0); builder.Append(nullptr, 0); std::shared_ptr result = builder.Finish(); ASSERT_EQ(nullptr, result->data()); ASSERT_EQ(0, result->size()); } } // namespace feather feather-format-0.3.1/src/feather/tests/test_main.cc0000664000175100017510000000134512700356276022247 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); return ret; } feather-format-0.3.1/src/feather/tests/test-common.h0000664000175100017510000000477512756747223022414 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include #include #include #include using std::vector; namespace feather { #define ASSERT_RAISES(ENUM, expr) \ do { \ Status s = (expr); \ ASSERT_TRUE(s.Is##ENUM()); \ } while (0) #define ASSERT_OK(expr) \ do { \ Status s = (expr); \ ASSERT_TRUE(s.ok()); \ } while (0) #define EXPECT_OK(expr) \ do { \ Status s = (expr); \ EXPECT_TRUE(s.ok()); \ } while (0) namespace test { template inline void assert_vector_equal(const vector& left, const vector& right) { ASSERT_EQ(left.size(), right.size()); for (size_t i = 0; i < left.size(); ++i) { ASSERT_EQ(left[i], right[i]) << i; } } static inline void random_bytes(int64_t n, uint32_t seed, std::vector* out) { std::mt19937 gen(seed); std::uniform_int_distribution d(0, 255); for (int i = 0; i < n; ++i) { out->push_back(d(gen) & 0xFF); } } static inline void random_vlen_bytes(int64_t n, int max_value_size, uint32_t seed, std::vector* offsets, std::vector* values) { std::mt19937 gen(seed); std::uniform_int_distribution len_dist(0, max_value_size); std::uniform_int_distribution byte_dist(0, 255); int32_t offset = 0; for (int i = 0; i < n; ++i) { offsets->push_back(offset); int32_t length = len_dist(gen); // Generate bytes for the value in this slot for (int j = 0; j < length; ++j) { values->push_back(byte_dist(gen) & 0xFF); } offset += length; } // final (n + 1)-th offset offsets->push_back(offset); } } // namespace test } // namespace feather feather-format-0.3.1/src/feather/tests/c-api-test.cc0000664000175100017510000001221212756747223022234 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include #include #include #include #include #include #include "feather/common.h" #include "feather/feather-c.h" #include "feather/tests/test-common.h" #include "feather/types.h" #define ASSERT_CFEATHER_OK(s) do { \ feather_status _s = (s); \ ASSERT_EQ(FEATHER_OK, _s); \ } while (0); namespace feather { class TestCAPI : public ::testing::Test { public: virtual void TearDown() { for (const std::string& path : tmp_paths_) { try { std::remove(path.c_str()); } catch (const std::exception& e) { (void) e; } } } void OpenWriter(const std::string& path) { const char* c_path = path.c_str(); tmp_paths_.push_back(path); ASSERT_CFEATHER_OK(feather_writer_open_file(c_path, &writer_)); } void CloseWriter() { ASSERT_CFEATHER_OK(feather_writer_close(writer_)); ASSERT_CFEATHER_OK(feather_writer_free(writer_)); } void OpenReader(const std::string& path) { ASSERT_CFEATHER_OK(feather_reader_open_file(path.c_str(), &reader_)); } void CloseReader() { ASSERT_CFEATHER_OK(feather_reader_close(reader_)); ASSERT_CFEATHER_OK(feather_reader_free(reader_)); } protected: std::vector tmp_paths_; feather_writer_t* writer_; feather_reader_t* reader_; }; TEST_F(TestCAPI, FileNotExist) { feather_status s; feather_reader_t* reader; const char* path = "file-not-exist.feather"; s = feather_reader_open_file(path, &reader); ASSERT_EQ(FEATHER_IO_ERROR, s); } TEST_F(TestCAPI, WriteNumRows) { const int num_rows = 1000; std::string path("test-cfeather-write-num-rows"); OpenWriter(path); feather_writer_set_num_rows(writer_, num_rows); CloseWriter(); OpenReader(path); ASSERT_EQ(num_rows, feather_reader_num_rows(reader_)); ASSERT_EQ(0, feather_reader_num_columns(reader_)); CloseReader(); } void MakePrimitive(feather_type type, int64_t length, int64_t null_count, const uint8_t* nulls, const uint8_t* values, const int32_t* offsets, feather_array_t* out) { out->type = type; out->length = length; out->null_count = null_count; out->nulls = nulls; out->values = values; out->offsets = offsets; } static PrimitiveType::type ToFeatherType(feather_type ctype) { return static_cast(static_cast(ctype)); } bool cfeather_array_equals(const feather_array_t* lhs, const feather_array_t* rhs) { if (lhs->type != rhs->type || lhs->length != rhs->length || lhs->null_count != rhs->null_count) { return false; } if (lhs->null_count > 0) { if (lhs->null_count != rhs->null_count || memcmp(lhs->nulls, rhs->nulls, util::bytes_for_bits(lhs->length)) != 0) { return false; } } // TODO(wesm): variable-length dimensions // Fixed size, get the number of bytes from the length and value size if (memcmp(lhs->values, rhs->values, lhs->length * ByteSize(ToFeatherType(lhs->type))) != 0) { return false; } return true; } TEST_F(TestCAPI, PrimitiveRoundTrip) { int num_values = 1000; int num_nulls = 50; int64_t null_bytes = util::bytes_for_bits(num_values); // Generate some random data vector null_buffer; vector values_buffer; test::random_bytes(null_bytes, 0, &null_buffer); test::random_bytes(num_values * sizeof(int32_t), 0, &values_buffer); feather_array_t cvalues; feather_array_t cvalues_nn; MakePrimitive(FEATHER_INT32, num_values, num_nulls, &null_buffer[0], &values_buffer[0], nullptr, &cvalues); // A non-nullable version of this MakePrimitive(FEATHER_UINT32, num_values, 0, nullptr, &values_buffer[0], nullptr, &cvalues_nn); std::string path("test-cfeather-primitive-round-trip"); OpenWriter(path); const char* name0 = "f0"; const char* name1 = "f1"; ASSERT_CFEATHER_OK(feather_writer_append_plain(writer_, name0, &cvalues)); ASSERT_CFEATHER_OK(feather_writer_append_plain(writer_, name1, &cvalues_nn)); CloseWriter(); OpenReader(path); ASSERT_EQ(2, feather_reader_num_columns(reader_)); feather_column_t col; ASSERT_CFEATHER_OK(feather_reader_get_column(reader_, 0, &col)); ASSERT_EQ(FEATHER_COLUMN_PRIMITIVE, col.type); ASSERT_STREQ(name0, col.name); ASSERT_TRUE(cfeather_array_equals(&cvalues, &col.values)); feather_column_free(&col); ASSERT_CFEATHER_OK(feather_reader_get_column(reader_, 1, &col)); ASSERT_STREQ(name1, col.name); ASSERT_TRUE(cfeather_array_equals(&cvalues_nn, &col.values)); feather_column_free(&col); CloseReader(); } } // namespace feather feather-format-0.3.1/src/feather/tests/metadata-test.cc0000664000175100017510000001347112756750540023027 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include #include #include #include #include "feather/common.h" #include "feather/metadata.h" namespace feather { namespace metadata { class TestTableBuilder : public ::testing::Test { public: void SetUp() { tb_.reset(new TableBuilder(1000)); } virtual void Finish() { tb_->Finish(); table_.reset(new Table()); table_->Open(tb_->GetBuffer()); } protected: std::unique_ptr tb_; std::unique_ptr
table_; }; TEST_F(TestTableBuilder, Version) { Finish(); ASSERT_EQ(kFeatherVersion, table_->version()); } TEST_F(TestTableBuilder, EmptyTable) { Finish(); ASSERT_FALSE(table_->has_description()); ASSERT_EQ("", table_->description()); ASSERT_EQ(1000, table_->num_rows()); ASSERT_EQ(0, table_->num_columns()); } TEST_F(TestTableBuilder, SetDescription) { std::string desc("this is some good data"); tb_->SetDescription(desc); Finish(); ASSERT_TRUE(table_->has_description()); ASSERT_EQ(desc, table_->description()); } void AssertArrayEquals(const ArrayMetadata& left, const ArrayMetadata& right) { EXPECT_EQ(left.type, right.type); EXPECT_EQ(left.encoding, right.encoding); EXPECT_EQ(left.offset, right.offset); EXPECT_EQ(left.length, right.length); EXPECT_EQ(left.null_count, right.null_count); EXPECT_EQ(left.total_bytes, right.total_bytes); } TEST_F(TestTableBuilder, AddPrimitiveColumn) { std::unique_ptr cb = tb_->AddColumn("f0"); ArrayMetadata values1; ArrayMetadata values2; values1.type = PrimitiveType::INT32; values1.encoding = Encoding::PLAIN; values1.offset = 10000; values1.length = 1000; values1.null_count = 100; values1.total_bytes = 4000; cb->SetValues(values1); std::string user_meta = "as you wish"; cb->SetUserMetadata(user_meta); cb->Finish(); cb = tb_->AddColumn("f1"); values2.type = PrimitiveType::UTF8; values2.encoding = Encoding::PLAIN; values2.offset = 14000; values2.length = 1000; values2.null_count = 100; values2.total_bytes = 10000; cb->SetValues(values2); cb->Finish(); Finish(); ASSERT_EQ(2, table_->num_columns()); auto col = table_->GetColumn(0); ASSERT_EQ("f0", col->name()); ASSERT_EQ(ColumnType::PRIMITIVE, col->type()); ASSERT_EQ(user_meta, col->user_metadata()); AssertArrayEquals(col->values(), values1); col = table_->GetColumn(1); ASSERT_EQ("f1", col->name()); ASSERT_EQ(ColumnType::PRIMITIVE, col->type()); AssertArrayEquals(col->values(), values2); } TEST_F(TestTableBuilder, AddCategoryColumn) { ArrayMetadata values1(PrimitiveType::UINT8, Encoding::PLAIN, 10000, 1000, 100, 4000); ArrayMetadata levels(PrimitiveType::UTF8, Encoding::PLAIN, 14000, 10, 0, 300); std::unique_ptr cb = tb_->AddColumn("c0"); cb->SetValues(values1); cb->SetCategory(levels); cb->Finish(); cb = tb_->AddColumn("c1"); cb->SetValues(values1); cb->SetCategory(levels, true); cb->Finish(); Finish(); auto col = table_->GetColumn(0); ASSERT_EQ(ColumnType::CATEGORY, col->type()); AssertArrayEquals(col->values(), values1); const CategoryColumn* cat_ptr = static_cast(col.get()); ASSERT_FALSE(cat_ptr->ordered()); AssertArrayEquals(cat_ptr->levels(), levels); col = table_->GetColumn(1); cat_ptr = static_cast(col.get()); ASSERT_TRUE(cat_ptr->ordered()); AssertArrayEquals(cat_ptr->levels(), levels); } TEST_F(TestTableBuilder, AddTimestampColumn) { ArrayMetadata values1(PrimitiveType::INT64, Encoding::PLAIN, 10000, 1000, 100, 4000); std::unique_ptr cb = tb_->AddColumn("c0"); cb->SetValues(values1); cb->SetTimestamp(TimeUnit::MILLISECOND); cb->Finish(); cb = tb_->AddColumn("c1"); std::string tz("America/Los_Angeles"); cb->SetValues(values1); cb->SetTimestamp(TimeUnit::SECOND, tz); cb->Finish(); Finish(); auto col = table_->GetColumn(0); ASSERT_EQ(ColumnType::TIMESTAMP, col->type()); AssertArrayEquals(col->values(), values1); const TimestampColumn* ts_ptr = static_cast(col.get()); ASSERT_EQ(TimeUnit::MILLISECOND, ts_ptr->unit()); col = table_->GetColumn(1); ts_ptr = static_cast(col.get()); ASSERT_EQ(TimeUnit::SECOND, ts_ptr->unit()); ASSERT_EQ(tz, ts_ptr->timezone()); } TEST_F(TestTableBuilder, AddDateColumn) { ArrayMetadata values1(PrimitiveType::INT64, Encoding::PLAIN, 10000, 1000, 100, 4000); std::unique_ptr cb = tb_->AddColumn("d0"); cb->SetValues(values1); cb->SetDate(); cb->Finish(); Finish(); auto col = table_->GetColumn(0); ASSERT_EQ(ColumnType::DATE, col->type()); AssertArrayEquals(col->values(), values1); } TEST_F(TestTableBuilder, AddTimeColumn) { ArrayMetadata values1(PrimitiveType::INT64, Encoding::PLAIN, 10000, 1000, 100, 4000); std::unique_ptr cb = tb_->AddColumn("c0"); cb->SetValues(values1); cb->SetTime(TimeUnit::SECOND); cb->Finish(); Finish(); auto col = table_->GetColumn(0); ASSERT_EQ(ColumnType::TIME, col->type()); AssertArrayEquals(col->values(), values1); const TimeColumn* t_ptr = static_cast(col.get()); ASSERT_EQ(TimeUnit::SECOND, t_ptr->unit()); } } // namespace metadata } // namespace feather feather-format-0.3.1/src/feather/metadata.h0000664000175100017510000000762512756747223020562 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_METADATA_H #define FEATHER_METADATA_H #include #include #include #include "feather/compatibility.h" #include "feather/buffer.h" #include "feather/types.h" namespace feather { namespace metadata { class TableBuilder; class ColumnBuilder { public: ColumnBuilder(TableBuilder* parent, const std::string& name); ~ColumnBuilder(); void SetValues(const ArrayMetadata& values); void SetCategory(const ArrayMetadata& levels, bool ordered = false); void SetTimestamp(TimeUnit::type unit); void SetTimestamp(TimeUnit::type unit, const std::string& timezone); void SetDate(); void SetTime(TimeUnit::type unit); void SetUserMetadata(const std::string& data); void Finish(); private: TableBuilder* parent_; class Impl; std::shared_ptr impl_; }; class TableBuilder { public: TableBuilder(); explicit TableBuilder(int64_t num_rows); std::unique_ptr AddColumn(const std::string& name); void Finish(); // These are accessible after calling Finish std::shared_ptr GetBuffer() const; void SetDescription(const std::string& description); void SetNumRows(int64_t num_rows); private: friend class ColumnBuilder; // PIMPL, to hide flatbuffers class Impl; std::shared_ptr impl_; }; // ---------------------------------------------------------------------- // Metadata reader interface classes class File; class Table; class Column { public: Column() {} // Conceal flatbuffer types from the public API static std::shared_ptr Make(const void* fbs_column); std::string name() const; ColumnType::type type() const; PrimitiveType::type values_type() const; std::string user_metadata() const; const ArrayMetadata& values() const { return values_; } protected: void Init(const void* fbs_column); std::string name_; ColumnType::type type_; ArrayMetadata values_; std::string user_metadata_; }; class CategoryColumn : public Column { public: static std::shared_ptr Make(const void* fbs_column); const ArrayMetadata& levels() const { return metadata_.levels; } bool ordered() const { return metadata_.ordered; } private: CategoryMetadata metadata_; }; class TimestampColumn : public Column { public: static std::shared_ptr Make(const void* fbs_column); TimeUnit::type unit() const; std::string timezone() const; private: TimestampMetadata metadata_; }; class DateColumn : public Column { public: static std::shared_ptr Make(const void* fbs_column); }; class TimeColumn : public Column { public: static std::shared_ptr Make(const void* fbs_column); TimeUnit::type unit() const; private: TimeMetadata metadata_; }; // TODO: address memory ownership issues of the buffer here class Table { public: Table() : table_(nullptr) {} bool Open(const std::shared_ptr& buffer); std::string description() const; int version() const; // Optional bool has_description() const; int64_t num_rows() const; size_t num_columns() const; std::shared_ptr GetColumn(int i) const; std::shared_ptr GetColumnNamed(const std::string& name) const; private: std::shared_ptr buffer_; // Opaque fbs::CTable const void* table_; }; } // namespace metadata } // namespace feather #endif // FEATHER_METADATA_H feather-format-0.3.1/src/feather/reader.h0000664000175100017510000001170112756747223020232 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_READER_H #define FEATHER_READER_H #include #include "feather/io.h" #include "feather/metadata.h" #include "feather/types.h" namespace feather { class Status; class Column { public: Column(ColumnType::type type, const std::shared_ptr& metadata, const PrimitiveArray& values) : type_(type), metadata_(metadata), values_(values) { name_ = metadata_->name(); } const PrimitiveArray& values() const { return values_; } ColumnType::type type() const { return type_; } const std::shared_ptr& metadata() const { return metadata_; } const std::string& name() const { return name_; } protected: ColumnType::type type_; std::string name_; std::shared_ptr metadata_; PrimitiveArray values_; }; class CategoryColumn : public Column { public: CategoryColumn(const std::shared_ptr& metadata, const PrimitiveArray& values, const PrimitiveArray& levels, bool ordered = false) : Column(ColumnType::CATEGORY, metadata, values), levels_(levels), ordered_(ordered) { category_meta_ = static_cast(metadata.get()); } const PrimitiveArray& levels() const { return levels_; } bool ordered() const { return ordered_; } private: const metadata::CategoryColumn* category_meta_; PrimitiveArray levels_; bool ordered_; }; class TimestampColumn : public Column { public: TimestampColumn(const std::shared_ptr& metadata, const PrimitiveArray& values) : Column(ColumnType::TIMESTAMP, metadata, values) { timestamp_meta_ = static_cast(metadata.get()); timezone_ = timestamp_meta_->timezone(); } TimeUnit::type unit() const { return timestamp_meta_->unit(); } const std::string& timezone() const { return timezone_; } private: const metadata::TimestampColumn* timestamp_meta_; std::string timezone_; }; class DateColumn : public Column { public: DateColumn(const std::shared_ptr& metadata, const PrimitiveArray& values) : Column(ColumnType::DATE, metadata, values) { date_meta_ = static_cast(metadata.get()); } private: const metadata::DateColumn* date_meta_; }; class TimeColumn : public Column { public: TimeColumn(const std::shared_ptr& metadata, const PrimitiveArray& values) : Column(ColumnType::TIME, metadata, values) { time_meta_ = static_cast(metadata.get()); } TimeUnit::type unit() const { return time_meta_->unit(); } private: const metadata::TimeColumn* time_meta_; }; class TableReader { public: TableReader(); Status Open(const std::shared_ptr& source); static Status OpenFile(const std::string& abspath, std::unique_ptr* out); // Optional table description // // This does not return a const std::string& because a string has to be // copied from the flatbuffer to be able to return a non-flatbuffer type std::string GetDescription() const; bool HasDescription() const; int version() const; int64_t num_rows() const; int64_t num_columns() const; Status GetColumn(int i, std::unique_ptr* out) const; Status GetColumnMetadata(int i, std::shared_ptr* out) const; private: Status GetPrimitive(std::shared_ptr col_meta, std::unique_ptr* out) const; Status GetCategory(std::shared_ptr col_meta, std::unique_ptr* out) const; Status GetTimestamp(std::shared_ptr col_meta, std::unique_ptr* out) const; Status GetTime(std::shared_ptr col_meta, std::unique_ptr* out) const; Status GetDate(std::shared_ptr col_meta, std::unique_ptr* out) const; // Retrieve a primitive array from the data source // // @returns: a Buffer instance, the precise type will depend on the kind of // input data source (which may or may not have memory-map like semantics) Status GetPrimitiveArray(const ArrayMetadata& meta, PrimitiveArray* out) const; std::shared_ptr source_; metadata::Table metadata_; }; } // namespace feather #endif // FEATHER_WRITER_H feather-format-0.3.1/src/feather/buffer.cc0000664000175100017510000000247112756747223020403 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #include "feather/buffer.h" #include "feather/status.h" namespace feather { Buffer::Buffer(const std::shared_ptr& parent, int64_t offset, int64_t size) { data_ = parent->data() + offset; size_ = size; parent_ = parent; } std::shared_ptr MutableBuffer::GetImmutableView() { return std::make_shared(this->get_shared_ptr(), 0, size()); } OwnedMutableBuffer::OwnedMutableBuffer() {} Status OwnedMutableBuffer::Resize(int64_t new_size) { size_ = new_size; try { buffer_owner_.resize(new_size); } catch (const std::bad_alloc& e) { return Status::OutOfMemory(e.what()); } data_ = buffer_owner_.data(); mutable_data_ = buffer_owner_.data(); return Status::OK(); } } // namespace feather feather-format-0.3.1/src/feather/metadata.fbs0000664000175100017510000000404712702771466021075 0ustar wesmwesm00000000000000namespace feather.fbs; enum Type : byte { BOOL = 0, INT8 = 1, INT16 = 2, INT32 = 3, INT64 = 4, UINT8 = 5, UINT16 = 6, UINT32 = 7, UINT64 = 8, FLOAT = 9, DOUBLE = 10, UTF8 = 11, BINARY = 12, CATEGORY = 13, TIMESTAMP = 14, DATE = 15, TIME = 16 } enum Encoding : byte { PLAIN = 0, /// Data is stored dictionary-encoded /// dictionary size: /// dictionary data: /// dictionary index: /// /// TODO: do we care about storing the index values in a smaller typeclass DICTIONARY = 1 } enum TimeUnit : byte { SECOND = 0, MILLISECOND = 1, MICROSECOND = 2, NANOSECOND = 3 } table PrimitiveArray { type: Type; encoding: Encoding = PLAIN; /// Relative memory offset of the start of the array data excluding the size /// of the metadata offset: long; /// The number of logical values in the array length: long; /// The number of observed nulls null_count: long; /// The total size of the actual data in the file total_bytes: long; /// TODO: Compression } table CategoryMetadata { /// The category codes are presumed to be integers that are valid indexes into /// the levels array levels: PrimitiveArray; ordered: bool = false; } table TimestampMetadata { unit: TimeUnit; /// Timestamp data is assumed to be UTC, but the time zone is stored here for /// presentation as localized timezone: string; } table DateMetadata { } table TimeMetadata { unit: TimeUnit; } union TypeMetadata { CategoryMetadata, TimestampMetadata, DateMetadata, TimeMetadata, } table Column { name: string; values: PrimitiveArray; metadata: TypeMetadata; /// This should (probably) be JSON user_metadata: string; } table CTable { /// Some text (or a name) metadata about what the file is, optional description: string; num_rows: long; columns: [Column]; /// Version number of the Feather format version: int; /// Table metadata (likely JSON), not yet used metadata: string; } root_type CTable; feather-format-0.3.1/src/feather/feather-c.h0000664000175100017510000001060612700654610020613 0ustar wesmwesm00000000000000/* * Copyright 2016 Feather Developers * * 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. */ #ifndef FEATHER_FEATHER_C_H #define FEATHER_FEATHER_C_H #ifdef __cplusplus extern "C" { #if 0 /* confuse emacs indentation */ } #endif #endif #include #include typedef enum { FEATHER_OK = 0, FEATHER_OOM = 1, FEATHER_KEY_ERROR = 2, FEATHER_INVALID = 3, FEATHER_IO_ERROR = 4, FEATHER_NOT_IMPLEMENTED = 10, FEATHER_UNKNOWN = 50 } feather_status; typedef enum { FEATHER_BOOL = 0, FEATHER_INT8 = 1, FEATHER_INT16 = 2, FEATHER_INT32 = 3, FEATHER_INT64 = 4, FEATHER_UINT8 = 5, FEATHER_UINT16 = 6, FEATHER_UINT32 = 7, FEATHER_UINT64 = 8, FEATHER_FLOAT = 9, FEATHER_DOUBLE = 10, FEATHER_UTF8 = 11, FEATHER_BINARY = 12 } feather_type; /* Column C API */ typedef enum { FEATHER_COLUMN_PRIMITIVE = 0, FEATHER_COLUMN_CATEGORY = 1, FEATHER_COLUMN_TIMESTAMP = 2, FEATHER_COLUMN_DATE = 3, FEATHER_COLUMN_TIME = 4, } feather_column_type; typedef enum { FEATHER_UNIT_SECOND = 0, FEATHER_UNIT_MILLISECOND = 1, FEATHER_UNIT_MICROSECOND = 2, FEATHER_UNIT_NANOSECOND = 3 } feather_time_unit; typedef struct { feather_type type; int64_t length; int64_t null_count; const uint8_t* nulls; const uint8_t* values; const int32_t* offsets; } feather_array_t; typedef struct { feather_array_t indices; feather_array_t levels; int ordered; } feather_category_t; typedef struct { feather_array_t levels; int ordered; } feather_category_data_t; typedef struct { const char* timezone; feather_time_unit unit; } feather_timestamp_data_t; typedef struct { feather_time_unit unit; } feather_time_data_t; typedef struct { feather_column_type type; const char* name; feather_array_t values; void* data; void* type_metadata; } feather_column_t; feather_status feather_column_free(feather_column_t* self); /* ************************************************* TableWriter C API ************************************************* */ typedef void feather_writer_t; feather_status feather_writer_open_file(const char* path, feather_writer_t** out); void feather_writer_set_num_rows(feather_writer_t* self, int64_t num_rows); /* Write primitive array */ feather_status feather_writer_append_plain(feather_writer_t* self, const char* name, feather_array_t* values); feather_status feather_writer_append_category(feather_writer_t* self, const char* name, feather_array_t* values, feather_array_t* levels, int ordered); feather_status feather_writer_append_timestamp(feather_writer_t* self, const char* name, feather_array_t* values, const char* timezone, feather_time_unit unit); feather_status feather_writer_append_time(feather_writer_t* self, const char* name, feather_array_t* values, feather_time_unit unit); feather_status feather_writer_append_date(feather_writer_t* self, const char* name, feather_array_t* values); /* Write file metadata and footer */ feather_status feather_writer_close(feather_writer_t* self); /* Close file if any, and deallocate TableWriter */ feather_status feather_writer_free(feather_writer_t* self); /* ************************************************* TableReader C API ************************************************* */ typedef void feather_reader_t; feather_status feather_reader_open_file(const char* path, feather_reader_t** out); int64_t feather_reader_num_rows(feather_reader_t* self); int64_t feather_reader_num_columns(feather_reader_t* self); /* * Retrieve the column metadata and data pointers from the file. Call * feather_column_free when finished with the column. */ feather_status feather_reader_get_column(feather_reader_t* self, int i, feather_column_t* out); feather_status feather_reader_close(feather_reader_t* self); feather_status feather_reader_free(feather_reader_t* self); #ifdef __cplusplus #if 0 /* confuse emacs indentation */ { #endif } #endif #endif /* FEATHER_FEATHER_C_H */ feather-format-0.3.1/src/feather/writer.h0000664000175100017510000000421412674421146020275 0ustar wesmwesm00000000000000// Copyright 2016 Feather Developers // // 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. #ifndef FEATHER_WRITER_H #define FEATHER_WRITER_H #include #include #include "feather/io.h" #include "feather/metadata.h" #include "feather/types.h" namespace feather { class TableWriter { public: TableWriter(); Status Open(const std::shared_ptr& stream); static Status OpenFile(const std::string& abspath, std::unique_ptr* out); void SetDescription(const std::string& desc); void SetNumRows(int64_t num_rows); // Plain-encoded data Status AppendPlain(const std::string& name, const PrimitiveArray& values); // Dictionary-encoded primitive data. Especially useful for strings and // binary data void AppendDictEncoded(const std::string& name, const DictEncodedArray& data); // Category type data Status AppendCategory(const std::string& name, const PrimitiveArray& values, const PrimitiveArray& levels, bool ordered = false); // Other primitive data types Status AppendTimestamp(const std::string& name, const PrimitiveArray& values, const TimestampMetadata& meta); Status AppendDate(const std::string& name, const PrimitiveArray& values); Status AppendTime(const std::string& name, const PrimitiveArray& values, const TimeMetadata& meta); // We are done, write the file metadata and footer Status Finalize(); private: Status Init(); std::shared_ptr stream_; bool initialized_stream_; metadata::TableBuilder metadata_; Status AppendPrimitive(const PrimitiveArray& values, ArrayMetadata* out); }; } // namespace feather #endif // FEATHER_WRITER_H feather-format-0.3.1/src/feather/status.cc0000664000175100017510000000467212756747223020462 0ustar wesmwesm00000000000000// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. // // A Status encapsulates the result of an operation. It may indicate success, // or it may indicate an error with an associated error message. // // Multiple threads can invoke const methods on a Status without // external synchronization, but if any of the threads may call a // non-const method, all threads accessing the same Status must use // external synchronization. #include "feather/status.h" #include namespace feather { Status::Status(StatusCode code, const std::string& msg, int16_t posix_code) { assert(code != StatusCode::OK); const uint32_t size = static_cast(msg.size()); char* result = new char[size + 7]; memcpy(result, &size, sizeof(size)); result[4] = static_cast(code); memcpy(result + 5, &posix_code, sizeof(posix_code)); memcpy(result + 7, msg.c_str(), msg.size()); state_ = result; } const char* Status::CopyState(const char* state) { uint32_t size; memcpy(&size, state, sizeof(size)); char* result = new char[size + 7]; memcpy(result, state, size + 7); return result; } std::string Status::ToString() const { std::string result(CodeAsString()); if (state_ == NULL) { return result; } result.append(": "); uint32_t length; memcpy(&length, state_, sizeof(length)); result.append(state_ + 7, length); int16_t posix = posix_code(); if (posix != -1) { char buf[64]; snprintf(buf, sizeof(buf), " (error %d)", posix); result.append(buf); } return result; } std::string Status::CodeAsString() const { if (state_ == NULL) { return "OK"; } const char* type = NULL; switch (code()) { case StatusCode::OK: type = "OK"; break; case StatusCode::OutOfMemory: type = "Out of memory"; break; case StatusCode::KeyError: type = "Key error"; break; case StatusCode::Invalid: type = "Invalid"; break; case StatusCode::IOError: type = "IO error"; break; case StatusCode::NotImplemented: type = "Not implemented"; break; } return std::string(type); } int16_t Status::posix_code() const { if (state_ == NULL) { return 0; } int16_t posix_code; memcpy(&posix_code, state_ + 5, sizeof(posix_code)); return posix_code; } } // namespace feather feather-format-0.3.1/src/feather/CMakeLists.txt0000664000175100017510000000564212756747223021366 0ustar wesmwesm00000000000000# Copyright 2012 Feather Developers # # 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. set(LIBFEATHER_SRCS buffer.cc feather-c.cc io.cc metadata.cc reader.cc status.cc types.cc writer.cc ) set(LIBFEATHER_HEADERS api.h buffer.h common.h feather-c.h io.h metadata.h reader.h status.h types.h writer.h ) set(LIBFEATHER_LINK_LIBS ) set(LIBFEATHER_LINKAGE "SHARED") add_library(feather ${LIBFEATHER_LINKAGE} ${LIBFEATHER_SRCS} ${LIBFEATHER_HEADERS} ) set_target_properties(feather PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") target_link_libraries(feather ${LIBFEATHER_LINK_LIBS}) set_target_properties(feather PROPERTIES LINKER_LANGUAGE CXX) if(APPLE) set_target_properties(feather PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") endif() add_library(feather_test_main tests/test_main.cc) if (APPLE) target_link_libraries(feather_test_main gtest dl) set_target_properties(feather_test_main PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") elseif (WIN32) target_link_libraries(feather_test_main gtest) # copy dll to directory of test executables add_custom_command(TARGET feather_test_main POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory $ $) else() target_link_libraries(feather_test_main dl gtest pthread ) endif() ADD_FEATHER_TEST(tests/c-api-test) ADD_FEATHER_TEST(tests/io-test) ADD_FEATHER_TEST(tests/metadata-test) ADD_FEATHER_TEST(tests/writer-test) # make clean will delete the generated file set_source_files_properties(metadata_generated.h PROPERTIES GENERATED TRUE) set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/src/feather) set(FBS_OUTPUT_FILES "${OUTPUT_DIR}/metadata_generated.h") set(FBS_SRC metadata.fbs) get_filename_component(ABS_FBS_SRC ${FBS_SRC} ABSOLUTE) add_custom_command( OUTPUT ${FBS_OUTPUT_FILES} COMMAND ${FLATBUFFERS_COMPILER} -c -o ${OUTPUT_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${FBS_SRC} DEPENDS ${ABS_FBA_SRC} COMMENT "Running flatc compiler on ${FBS_SRC}" VERBATIM ) add_custom_target(metadata_fbs DEPENDS ${FBS_OUTPUT_FILES}) add_dependencies(feather metadata_fbs) # installation install(FILES api.h buffer.h common.h feather-c.h io.h metadata.h reader.h status.h types.h writer.h DESTINATION include/feather) install(TARGETS feather LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) feather-format-0.3.1/MANIFEST.in0000664000175100017510000000037512676603306016147 0ustar wesmwesm00000000000000include MANIFEST.in include ../LICENSE.txt include README.md include setup.py include requirements.txt graft feather graft src global-exclude *.so global-exclude *.pyc global-exclude *~ global-exclude \#* global-exclude .git* global-exclude .DS_Store