jina.types.querylang.queryset.helper

jina.types.querylang.queryset.helper.iff(precond, val, f)[source]

If and only if the precond is True

Shortcut function for precond(val) and f(val). It is mainly used to create partial functions for commonly required preconditions

:param precond : (function) represents the precondition :type val: Union[int, str] :param val: (mixed) value to which the functions are applied :type f: Callable :param f: (function) the actual function :rtype: bool :return: whether or not the cond is satisfied

jina.types.querylang.queryset.helper.iff_not_none(val: Union[int, str], f: Callable)bool

If and only if the precond is True

Shortcut function for precond(val) and f(val). It is mainly used to create partial functions for commonly required preconditions

:param precond : (function) represents the precondition :param val: (mixed) value to which the functions are applied :param f: (function) the actual function :return: whether or not the cond is satisfied

jina.types.querylang.queryset.helper.guard_type(classinfo, val)[source]

Make sure the type of :param:`val` is :param:`classinfo`.

Parameters
  • classinfo (Union[Type[str], Type[Iterable]]) – Guard type.

  • val (Union[str, List[int]]) – Target object.

Return type

Union[str, List[int]]

Returns

:param:`val` if it has correct type.

jina.types.querylang.queryset.helper.guard_str(val: Union[str, List[int]])Union[str, List[int]]

Make sure the type of :param:`val` is :param:`classinfo`.

Parameters
  • classinfo – Guard type.

  • val – Target object.

Returns

:param:`val` if it has correct type.

jina.types.querylang.queryset.helper.guard_iter(val: Union[str, List[int]])Union[str, List[int]]

Make sure the type of :param:`val` is :param:`classinfo`.

Parameters
  • classinfo – Guard type.

  • val – Target object.

Returns

:param:`val` if it has correct type.

jina.types.querylang.queryset.helper.guard_int(val: Union[str, List[int]])Union[str, List[int]]

Make sure the type of :param:`val` is :param:`classinfo`.

Parameters
  • classinfo – Guard type.

  • val – Target object.

Returns

:param:`val` if it has correct type.