GithubHelp home page GithubHelp logo

isabella232 / reindexer-py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from restream/reindexer-py

0.0 0.0 0.0 18 KB

Reindexer's python connector

License: Apache License 2.0

CMake 3.38% Python 56.22% C++ 40.11% Shell 0.29%

reindexer-py's Introduction

pyreindexer

The pyreindexer module provides a connector and its auxiliary tools for interaction with Reindexer.

pyreindexer.rx_connector

RxConnector

RxConnector(self, dsn)

RxConnector provides a binding to Reindexer upon two shared libraries (hereinafter - APIs): 'rawpyreindexerb.so' and 'rawpyreindexerc.so'. The first one is aimed to a builtin way usage. That API embeds Reindexer so it could be used right in-place as is. The second one acts as a lightweight client which establishes a connection to Reindexer server via RPC. The APIs interfaces are completely the same.

Attributes:

api (module): An API module loaded dynamically for Reindexer calls
rx (int): A memory pointer to Reindexer instance
err_code (int): the API error code
err_msg (string): the API error message

close

RxConnector.close(self)

Closes an API instance with Reindexer resources freeing

Returns:

None

namespace_open

RxConnector.namespace_open(self, namespace)

Opens a namespace specified or creates a namespace if it does not exist

Arguments:

namespace (string): A name of a namespace

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

namespace_close

RxConnector.namespace_close(self, namespace)

Closes a namespace specified

Arguments:

namespace (string): A name of a namespace

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

namespace_drop

RxConnector.namespace_drop(self, namespace)

Drops a namespace specified

Arguments:

namespace (string): A name of a namespace

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

namespaces_enum

RxConnector.namespaces_enum(self, enum_not_opened=False)

Gets a list of namespaces available

Arguments:

enum_not_opeden (bool, optional): An enumeration mode flag. If it is
    set then closed namespaces are in result list too. Defaults to False.

Returns:

(:obj:`list` of :obj:`dict`): A list of dictionaries which describe each namespace.

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

index_add

RxConnector.index_add(self, namespace, index_def)

Adds an index to the namespace specified

Arguments:

namespace (string): A name of a namespace
index_def (dict): A dictionary of index definiton

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

index_update

RxConnector.index_update(self, namespace, index_def)

Updates an index in the namespace specified

Arguments:

namespace (string): A name of a namespace
index_def (dict): A dictionary of index definiton

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

index_drop

RxConnector.index_drop(self, namespace, index_name)

Drops an index from the namespace specified

Arguments:

namespace (string): A name of a namespace
index_name (string): A name of an index

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

item_insert

RxConnector.item_insert(self, namespace, item_def, precepts=[])

Inserts an item with its precepts to the namespace specified.

Arguments:

namespace (string): A name of a namespace
item_def (dict): A dictionary of item definiton
precepts (:obj:`list` of :obj:`str`): A dictionary of index definiton

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

item_update

RxConnector.item_update(self, namespace, item_def, precepts=[])

Updates an item with its precepts in the namespace specified.

Arguments:

namespace (string): A name of a namespace
item_def (dict): A dictionary of item definiton
precepts (:obj:`list` of :obj:`str`): A dictionary of index definiton

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

item_upsert

RxConnector.item_upsert(self, namespace, item_def, precepts=[])

Updates an item with its precepts in the namespace specified. Creates the item if it not exist.

Arguments:

namespace (string): A name of a namespace
item_def (dict): A dictionary of item definiton
precepts (:obj:`list` of :obj:`str`): A dictionary of index definiton

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

item_delete

RxConnector.item_delete(self, namespace, item_def)

Deletes an item from the namespace specified.

Arguments:

namespace (string): A name of a namespace
item_def (dict): A dictionary of item definiton

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

commit

RxConnector.commit(self, namespace)

Flushes changes to a storage of Reindexer

Arguments:

namespace (string): A name of a namespace

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

meta_put

RxConnector.meta_put(self, namespace, key, value)

Puts metadata to a storage of Reindexer by key

Arguments:

namespace (string): A name of a namespace
key (string): A key in a storage of Reindexer for metadata keeping
value (string): A metadata for storage

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

meta_get

RxConnector.meta_get(self, namespace, key)

Gets metadata from a storage of Reindexer by key specified

Arguments:

namespace (string): A name of a namespace
key (string): A key in a storage of Reindexer where metadata is kept

Returns:

string: A metadata value

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

meta_enum

RxConnector.meta_enum(self, namespace)

Gets a list of metadata keys from a storage of Reindexer

Arguments:

namespace (string): A name of a namespace

Returns:

(:obj:`list` of :obj:`str`): A list of all metadata keys.

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

select

RxConnector.select(self, query)

Executes an SQL query and returns query results

Arguments:

query (string): An SQL query

Returns:

(:obj:`QueryResults`): A QueryResults iterator.

Raises:

Exception: Raises with an error message of API return if Reindexer instance is not initialized yet.
Exception: Raises with an error message of API return on non-zero error code.

pyreindexer.query_results

QueryResults

QueryResults(self, api, qres_wrapper_ptr, qres_iter_count)

QueryResults is a disposable iterator of Reindexer results for such queries as SELECT and etc. When the results are fetched the iterator closes and frees a memory of results buffer of Reindexer

Attributes:

api (module): An API module for Reindexer calls
err_code (int): the API error code
err_msg (string): the API error message
qres_wrapper_ptr (int): A memory pointer to Reindexer iterator object
qres_iter_count (int): A count of results for iterations
pos (int): The current result position in iterator

count

QueryResults.count(self)

Returns a count of results

Returns

int: A count of results

pyreindexer.index_definition

IndexDefinition

IndexDefinition(self, /, *args, **kwargs)

IndexDefinition is a dictionary subclass which allows to construct and manage indexes more efficiently. NOT IMPLEMENTED YET. USE FIELDS DESCRIPTION ONLY.

Arguments:

name (str): An index name.
json_paths (:obj:`list` of :obj:`str`): A name for mapping a value to a json field.
field_type (str): A type of a field. Possible values are: `int`, `int64`, `double`, `string`, `bool`, `composite`.
index_type (str): An index type. Possible values are: `hash`, `tree`, `text`, `-`.
is_pk (bool): True if a field is a primary key.
is_array (bool): True if an index is an array.
is_dense (bool): True if an index is dense. reduce index size. Saves 8 bytes per unique key value for 'hash' and 'tree' index types.
    For '-' index type saves 4-8 bytes per each element. Useful for indexes with high selectivity, but for tree and hash indexes with low selectivity could
    significantly decrease update performance.
is_sparse (bool): True if a value of an index may be not presented.
collate_mode (str): Sets an order of values by collate mode. Possible values are: `none`, `ascii`, `utf8`, `numeric`, `custom`.
sort_order_letters (str): Order for a sort sequence for a custom collate mode.
config (dict): A config for a fulltext engine. [More](https://github.com/Restream/reindexer/blob/master/fulltext.md) .

reindexer-py's People

Contributors

olegator77 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.