Skip to content

Commit

Permalink
take prefix from virtual index
Browse files Browse the repository at this point in the history
  • Loading branch information
diPhantxm authored and reshke committed Oct 31, 2024
1 parent eca0b54 commit ea69edd
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/yproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "util.h"
#include "virtual_index.h"
#include <iostream>
#include <set>
#include <sys/socket.h>

#include <unistd.h>
Expand Down Expand Up @@ -667,17 +668,25 @@ int YProxyLister::prepareYproxyConnection() {
}

std::vector<storageChunkMeta> YProxyLister::list_relation_chunks() {
std::vector<storageChunkMeta> res;
auto ret = prepareYproxyConnection();
if (ret != 0) {
// throw?
return res;
}

auto order = YezzeyVirtualGetOrder(YezzeyFindAuxIndex(adv_->reloid), adv_->reloid,
adv_->coords_.filenode, adv_->coords_.blkno);
std::set<std::string> xpaths;
for (auto& chunk : order) {
auto msg = ConstructListRequest(chunk.x_path);
int i = 0;
for (int n = 0; n != 8 && i < chunk.x_path.size(); ++n)
i = chunk.x_path.find('_', i+1);
xpaths.insert(chunk.x_path.substr(0, i));
}

std::vector<storageChunkMeta> res;
for (auto& xpath : xpaths) {
auto ret = prepareYproxyConnection();
if (ret != 0) {
// throw?
return res;
}

auto msg = ConstructListRequest(xpath);
size_t rc = ::write(client_fd_, msg.data(), msg.size());
if (rc <= 0) {
// throw?
Expand All @@ -695,6 +704,7 @@ std::vector<storageChunkMeta> YProxyLister::list_relation_chunks() {
break;
case MessageTypeReadyForQuery:
more = false;
break;

default:
// throw?
Expand Down

0 comments on commit ea69edd

Please sign in to comment.