MCPcopy Create free account
hub / github.com/baidu/tera / ScanTable

Function ScanTable

src/sample/tera_sample.cc:101–122  ·  view source on GitHub ↗

扫描一个表

Source from the content-addressed store, hash-verified

99
100/// 扫描一个表
101int ScanTable(tera::Table* table) {
102 tera::ErrorCode error_code;
103
104 // 创建一个scan表述
105 tera::ScanDescriptor scan_desc("com.baidu.");
106 // 只扫描百度主域
107 scan_desc.SetEnd("com.baidu.~");
108 // 设置扫描的column family
109 scan_desc.AddColumnFamily("anchor");
110 // 设置最多返回的版本
111 scan_desc.SetMaxVersions(3);
112 // 设置扫描的时间范围
113 scan_desc.SetTimeRange(time(NULL), time(NULL) - 3600);
114
115 tera::ResultStream* scanner = table->Scan(scan_desc, &error_code);
116 for (scanner->LookUp("com.baidu."); !scanner->Done(); scanner->Next()) {
117 printf("Row: %s\%s\%ld\%s\n", scanner->RowName().c_str(), scanner->ColumnName().c_str(),
118 scanner->Timestamp(), scanner->Value().c_str());
119 }
120 delete scanner;
121 return 0;
122}
123
124bool finish = false;
125

Callers 2

AddTableMetaMethod · 0.85
ExtractMetaDataMethod · 0.85

Calls 12

SetEndMethod · 0.45
AddColumnFamilyMethod · 0.45
SetMaxVersionsMethod · 0.45
SetTimeRangeMethod · 0.45
ScanMethod · 0.45
LookUpMethod · 0.45
DoneMethod · 0.45
NextMethod · 0.45
RowNameMethod · 0.45
ColumnNameMethod · 0.45
TimestampMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected