コード例 #1
0
    def _get_java_object(self):
        from maprdb.connection import Connection
        maprdb = Connection.get_instance().MapRDB
        java_document = maprdb.newDocument()

        for k,v in self.items():
            java_document.set(python_to_java_cast(k),python_to_java_cast(v))

        return java_document
コード例 #2
0
    def _get_java_object(self):
        from maprdb.connection import Connection
        maprdb = Connection.get_instance().MapRDB
        java_document = maprdb.newDocument()

        for k, v in self.items():
            java_document.set(python_to_java_cast(k), python_to_java_cast(v))

        return java_document
コード例 #3
0
    def find_by_condition(self, condition, columns=None):
        """
        Returns a generator that iterates over all documents that satisfy the passed condition.

        :param condition: maprdb.document.Condition class instance
        :param columns: list of strings, which
        specifies certain columns to select from the returned document.
        :returns: generator, which returns maprdb.document.Document class instances.
        """
        document_stream = self.java_table.find(
            python_to_java_cast(condition),
            columns) if columns else self.java_table.find(
                python_to_java_cast(condition))
        return self._find_by_java_document_stream(document_stream)
コード例 #4
0
    def insert_or_replace(self, doc, key=None):
        """
        Insert the document in the database. If the document already exists, it gets replaced.

        :param doc: maprdb.document.Document class instance, that should have an _id field. If not present an exception should be raised.
        If the user specific a key, it will be added to the document automatically as _id field, if the document contains an _id and a key is passed, an maprdb.utils.MapRDBError will be raised.
        :param key: string value, which is _id of the record to find.
        """
        doc = self._fill_document_key(doc, key=key)
        self.java_table.insertOrReplace(python_to_java_cast(doc))
コード例 #5
0
ファイル: tables.py プロジェクト: mapr-demos/python-bindings
    def insert_or_replace(self, doc, key=None):
        """
        Insert the document in the database. If the document already exists, it gets replaced.

        :param doc: maprdb.document.Document class instance, that should have an _id field. If not present an exception should be raised.
        If the user specific a key, it will be added to the document automatically as _id field, if the document contains an _id and a key is passed, an maprdb.utils.MapRDBError will be raised.
        :param key: string value, which is _id of the record to find.
        """
        doc = self._fill_document_key(doc, key=key)
        self.java_table.insertOrReplace(python_to_java_cast(doc))
コード例 #6
0
ファイル: mutation.py プロジェクト: yarabarla/python-bindings
    def append(self, field_name, value):
        """
        Appends the specified value to the specified field.

        :param field_name: string value, which is a name of field to set.
        :param value: a list or string value to append.
        :return: maprdb.mutation.Mutation resulting instance
        """
        self.java_mutation = self.java_mutation.append(
            field_name, python_to_java_cast(value))
        return self
コード例 #7
0
ファイル: mutation.py プロジェクト: yarabarla/python-bindings
    def set_or_replace(self, field_name, value):
        """
        Sets the value of a field conditionally. If a previous value exists, it is overwritten.

        :param field_name: string value, which is a name of field to set.
        :param value: a list, dictionary, numeric or date value to set for the field.
        :return: maprdb.mutation.Mutation resulting instance
        """
        self.java_mutation = self.java_mutation.setOrReplace(
            field_name, python_to_java_cast(value))
        return self
コード例 #8
0
ファイル: mutation.py プロジェクト: yarabarla/python-bindings
    def set(self, field_name, value):
        """
        Sets the value of a field if no previous value exists.

        :param field_name: string value, which is a name of field to set.
        :param value: a list, dictionary, numeric or date value to set for the field.
        :return: maprdb.mutation.Mutation resulting instance
        """
        self.java_mutation = self.java_mutation.set(field_name,
                                                    python_to_java_cast(value))
        return self
コード例 #9
0
ファイル: tables.py プロジェクト: mapr-demos/python-bindings
    def find_by_condition(self, condition, columns=None):
        """
        Returns a generator that iterates over all documents that satisfy the passed condition.

        :param condition: maprdb.document.Condition class instance
        :param columns: list of strings, which
        specifies certain columns to select from the returned document.
        :returns: generator, which returns maprdb.document.Document class instances.
        """
        document_stream = self.java_table.find(python_to_java_cast(condition), columns) if columns else self.java_table.find(python_to_java_cast(condition))
        return self._find_by_java_document_stream(document_stream)
コード例 #10
0
    def update(self, key, mutation):
        """
        Performs the requested mutation on the document with the specified key(s).

        :param key: string value or list of strings, if it is a list,
        then the same mutation will be applied to each document specified by the elements of the list.
        :param mutation: maprdb.mutation.Mutation class instance, which is a mutation to perform.
        """
        keys_list = key if isinstance(key, (list, tuple)) else [key]

        for k in keys_list:
            self.java_table.update(k, python_to_java_cast(mutation))
コード例 #11
0
ファイル: tables.py プロジェクト: mapr-demos/python-bindings
    def update(self, key, mutation):
        """
        Performs the requested mutation on the document with the specified key(s).

        :param key: string value or list of strings, if it is a list,
        then the same mutation will be applied to each document specified by the elements of the list.
        :param mutation: maprdb.mutation.Mutation class instance, which is a mutation to perform.
        """
        keys_list = key if isinstance(key, (list,tuple)) else [key]

        for k in keys_list:
            self.java_table.update(k, python_to_java_cast(mutation))
コード例 #12
0
 def _is(self, field, condition, value):
     value = python_to_java_cast(value)
     self.java_condition = self.java_condition.is_(field, condition, value)
     return self
コード例 #13
0
 def _is(self, field, condition, value):
     value = python_to_java_cast(value)
     self.java_condition = self.java_condition.is_(field, condition, value)
     return self