get_scanner

获取scanner对象,用于指定范围的数据扫描。可以通过scan_options参数指定扫描的模式。

  1. def get_scanner(self, hash_key,
  2. start_sort_key, stop_sort_key,
  3. scan_options):
  4. """
  5. Get scanner for hash_key, start from start_sort_key, and stop at stop_sort_key.
  6. Whether the scanner include the start_sort_key and stop_sort_key is configurable by scan_options
  7. :param hash_key: (str) which hash key used for this API.
  8. :param start_sort_key: (str) returned scanner is start from start_sort_key.
  9. :param stop_sort_key: (str) returned scanner is stop at stop_sort_key.
  10. :param scan_options: (ScanOptions) configurable scan options.
  11. :return: (PegasusScanner) scanner, instance of PegasusScanner.
  12. """

其中,ScanOptions可以指定是否包含边界、超时时间、一次从replica server批量获取的sortkey-value数量等,具体定义如下:

  1. class ScanOptions(object):
  2. """
  3. configurable options for scan.
  4. """
  5. def __init__(self):
  6. self.timeout_millis = 5000
  7. self.batch_size = 1000
  8. self.start_inclusive = True
  9. self.stop_inclusive = False
  10. self.snapshot = None # for future use