示例#1
0
 def get_connection(cls, table_object_name):
     if table_object_name not in cls._connection_dict:
         if cls._region_conn is None:
             cls._region_conn = get_dynamodb_connection()
         table_properties = cls._TABLE_NAME_TO_PROPERTIES[table_object_name]
         avro_schema = get_avro_schema(table_properties['avro_schema'])
         table_name = read_string(table_properties['physical_id_key'])
         table = Table(table_name, connection=cls._region_conn)
         try:
             results = table.describe()
             raw_indexes = results['Table'].get('GlobalSecondaryIndexes',
                                                [])
             table.global_indexes = introspect_global_indexes(raw_indexes)
         except Exception:
             log_exception("Table Connection Failed")
         cls._connection_dict[table_object_name] = table_properties[
             'class'](table, avro_schema)
     return cls._connection_dict[table_object_name]
示例#2
0
 def get_connection(cls, table_object_name):
     if table_object_name not in cls._connection_dict:
         if cls._region_conn is None:
             cls._region_conn = get_dynamodb_connection()
         table_properties = cls._TABLE_NAME_TO_PROPERTIES[table_object_name]
         avro_schema = get_avro_schema(table_properties['avro_schema'])
         table_name = read_string(table_properties['physical_id_key'])
         table = Table(
             table_name,
             connection=cls._region_conn
         )
         try:
             results = table.describe()
             raw_indexes = results['Table'].get('GlobalSecondaryIndexes', [])
             table.global_indexes = introspect_global_indexes(raw_indexes)
         except Exception:
             log_exception("Table Connection Failed")
         cls._connection_dict[table_object_name] = table_properties['class'](
             table,
             avro_schema
         )
     return cls._connection_dict[table_object_name]
示例#3
0
def test_introspect_global_indexes():
    indexes = introspect_global_indexes(safe_load(raw_indexes))
    assert len(indexes) == 3
    for index in indexes:
        assert isinstance(index, GlobalAllIndex)
示例#4
0
def test_introspect_global_indexes():
    indexes = introspect_global_indexes(safe_load(raw_indexes))
    assert len(indexes) == 3
    for index in indexes:
        assert isinstance(index, GlobalAllIndex)