| 442 | } |
| 443 | |
| 444 | int |
| 445 | StripeSM::dir_probe(CryptoHash *key, [[maybe_unused]] CacheDirEntry *result, [[maybe_unused]] CacheDirEntry **last_collision) |
| 446 | { |
| 447 | int segment = key->slice32(0) % this->_segments; |
| 448 | int bucket = key->slice32(1) % this->_buckets; |
| 449 | |
| 450 | CacheDirEntry *seg = this->dir_segment(segment); |
| 451 | CacheDirEntry *e = nullptr; |
| 452 | e = dir_bucket(bucket, seg); |
| 453 | char *stripe_buff2 = nullptr; |
| 454 | Doc *doc = nullptr; |
| 455 | // TODO: collision craft is pending.. look at the main ATS code. Assuming no collision for now |
| 456 | if (dir_offset(e)) { |
| 457 | do { |
| 458 | if (dir_compare_tag(e, key)) { |
| 459 | if (dir_valid(e)) { |
| 460 | stripe_buff2 = static_cast<char *>(ats_memalign(ats_pagesize(), dir_approx_size(e))); |
| 461 | std::cout << "dir_probe hit: found seg: " << segment << " bucket: " << bucket << " offset: " << dir_offset(e) |
| 462 | << "size: " << dir_approx_size(e) << std::endl; |
| 463 | break; |
| 464 | } else { |
| 465 | // let's skip deleting for now |
| 466 | // e = dir_delete_entry(e, p ,segment); |
| 467 | // continue; |
| 468 | } |
| 469 | } |
| 470 | e = next_dir(e, seg); |
| 471 | |
| 472 | } while (e); |
| 473 | if (e == nullptr) { |
| 474 | std::cout << "No directory entry found matching the URL key" << std::endl; |
| 475 | return 0; |
| 476 | } |
| 477 | int fd = _span->_fd; |
| 478 | Bytes offset = stripe_offset(e); |
| 479 | int64_t size = dir_approx_size(e); |
| 480 | ssize_t n = pread(fd, stripe_buff2, size, offset); |
| 481 | if (n < size) { |
| 482 | std::cout << "Failed to read content from the Stripe:" << strerror(errno) << std::endl; |
| 483 | } |
| 484 | |
| 485 | doc = reinterpret_cast<Doc *>(stripe_buff2); |
| 486 | std::string hdr(doc->hdr(), doc->hlen); |
| 487 | |
| 488 | std::string data_(doc->data(), doc->data_len()); |
| 489 | std::cout << "DATA\n" << data_ << std::endl; |
| 490 | } else { |
| 491 | std::cout << "Not found in the Cache" << std::endl; |
| 492 | } |
| 493 | free(stripe_buff2); |
| 494 | return 0; // Why does this have a non-void return? |
| 495 | } |
| 496 | |
| 497 | CacheDirEntry * |
| 498 | StripeSM::dir_delete_entry(CacheDirEntry *e, CacheDirEntry *p, int s) |
no test coverage detected