| 1386 | } |
| 1387 | |
| 1388 | int MemTableSnapshot::DecodeData(std::shared_ptr<Table> table, const fedb::api::LogEntry& entry, |
| 1389 | uint32_t max_idx, std::vector<std::string>& row) { |
| 1390 | std::string buff; |
| 1391 | fedb::base::Slice data; |
| 1392 | if (table->GetCompressType() == fedb::type::kSnappy) { |
| 1393 | snappy::Uncompress(entry.value().data(), entry.value().size(), &buff); |
| 1394 | data.reset(buff.data(), buff.size()); |
| 1395 | } else { |
| 1396 | data.reset(entry.value().data(), entry.value().size()); |
| 1397 | } |
| 1398 | const int8_t* raw = reinterpret_cast<const int8_t*>(data.data()); |
| 1399 | uint8_t version = fedb::codec::RowView::GetSchemaVersion(raw); |
| 1400 | int32_t data_size = data.size(); |
| 1401 | std::shared_ptr<Schema> schema = table->GetVersionSchema(version); |
| 1402 | if (schema == nullptr) { |
| 1403 | LOG(WARNING) << "fail get version " << unsigned(version) << " schema"; |
| 1404 | return 1; |
| 1405 | } |
| 1406 | |
| 1407 | bool ok = fedb::codec::RowCodec::DecodeRow(*schema, raw, data_size, true, 0, max_idx + 1, row); |
| 1408 | if (!ok) { |
| 1409 | DLOG(WARNING) << "decode data error"; |
| 1410 | return 3; |
| 1411 | } |
| 1412 | if (schema->size() < (int64_t)(max_idx + 1)) { |
| 1413 | DLOG(WARNING) << "data size is " << schema->size() << " less than " << max_idx + 1; |
| 1414 | return 2; |
| 1415 | } |
| 1416 | return 0; |
| 1417 | } |
| 1418 | |
| 1419 | bool MemTableSnapshot::IsCompressed(const std::string& path) { |
| 1420 | if (path.find(fedb::log::ZLIB_COMPRESS_SUFFIX) != std::string::npos |
nothing calls this directly
no test coverage detected