forked from ydb-platform/ydb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sys view for granules (ydb-platform#3498)
- Loading branch information
1 parent
c97ef92
commit a833a43
Showing
15 changed files
with
245 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
ydb/core/tx/columnshard/engines/reader/sys_view/granules/granules.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "granules.h" | ||
#include <ydb/core/formats/arrow/switch/switch_type.h> | ||
#include <ydb/core/tx/columnshard/blobs_action/common/const.h> | ||
#include <ydb/core/tx/columnshard/engines/reader/abstract/read_context.h> | ||
#include <util/system/hostname.h> | ||
|
||
namespace NKikimr::NOlap::NReader::NSysView::NGranules { | ||
|
||
void TStatsIterator::AppendStats(const std::vector<std::unique_ptr<arrow::ArrayBuilder>>& builders, NAbstract::TGranuleMetaView& granule) const { | ||
NArrow::Append<arrow::UInt64Type>(*builders[0], granule.GetPathId()); | ||
NArrow::Append<arrow::UInt64Type>(*builders[1], ReadMetadata->TabletId); | ||
NArrow::Append<arrow::UInt64Type>(*builders[2], granule.GetPortions().size()); | ||
NArrow::Append<arrow::StringType>(*builders[3], HostNameField); | ||
NArrow::Append<arrow::UInt64Type>(*builders[4], NActors::TActivationContext::AsActorContext().SelfID.NodeId()); | ||
while (granule.PopFrontPortion()) { | ||
} | ||
} | ||
|
||
std::unique_ptr<TScanIteratorBase> TReadStatsMetadata::StartScan(const std::shared_ptr<TReadContext>& readContext) const { | ||
return std::make_unique<TStatsIterator>(readContext->GetReadMetadataPtrVerifiedAs<TReadStatsMetadata>()); | ||
} | ||
|
||
std::vector<std::pair<TString, NKikimr::NScheme::TTypeInfo>> TReadStatsMetadata::GetKeyYqlSchema() const { | ||
return GetColumns(TStatsIterator::StatsSchema, TStatsIterator::StatsSchema.KeyColumns); | ||
} | ||
|
||
std::shared_ptr<NAbstract::TReadStatsMetadata> TConstructor::BuildMetadata(const NColumnShard::TColumnShard* self, const TReadDescription& read) const { | ||
auto* index = self->GetIndexOptional(); | ||
return std::make_shared<TReadStatsMetadata>(index ? index->CopyVersionedIndexPtr() : nullptr, self->TabletID(), | ||
IsReverse ? TReadMetadataBase::ESorting::DESC : TReadMetadataBase::ESorting::ASC, | ||
read.GetProgram(), index ? index->GetVersionedIndex().GetSchema(read.GetSnapshot()) : nullptr, read.GetSnapshot()); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
ydb/core/tx/columnshard/engines/reader/sys_view/granules/granules.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
#include <ydb/core/sys_view/common/schema.h> | ||
#include <ydb/core/tx/columnshard/engines/reader/sys_view/abstract/abstract.h> | ||
#include <ydb/core/tx/columnshard/engines/reader/sys_view/constructor/constructor.h> | ||
#include <util/system/hostname.h> | ||
|
||
namespace NKikimr::NOlap::NReader::NSysView::NGranules { | ||
|
||
class TConstructor: public TStatScannerConstructor<NKikimr::NSysView::Schema::PrimaryIndexGranuleStats> { | ||
private: | ||
using TBase = TStatScannerConstructor<NKikimr::NSysView::Schema::PrimaryIndexGranuleStats>; | ||
protected: | ||
virtual std::shared_ptr<NAbstract::TReadStatsMetadata> BuildMetadata(const NColumnShard::TColumnShard* self, const TReadDescription& read) const override; | ||
|
||
public: | ||
using TBase::TBase; | ||
}; | ||
|
||
struct TReadStatsMetadata: public NAbstract::TReadStatsMetadata { | ||
private: | ||
using TBase = NAbstract::TReadStatsMetadata; | ||
using TSysViewSchema = NKikimr::NSysView::Schema::PrimaryIndexGranuleStats; | ||
public: | ||
using TBase::TBase; | ||
|
||
virtual std::unique_ptr<TScanIteratorBase> StartScan(const std::shared_ptr<TReadContext>& readContext) const override; | ||
virtual std::vector<std::pair<TString, NScheme::TTypeInfo>> GetKeyYqlSchema() const override; | ||
}; | ||
|
||
class TStatsIterator : public NAbstract::TStatsIterator<NKikimr::NSysView::Schema::PrimaryIndexGranuleStats> { | ||
private: | ||
const std::string HostNameField = HostName(); | ||
using TBase = NAbstract::TStatsIterator<NKikimr::NSysView::Schema::PrimaryIndexGranuleStats>; | ||
virtual ui32 PredictRecordsCount(const NAbstract::TGranuleMetaView& /*granule*/) const override { | ||
return 1; | ||
} | ||
virtual void AppendStats(const std::vector<std::unique_ptr<arrow::ArrayBuilder>>& builders, NAbstract::TGranuleMetaView& granule) const override; | ||
public: | ||
using TBase::TBase; | ||
}; | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
ydb/core/tx/columnshard/engines/reader/sys_view/granules/ya.make
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LIBRARY() | ||
|
||
PEERDIR( | ||
ydb/core/tx/columnshard/engines/reader/sys_view/abstract | ||
) | ||
|
||
SRCS( | ||
granules.cpp | ||
) | ||
|
||
END() | ||
|
Oops, something went wrong.