From 50d6a8cf0fff6976f22da79a1ab83ac3fefebad3 Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Tue, 20 Aug 2024 17:36:42 +0900 Subject: [PATCH] fix Signed-off-by: Kosuke Morimoto --- pkg/agent/core/ngt/handler/grpc/index.go | 20 +++++++++++ pkg/agent/core/ngt/service/ngt.go | 44 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/pkg/agent/core/ngt/handler/grpc/index.go b/pkg/agent/core/ngt/handler/grpc/index.go index 3a55be3983..62df71e180 100644 --- a/pkg/agent/core/ngt/handler/grpc/index.go +++ b/pkg/agent/core/ngt/handler/grpc/index.go @@ -240,3 +240,23 @@ func (s *server) IndexStatisticsDetail( }, }, nil } + +func (s *server) IndexProperty( + ctx context.Context, _ *payload.Empty, +) (res *payload.Info_Index_PropertyDetail, err error) { + _, span := trace.StartSpan(ctx, apiName+".IndexStatisticsDetail") + defer func() { + if span != nil { + span.End() + } + }() + prop, err := s.ngt.IndexProperty() + if err != nil { + return nil, err + } + return &payload.Info_Index_PropertyDetail{ + Details: map[string]*payload.Info_Index_Property{ + s.name: prop, + }, + }, nil +} diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index ba0c11319a..095f0b6f0a 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -92,6 +92,7 @@ type NGT interface { BrokenIndexCount() uint64 IndexStatistics() (*payload.Info_Index_Statistics, error) IsStatisticsEnabled() bool + IndexProperty() (*payload.Info_Index_Property, error) Close(ctx context.Context) error } @@ -2044,6 +2045,49 @@ func (n *ngt) IsStatisticsEnabled() bool { return n.enableStatistics } +func (n *ngt) IndexProperty() (*payload.Info_Index_Property, error) { + p, err := n.core.GetProperty() + if err != nil { + return nil, err + } + return &payload.Info_Index_Property{ + Dimension: p.Dimension, + ThreadPoolSize: p.ThreadPoolSize, + ObjectType: p.ObjectType.String(), + DistanceType: p.DistanceType.String(), + IndexType: p.IndexType.String(), + DatabaseType: p.DatabaseType.String(), + ObjectAlignment: p.ObjectAlignment.String(), + PathAdjustmentInterval: p.PathAdjustmentInterval, + GraphSharedMemorySize: p.GraphSharedMemorySize, + TreeSharedMemorySize: p.TreeSharedMemorySize, + ObjectSharedMemorySize: p.ObjectSharedMemorySize, + PrefetchOffset: p.PrefetchOffset, + PrefetchSize: p.PrefetchSize, + AccuracyTable: p.AccuracyTable, + SearchType: p.SearchType, + MaxMagnitude: p.MaxMagnitude, + NOfNeighborsForInsertionOrder: p.NOfNeighborsForInsertionOrder, + EpsilonForInsertionOrder: p.EpsilonForInsertionOrder, + RefinementObjectType: p.RefinementObjectType.String(), + TruncationThreshold: p.TruncationThreshold, + EdgeSizeForCreation: p.EdgeSizeForCreation, + EdgeSizeForSearch: p.EdgeSizeForSearch, + EdgeSizeLimitForCreation: p.EdgeSizeLimitForCreation, + InsertionRadiusCoefficient: p.InsertionRadiusCoefficient, + SeedSize: p.SeedSize, + SeedType: p.SeedType.String(), + TruncationThreadPoolSize: p.TruncationThreadPoolSize, + BatchSizeForCreation: p.BatchSizeForCreation, + GraphType: p.GraphType.String(), + DynamicEdgeSizeBase: p.DynamicEdgeSizeBase, + DynamicEdgeSizeRate: p.DynamicEdgeSizeRate, + BuildTimeLimit: p.BuildTimeLimit, + OutgoingEdge: p.OutgoingEdge, + IncomingEdge: p.IncomingEdge, + }, nil +} + func (n *ngt) toSearchResponse( sr []algorithm.SearchResult, ) (res *payload.Search_Response, err error) {