def scan(table): from TeraSdk import ScanDescriptor scan_desc = ScanDescriptor("") scan_desc.SetBufferSize(1024 * 1024) # 1MB try: stream = table.Scan(scan_desc) except TeraSdkException as e: print(e.reason) return while not stream.Done(): row = stream.RowName() column = stream.ColumnName() timestamp = str(stream.Timestamp()) val = stream.Value() print row + ":" + column + ":" + timestamp + ":" + val stream.Next()
def scan_with_filter(table): from TeraSdk import ScanDescriptor scan_desc = ScanDescriptor("") scan_desc.SetBufferSize(1024 * 1024) # 1MB if not scan_desc.SetFilter("SELECT * WHERE int64 cf0 >= 0"): print("invalid filter") return try: stream = table.Scan(scan_desc) except TeraSdkException as e: print(e.reason) return while not stream.Done(): row = stream.RowName() column = stream.ColumnName() timestamp = str(stream.Timestamp()) val = stream.ValueInt64() print row + ":" + column + ":" + timestamp + ":" + str(val) stream.Next()
def scan_with_filter(table, filter_str): from TeraSdk import ScanDescriptor scan_desc = ScanDescriptor("") scan_desc.SetBufferSize(1024 * 1024) # 1MB if not scan_desc.SetFilter(filter_str): print("invalid filter") return list() try: stream = table.Scan(scan_desc) except TeraSdkException as e: print(e.reason) return list() res = list() while not stream.Done(): row = stream.RowName() col = stream.ColumnName() val = stream.ValueInt64() res.append(row + ":" + col + ":" + str(val)) stream.Next() return res