예제 #1
0
파일: parser.py 프로젝트: purpen/magnetodb
    def parse_select_type(cls,
                          select,
                          attributes_to_get,
                          select_on_index=False):
        if select is None:
            if attributes_to_get:
                return SelectType.specific_attributes(attributes_to_get)
            else:
                if select_on_index:
                    return SelectType.all_projected()
                else:
                    return SelectType.all()

        if select == Values.SPECIFIC_ATTRIBUTES:
            assert attributes_to_get
            return SelectType.specific_attributes(attributes_to_get)

        assert not attributes_to_get

        if select == Values.ALL_ATTRIBUTES:
            return SelectType.all()

        if select == Values.ALL_PROJECTED_ATTRIBUTES:
            assert select_on_index
            return SelectType.all_projected()

        if select == Values.COUNT:
            return SelectType.count()

        assert False, "Select type wasn't recognized"
예제 #2
0
    def parse_select_type(cls, select, attributes_to_get,
                          select_on_index=False):
        if select is None:
            if attributes_to_get:
                return SelectType.specific_attributes(
                    attributes_to_get
                )
            else:
                if select_on_index:
                    return SelectType.all_projected()
                else:
                    return SelectType.all()

        if select == Values.SPECIFIC_ATTRIBUTES:
            assert attributes_to_get
            return SelectType.specific_attributes(attributes_to_get)

        assert not attributes_to_get

        if select == Values.ALL_ATTRIBUTES:
            return SelectType.all()

        if select == Values.ALL_PROJECTED_ATTRIBUTES:
            assert select_on_index
            return SelectType.all_projected()

        if select == Values.COUNT:
            return SelectType.count()

        assert False, "Select type wasn't recognized"
예제 #3
0
    def _get_item_async(self, context, table_info, hash_key, range_key,
                        attributes_to_get, consistent=True):
        payload = dict(table_name=table_info.name,
                       hash_key=hash_key,
                       range_key=range_key,
                       attributes_to_get=attributes_to_get,
                       consistent=consistent)
        self._notifier.info(
            context,
            notifier.EVENT_TYPE_DATA_GETITEM_START,
            payload)
        select_type = (
            SelectType.all() if attributes_to_get is None else
            SelectType.specific_attributes(attributes_to_get)
        )
        hash_key_condition_list = [IndexedCondition.eq(hash_key)]
        range_key_condition_list = (
            None if range_key is None else [IndexedCondition.eq(range_key)]
        )

        result = self._execute_async(
            self._storage_driver.select_item,
            context, table_info, hash_key_condition_list,
            range_key_condition_list, select_type, consistent=consistent
        )
        self._notifier.info(
            context,
            notifier.EVENT_TYPE_DATA_GETITEM_END,
            payload)
        return result
예제 #4
0
    def _get_item_async(self, context, table_info, hash_key, range_key,
                        attributes_to_get, consistent=True):
        payload = dict(table_name=table_info.name,
                       hash_key=hash_key,
                       range_key=range_key,
                       attributes_to_get=attributes_to_get,
                       consistent=consistent)
        notifier.notify(context, notifier.EVENT_TYPE_DATA_SELECTITEM_START,
                        payload)
        select_type = (
            SelectType.all() if attributes_to_get is None else
            SelectType.specific_attributes(attributes_to_get)
        )
        hash_key_condition_list = [IndexedCondition.eq(hash_key)]
        range_key_condition_list = (
            None if range_key is None else [IndexedCondition.eq(range_key)]
        )

        result = self._execute_async(
            self._storage_driver.select_item,
            context, table_info, hash_key_condition_list,
            range_key_condition_list, select_type, consistent=consistent
        )
        notifier.notify(context, notifier.EVENT_TYPE_DATA_SELECTITEM_END,
                        payload)
        return result