python

command
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

Python Binding of recordio

This package provides a Python binding of the recordio package in Go.

API

Python wrapper exposes three classes Index, Writer and Scanner. The interfaces are defined as following:

class Index(object):
   def __init__(self, path):
      """Loads index from file"""
      ...
   
   def num_records(self):
      """Returns total number of records in the file."""
      ...

   def close(self):
      """Closes the index"""
      ...

class Scanner(objec):
   def __init__(self, path, start=0, len=-1, index=None):
      """Creates a scanner for the file. Use the index if provided."""
      ...
   
   def record(self):
      """Returns the current record. Returns None if the end is reached"""
      ...

   def close(self):
      """Closes the scanner"""
      ...

class Writer(object):
   def __init__(self, path):
      """Creates a writer"""
      ...

   def write(self, record):
      """Writes the record to file"""
      ...

   def close(self):
      """Closes the writer"""
      ...

Build

To build this Python binding, we need Python 3 and the Go compiler. If you don't want to install them locally, you can install them into a Docker image, and run the image to build the package.

To build the Docker image, we can use the /Dockerfile.

docker build -t recordio:dev .

To start a Docker container, run the following command:

docker run --rm -it -v $PWD:/work -w /work recordio:dev

Test

Run the following command in python directory:

python setup.py -vvv test

Or use the Docker image:

docker run -it --rm -v $PWD:/work -w /work recordio:dev \
    bash -c "cd python && python setup.py -vvv test"

Documentation

Overview

Note: this file is part of python extension to recordio. It should be put in the same directory of setup.py so pip to find it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL