MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getBySerializedKeys

Method getBySerializedKeys

src/Storages/StorageKeeperMap.cpp:1470–1548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1468}
1469
1470Chunk StorageKeeperMap::getBySerializedKeys(
1471 const std::span<const std::string> keys, PaddedPODArray<UInt8> * null_map, bool with_version, const ContextPtr & local_context) const
1472{
1473 auto metadata_snapshot = getInMemoryMetadataPtr(local_context, false);
1474 Block sample_block = metadata_snapshot->getSampleBlock();
1475 MutableColumns columns = sample_block.cloneEmptyColumns();
1476 MutableColumnPtr version_column = nullptr;
1477
1478 if (with_version)
1479 version_column = ColumnVector<Int32>::create();
1480
1481 size_t primary_key_pos = getPrimaryKeyPos(sample_block, getPrimaryKey());
1482
1483 if (null_map)
1484 {
1485 null_map->clear();
1486 null_map->resize_fill(keys.size(), 1);
1487 }
1488
1489 Strings full_key_paths;
1490 full_key_paths.reserve(keys.size());
1491
1492 for (const auto & key : keys)
1493 full_key_paths.emplace_back(fullPathForKey(key));
1494
1495 const auto & settings = local_context->getSettingsRef();
1496 ZooKeeperRetriesControl zk_retry{
1497 getName(),
1498 getLogger(getName()),
1499 ZooKeeperRetriesInfo{
1500 settings[Setting::keeper_max_retries],
1501 settings[Setting::keeper_retry_initial_backoff_ms],
1502 settings[Setting::keeper_retry_max_backoff_ms],
1503 local_context->getProcessListElement()}};
1504
1505 zkutil::ZooKeeper::MultiTryGetResponse values;
1506 zk_retry.retryLoop([&]{
1507 auto client = getClient();
1508 values = client->tryGet(full_key_paths);
1509 });
1510
1511 for (size_t i = 0; i < keys.size(); ++i)
1512 {
1513 auto response = values[i];
1514
1515 Coordination::Error code = response.error;
1516
1517 if (code == Coordination::Error::ZOK)
1518 {
1519 fillColumns(base64Decode(keys[i], true), response.data, primary_key_pos, sample_block, columns);
1520
1521 if (version_column)
1522 version_column->insert(response.stat.version);
1523 }
1524 else if (code == Coordination::Error::ZNONODE)
1525 {
1526 if (null_map)
1527 {

Callers 1

generateMethod · 0.45

Calls 15

getPrimaryKeyPosFunction · 0.85
getClientFunction · 0.85
fillColumnsFunction · 0.85
base64DecodeFunction · 0.85
resize_fillMethod · 0.80
retryLoopMethod · 0.80
columnsMethod · 0.80
createFunction · 0.70
ChunkClass · 0.70
getNameFunction · 0.50
getLoggerFunction · 0.50
ExceptionClass · 0.50

Tested by

no test coverage detected