Skip to content

Commit

Permalink
enhance: Fix go&cpp lint issues
Browse files Browse the repository at this point in the history
See also milvus-io#34483

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia committed Jul 30, 2024
1 parent fa9d606 commit 244a0f9
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 40 deletions.
6 changes: 3 additions & 3 deletions internal/core/src/common/QueryResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ struct VectorIterator {
for (auto& iter : iterators_) {
if (iter->HasNext()) {
auto origin_pair = iter->Next();
origin_pair.first = convert_to_segment_offset(
origin_pair.first, idx);
origin_pair.first =
convert_to_segment_offset(origin_pair.first, idx);
auto off_dis_pair =
std::make_shared<OffsetDisPair>(origin_pair, idx++);
std::make_shared<OffsetDisPair>(origin_pair, idx++);
heap_.push(off_dis_pair);
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/exec/expression/UnaryExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ PhyUnaryRangeFilterExpr::ExecArrayEqualForIndex(bool reverse) {

// filtering by index, get candidates.
auto size_per_chunk = segment_->size_per_chunk();
auto retrieve = [ size_per_chunk, this ](int64_t offset) -> auto{
auto retrieve = [ size_per_chunk, this ](int64_t offset) -> auto {
auto chunk_idx = offset / size_per_chunk;
auto chunk_offset = offset % size_per_chunk;
const auto& chunk =
Expand Down
10 changes: 5 additions & 5 deletions internal/core/src/monitor/prometheus_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ const prometheus::Histogram::BucketBoundaries bytesBuckets = {
536870912, // 512M
1073741824}; // 1G

const prometheus::Histogram::BucketBoundaries ratioBuckets =
{0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0};
const prometheus::Histogram::BucketBoundaries ratioBuckets = {
0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0};

const std::unique_ptr<PrometheusClient>
prometheusClient = std::make_unique<PrometheusClient>();
const std::unique_ptr<PrometheusClient> prometheusClient =
std::make_unique<PrometheusClient>();

/******************GetMetrics*************************************************************
* !!! NOT use SUMMARY metrics here, because when parse SUMMARY metrics in Milvus,
Expand Down
25 changes: 11 additions & 14 deletions internal/core/src/query/SubSearchResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
namespace milvus::query {
class SubSearchResult {
public:
SubSearchResult(
int64_t num_queries,
int64_t topk,
const MetricType& metric_type,
int64_t round_decimal,
const std::vector<knowhere::IndexNode::IteratorPtr>& iters)
SubSearchResult(int64_t num_queries,
int64_t topk,
const MetricType& metric_type,
int64_t round_decimal,
const std::vector<knowhere::IndexNode::IteratorPtr>& iters)
: num_queries_(num_queries),
topk_(topk),
round_decimal_(round_decimal),
Expand All @@ -41,12 +40,11 @@ class SubSearchResult {
int64_t topk,
const MetricType& metric_type,
int64_t round_decimal)
: SubSearchResult(
num_queries,
topk,
metric_type,
round_decimal,
std::vector<knowhere::IndexNode::IteratorPtr>{}) {
: SubSearchResult(num_queries,
topk,
metric_type,
round_decimal,
std::vector<knowhere::IndexNode::IteratorPtr>{}) {
}

SubSearchResult(SubSearchResult&& other) noexcept
Expand Down Expand Up @@ -130,8 +128,7 @@ class SubSearchResult {
knowhere::MetricType metric_type_;
std::vector<int64_t> seg_offsets_;
std::vector<float> distances_;
std::vector<knowhere::IndexNode::IteratorPtr>
chunk_iterators_;
std::vector<knowhere::IndexNode::IteratorPtr> chunk_iterators_;
};

} // namespace milvus::query
3 changes: 1 addition & 2 deletions internal/core/src/query/visitors/ExecPlanNodeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ ExecPlanNodeVisitor::VectorVisitorImpl(VectorPlanNode& node) {
double total_cost =
std::chrono::duration<double, std::micro>(vector_end - scalar_start)
.count();
double scalar_ratio =
total_cost > 0.0 ? scalar_cost / total_cost : 0.0;
double scalar_ratio = total_cost > 0.0 ? scalar_cost / total_cost : 0.0;
monitor::internal_core_search_latency_scalar_proportion.Observe(
scalar_ratio);
}
Expand Down
7 changes: 4 additions & 3 deletions internal/core/src/storage/DiskFileManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,10 @@ DiskFileManagerImpl::CacheRawDataToDisk(std::vector<std::string> remote_files) {
if (data_type == milvus::DataType::VECTOR_SPARSE_FLOAT) {
dim = std::max(
dim,
(uint32_t)(std::dynamic_pointer_cast<
FieldData<SparseFloatVector>>(field_data)
->Dim()));
(uint32_t)(
std::dynamic_pointer_cast<FieldData<SparseFloatVector>>(
field_data)
->Dim()));
auto sparse_rows =
static_cast<const knowhere::sparse::SparseRow<float>*>(
field_data->Data());
Expand Down
15 changes: 7 additions & 8 deletions internal/core/unittest/test_utils/DataGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,13 @@ GenerateRandomSparseFloatVector(size_t rows,
return tensor;
}

inline GeneratedData
DataGen(SchemaPtr schema,
int64_t N,
uint64_t seed = 42,
uint64_t ts_offset = 0,
int repeat_count = 1,
int array_len = 10,
bool random_pk = false) {
inline GeneratedData DataGen(SchemaPtr schema,
int64_t N,
uint64_t seed = 42,
uint64_t ts_offset = 0,
int repeat_count = 1,
int array_len = 10,
bool random_pk = false) {
using std::vector;
std::default_random_engine random(seed);
std::normal_distribution<> distr(0, 1);
Expand Down
2 changes: 1 addition & 1 deletion internal/distributed/proxy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s *Server) startHTTPServer(errChan chan error) {
// Process request
c.Next()

latency := time.Now().Sub(start)
latency := time.Since(start)
metrics.RestfulReqLatency.WithLabelValues(
strconv.FormatInt(paramtable.GetNodeID(), 10), path,
).Observe(float64(latency.Milliseconds()))
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/accesslog/info/grpc_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
"path"
"time"

"github.com/golang/protobuf/proto"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"

"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/proxy/connection"
Expand Down
1 change: 1 addition & 0 deletions internal/querycoordv2/balance/score_based_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ func (suite *ScoreBasedBalancerTestSuite) TestDelegatorPreserveMemory() {
segmentPlans, channelPlans = suite.getCollectionBalancePlans(balancer, c.collectionID)
suite.Len(segmentPlans, 1)
suite.Equal(segmentPlans[0].To, int64(2))
suite.Len(channelPlans, 0)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/paramtable/component_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ type queryCoordConfig struct {
RowCountMaxSteps ParamItem `refreshable:"true"`
RandomMaxSteps ParamItem `refreshable:"true"`
GrowingRowCountWeight ParamItem `refreshable:"true"`
DelegatorMemoryOverloadFactor ParamItem `refreshable:"true`
DelegatorMemoryOverloadFactor ParamItem `refreshable:"true"`
BalanceCostThreshold ParamItem `refreshable:"true"`

SegmentCheckInterval ParamItem `refreshable:"true"`
Expand Down Expand Up @@ -1638,7 +1638,7 @@ type queryCoordConfig struct {
CollectionObserverInterval ParamItem `refreshable:"false"`
CheckExecutedFlagInterval ParamItem `refreshable:"false"`
UpdateCollectionLoadStatusInterval ParamItem `refreshable:"false"`
CollectionBalanceSegmentBatchSize ParamItem `refreshable true`
CollectionBalanceSegmentBatchSize ParamItem `refreshable:"true"`
}

func (p *queryCoordConfig) init(base *BaseTable) {
Expand Down

0 comments on commit 244a0f9

Please sign in to comment.