从python瘦客户端调用put_all时出现错误

问题描述 投票:1回答:1

我正在研究示例“ create_binary.py”,而不是将其放入缓存,而是尝试put_all来缓存多个记录。尽管put成功,但是put_all给出了错误。

student_cache = client.get_or_create_cache({
    PROP_NAME: 'SQL_PUBLIC_STUDENT',
    PROP_SQL_SCHEMA: 'PUBLIC',
    PROP_QUERY_ENTITIES: [
        {
            'table_name': 'Student'.upper(),
            'key_field_name': 'SID',
            'key_type_name': 'java.lang.Integer',
            'field_name_aliases': [],
            'query_fields': [
                {
                    'name': 'SID',
                    'type_name': 'java.lang.Integer',
                    'is_key_field': True,
                    'is_notnull_constraint_field': True,
                },
                {
                    'name': 'NAME',
                    'type_name': 'java.lang.String',
                },
                {
                    'name': 'LOGIN',
                    'type_name': 'java.lang.String',
                },
                {
                    'name': 'AGE',
                    'type_name': 'java.lang.Integer',
                },
                {
                    'name': 'GPA',
                    'type_name': 'java.math.Double',
                },
            ],
            'query_indexes': [],
            'value_type_name': 'SQL_PUBLIC_STUDENT_TYPE',
            'value_field_name': None,
        },
    ],
})

工作正常

student_cache.put(
1,
Student(LOGIN='jdoe', NAME='John Doe', AGE=17, GPA=4.25),
key_hint=IntObject
)

全部不工作

student_cache.put_all({1: Student(LOGIN='jdoe', NAME='John Doe', AGE=17, GPA=4.25), 2: Student(LOGIN='jdoe2', NAME='John Doe2', AGE=18, GPA=4.25)})

[put_all给出错误:

追踪(最近一次通话):文件“ C:/ignite/pyignite/examples/create_binary.py”,第105行,在student_cache.put_all({1:Student(LOGIN ='jdoe',NAME ='John Doe',AGE = 17,GPA = 4.25),2:Student(LOGIN ='jdoe2',NAME ='John Doe2',AGE = 18岁GPA = 4.25)})文件“ C:\ Users \ nbkmqoi \ AppData \ Roaming \ Python \ Python35 \ site-packages \ pyignite \ utils.py”,第169行,在ste_wrapper中引发exc(result.message)pyignite.exceptions.CacheError:无法更新密钥(如果可能,请重试更新。):[1,2]

我如何使put_all工作?谢谢!

python thin-client
1个回答
0
投票

我想通了。需要使用键在turple中添加数据类型

student_cache.put_all({(1,IntObject):学生(LOGIN ='jdoe',NAME ='John Doe',AGE = 17,GPA = 4.25),((2,IntObject)] >> :学生(LOGIN ='jdoe2',NAME ='John Doe2',AGE = 18,GPA = 4.25)})

© www.soinside.com 2019 - 2024. All rights reserved.