get_scanner
获取scanner对象,用于指定范围的数据扫描。可以通过scan_options
参数指定扫描的模式。
def get_scanner(self, hash_key,
start_sort_key, stop_sort_key,
scan_options):
"""
Get scanner for hash_key, start from start_sort_key, and stop at stop_sort_key.
Whether the scanner include the start_sort_key and stop_sort_key is configurable by scan_options
:param hash_key: (str) which hash key used for this API.
:param start_sort_key: (str) returned scanner is start from start_sort_key.
:param stop_sort_key: (str) returned scanner is stop at stop_sort_key.
:param scan_options: (ScanOptions) configurable scan options.
:return: (PegasusScanner) scanner, instance of PegasusScanner.
"""
其中,ScanOptions
可以指定是否包含边界、超时时间、一次从replica server批量获取的sortkey-value数量等,具体定义如下:
class ScanOptions(object):
"""
configurable options for scan.
"""
def __init__(self):
self.timeout_millis = 5000
self.batch_size = 1000
self.start_inclusive = True
self.stop_inclusive = False
self.snapshot = None # for future use