How to use the pyignite.datatypes.String function in pyignite

To help you get started, we’ve selected a few pyignite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gridgain / gridgain / modules / platforms / python / pyignite / datatypes / binary.py View on Github external
# 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.
#
from pyignite.datatypes import Int, Bool, String, Struct, StructArray


binary_fields_struct = StructArray([
    ('field_name', String),
    ('type_id', Int),
    ('field_id', Int),
])

body_struct = Struct([
    ('type_id', Int),
    ('type_name', String),
    ('affinity_key_field', String),
    ('binary_fields', binary_fields_struct),
    ('is_enum', Bool),
])

enum_struct = StructArray([
    ('literal', String),
    ('type_id', Int),
])

schema_fields_struct = StructArray([
    ('schema_field_id', Int),
])

schema_struct = StructArray([
    ('schema_id', Int),
github gridgain / gridgain / modules / platforms / python / pyignite / api / binary.py View on Github external
schema_id = int_overflow(schema_id * FNV1_PRIME)

    data['schema'].append({
        'schema_id': schema_id,
        'schema_fields': [
            {'schema_field_id': entity_id(x)} for x in schema
        ],
    })

    # do query
    if is_enum:
        query_struct = Query(
            OP_PUT_BINARY_TYPE,
            [
                ('type_id', Int),
                ('type_name', String),
                ('affinity_key_field', String),
                ('binary_fields', binary_fields_struct),
                ('is_enum', Bool),
                ('enums', enum_struct),
                ('schema', schema_struct),
            ],
            query_id=query_id,
        )
    else:
        query_struct = Query(
            OP_PUT_BINARY_TYPE,
            [
                ('type_id', Int),
                ('type_name', String),
                ('affinity_key_field', String),
                ('binary_fields', binary_fields_struct),
github gridgain / gridgain / modules / platforms / python / pyignite / queries / response.py View on Github external
data_class = type(
                'SQLResponseData',
                (ctypes.LittleEndianStructure,),
                {
                    '_pack_': 1,
                    '_fields_': data_fields,
                }
            )
            fields += body_class._fields_ + [
                ('data', data_class),
                ('more', ctypes.c_bool),
            ]
            buffer += body_buffer + data_buffer
        else:
            c_type, buffer_fragment = String.parse(client)
            buffer += buffer_fragment
            fields.append(('error_message', c_type))

        final_class = type(
            'SQLResponse',
            (header_class,),
            {
                '_pack_': 1,
                '_fields_': fields,
            }
        )
        buffer += client.recv(ctypes.sizeof(final_class) - len(buffer))
        return final_class, buffer
github gridgain / gridgain / modules / platforms / python / pyignite / api / sql.py View on Github external
Value dict is of following format:

     * `cursor`: int, cursor ID,
     * `data`: list, result values,
     * `more`: bool, True if more data is available for subsequent
       ‘sql_fields_cursor_get_page’ calls.
    """
    if query_args is None:
        query_args = []

    query_struct = Query(
        OP_QUERY_SQL_FIELDS,
        [
            ('hash_code', Int),
            ('flag', Byte),
            ('schema', String),
            ('page_size', Int),
            ('max_rows', Int),
            ('query_str', String),
            ('query_args', AnyDataArray()),
            ('statement_type', StatementType),
            ('distributed_joins', Bool),
            ('local', Bool),
            ('replicated_only', Bool),
            ('enforce_join_order', Bool),
            ('collocated', Bool),
            ('lazy', Bool),
            ('timeout', Long),
            ('include_field_names', Bool),
        ],
        query_id=query_id,
    )
github gridgain / gridgain / modules / platforms / python / pyignite / datatypes / internal.py View on Github external
TC_BYTE_ARRAY: ByteArrayObject,
            TC_SHORT_ARRAY: ShortArrayObject,
            TC_INT_ARRAY: IntArrayObject,
            TC_LONG_ARRAY: LongArrayObject,
            TC_FLOAT_ARRAY: FloatArrayObject,
            TC_DOUBLE_ARRAY: DoubleArrayObject,
            TC_CHAR_ARRAY: CharArrayObject,
            TC_BOOL_ARRAY: BoolArrayObject,

            TC_UUID_ARRAY: UUIDArrayObject,
            TC_DATE_ARRAY: DateArrayObject,
            TC_TIMESTAMP_ARRAY: TimestampArrayObject,
            TC_TIME_ARRAY: TimeArrayObject,
            TC_ENUM_ARRAY: EnumArrayObject,

            TC_STRING: String,
            TC_STRING_ARRAY: StringArrayObject,
            TC_DECIMAL: DecimalObject,
            TC_DECIMAL_ARRAY: DecimalArrayObject,

            TC_OBJECT_ARRAY: ObjectArrayObject,
            TC_COLLECTION: CollectionObject,
            TC_MAP: MapObject,

            TC_COMPLEX_OBJECT: BinaryObject,
            TC_ARRAY_WRAPPED_OBJECTS: WrappedDataObject,
        }
    return _memo_map[key]
github gridgain / gridgain / modules / platforms / python / pyignite / api / result.py View on Github external
def __init__(self, response: 'Response'):
        self.status = response.status_code
        self.query_id = response.query_id
        if hasattr(response, 'error_message'):
            self.message = String.to_python(response.error_message)
github gridgain / gridgain / modules / platforms / python / pyignite / api / cache_config.py View on Github external
"""
    Creates a cache with a given name. Does nothing if the cache exists.

    :param connection: connection to Ignite server,
    :param name: cache name,
    :param query_id: (optional) a value generated by client and returned as-is
     in response.query_id. When the parameter is omitted, a random value
     is generated,
    :return: API result data object. Contains zero status if a cache is
     created successfully, non-zero status and an error description otherwise.
    """

    query_struct = Query(
        OP_CACHE_GET_OR_CREATE_WITH_NAME,
        [
            ('cache_name', String),
        ],
        query_id=query_id,
    )
    return query_struct.perform(
        connection,
        query_params={
            'cache_name': name,
        },
github gridgain / gridgain / modules / platforms / python / examples / migrate_binary.py View on Github external
from datetime import date
from decimal import Decimal

from pyignite import Client, GenericObjectMeta
from pyignite.datatypes import (
    BoolObject, DateObject, DecimalObject, LongObject, String,
)


# prepare old data
old_schema = OrderedDict([
    ('date', DateObject),
    ('reported', BoolObject),
    ('purpose', String),
    ('sum', DecimalObject),
    ('recipient', String),
    ('cashier_id', LongObject),
])

old_data = [
    (1, {
        'date': date(2017, 9, 21),
        'reported': True,
        'purpose': 'Praesent eget fermentum massa',
        'sum': Decimal('666.67'),
        'recipient': 'John Doe',
        'cashier_id': 8,
    }),
    (2, {
        'date': date(2017, 10, 11),
        'reported': True,
        'purpose': 'Proin in bibendum nulla',
github gridgain / gridgain / modules / platforms / python / pyignite / connection / handshake.py View on Github external
def __init__(
        self, username: Optional[str]=None, password: Optional[str]=None
    ):
        fields = [
            ('length', Int),
            ('op_code', Byte),
            ('version_major', Short),
            ('version_minor', Short),
            ('version_patch', Short),
            ('client_code', Byte),
        ]
        if username and password:
            self.username = username
            self.password = password
            fields.extend([
                ('username', String),
                ('password', String),
            ])
        self.handshake_struct = Struct(fields)