Skip to main content

A wrapper for the C++ Datasketches library

Project description

# Python Wrapper for Datasketches

## Installation

The release files do not include the needed python binding library ([pybind11](https://github.com/pybind/pybind11)). If building from a relase package, you must ensure that the pybind11 directory points to a local copy of pybind11.

An official pypi build is eventually planned but not yet available.

If you instead want to take a (possibly ill-advised) gamble on the current state of the master branch being useable, you can run: `pip install git+https://github.com/apache/datasketches-cpp.git`

## Developer Instructions

### Building

When cloning the source repository, you should include the pybind11 submodule with the –recursive option to the clone command: ` git clone --recursive https://github.com/apache/datasketches-cpp.git cd datasketches-cpp python -m pip install --upgrade pip setuptools wheel numpy python setup.py build `

If you cloned without –recursive, you can add the submodule post-checkout using git submodule update –init –recursive.

### Installing

Assuming you have already checked out the library and any dependent submodules, install by simply replacing the lsat line of the build command with python setup.py install.

### Unit tests

The python tests are run with tox. To ensure you have all the needed packages, from the package base directory run: ` python -m pip install --upgrade pip setuptools wheel numpy tox tox `

## Usage

Having installed the library, loading the Datasketches library in Python is simple: import datasketches.

## Available Sketch Classes

  • KLL
    • kll_ints_sketch

    • kll_floats_sketch

  • Frequent Items
    • frequent_strings_sketch

    • Error types are frequent_items_error_type.{NO_FALSE_NEGATIVES | NO_FALSE_POSITIVES}

  • Theta
    • update_theta_sketch

    • compact_theta_sketch (cannot be instantiated directly)

    • theta_union

    • theta_intersection

    • theta_a_not_b

  • HLL
    • hll_sketch

    • hll_union

    • Target HLL types are tgt_hll_type.{HLL_4 | HLL_6 | HLL_8}

  • CPC
    • cpc_sketch

    • cpc_union

  • VarOpt Sampling
    • var_opt_sketch

    • var_opt_union

  • Vector of KLL
    • vector_of_kll_ints_sketches

    • vector_of_kll_floats_sketches

## Known Differences from C++

The Python API largely mirrors the C++ API, with a few minor exceptions: The primary known differences are that Python on modern platforms does not support unsigned integer values or numeric values with fewer than 64 bits. As a result, you may not be able to produce identical sketches from within Python as you can with Java and C++. Loading those sketches after they have been serialized from another language will work as expected.

The Vector of KLL object is currently exclusive to python, and holds an array of independent KLL sketches. This is useful for creating a set of KLL sketches over a vector and has been designed to allow input as either a vector or a matrix of multiple vectors.

We have also removed reliance on a builder class for theta sketches as Python allows named arguments to the constructor, not strictly positional arguments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

whylabs_datasketches-2.2.0b1-cp310-cp310-macosx_12_0_arm64.whl (367.3 kB view hashes)

Uploaded CPython 3.10 macOS 12.0+ ARM64

whylabs_datasketches-2.2.0b1-cp39-cp39-win_amd64.whl (501.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

whylabs_datasketches-2.2.0b1-cp39-cp39-manylinux2010_x86_64.whl (404.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

whylabs_datasketches-2.2.0b1-cp39-cp39-macosx_12_0_arm64.whl (367.4 kB view hashes)

Uploaded CPython 3.9 macOS 12.0+ ARM64

whylabs_datasketches-2.2.0b1-cp39-cp39-macosx_10_15_x86_64.whl (392.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

whylabs_datasketches-2.2.0b1-cp39-cp39-macosx_10_9_x86_64.whl (392.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

whylabs_datasketches-2.2.0b1-cp38-cp38-win_amd64.whl (319.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

whylabs_datasketches-2.2.0b1-cp38-cp38-manylinux2010_x86_64.whl (405.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

whylabs_datasketches-2.2.0b1-cp38-cp38-macosx_12_0_arm64.whl (367.4 kB view hashes)

Uploaded CPython 3.8 macOS 12.0+ ARM64

whylabs_datasketches-2.2.0b1-cp38-cp38-macosx_10_15_x86_64.whl (392.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

whylabs_datasketches-2.2.0b1-cp38-cp38-macosx_10_9_x86_64.whl (392.9 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

whylabs_datasketches-2.2.0b1-cp37-cp37m-win_amd64.whl (517.6 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

whylabs_datasketches-2.2.0b1-cp37-cp37m-manylinux2010_x86_64.whl (410.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

whylabs_datasketches-2.2.0b1-cp37-cp37m-macosx_10_15_x86_64.whl (383.3 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

whylabs_datasketches-2.2.0b1-cp37-cp37m-macosx_10_9_x86_64.whl (383.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

whylabs_datasketches-2.2.0b1-cp36-cp36m-win_amd64.whl (517.6 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

whylabs_datasketches-2.2.0b1-cp36-cp36m-manylinux2010_x86_64.whl (410.5 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

whylabs_datasketches-2.2.0b1-cp36-cp36m-macosx_10_15_x86_64.whl (383.3 kB view hashes)

Uploaded CPython 3.6m macOS 10.15+ x86-64

whylabs_datasketches-2.2.0b1-cp36-cp36m-macosx_10_9_x86_64.whl (383.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

whylabs_datasketches-2.2.0b1-cp35-cp35m-manylinux2010_x86_64.whl (410.5 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

whylabs_datasketches-2.2.0b1-cp35-cp35m-macosx_10_15_x86_64.whl (383.3 kB view hashes)

Uploaded CPython 3.5m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page