扫描一个表
| 99 | |
| 100 | /// 扫描一个表 |
| 101 | int 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 | |
| 124 | bool finish = false; |
| 125 |
no test coverage detected