From d2ec1777ecad0a17e8962b7f8f1caa0a9c54da24 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Mon, 2 Jan 2023 10:31:06 +0800 Subject: [PATCH] Updated the license header for the new files linkedmap.go and linkedmap_test.go Also resolved a couple of golangci linter warnings. Signed-off-by: Benjamin Wang --- tools/rw-benchmark/linkedmap.go | 17 ++++++++++++++--- tools/rw-benchmark/linkedmap_test.go | 15 +++++++++++++-- tools/rw-benchmark/plot_data.go | 8 ++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tools/rw-benchmark/linkedmap.go b/tools/rw-benchmark/linkedmap.go index d101e24cd3d2..83e1d828fbdb 100644 --- a/tools/rw-benchmark/linkedmap.go +++ b/tools/rw-benchmark/linkedmap.go @@ -1,5 +1,16 @@ -// Copyright (c) 2019, Benjamin Wang (benjamin_wang@aliyun.com). All rights reserved. -// Licensed under the MIT license that can be found in the LICENSE file. +// Copyright 2022 The etcd Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. // Package linkedmap implements a linked hashmap, based on a map and a doubly linked list. The iteration ordering is normally // the order in which keys were inserted into the map, or the order in which the keys were accessed if the accessOrder flag is set. @@ -115,7 +126,7 @@ func (lm *linkedMap) IsEmpty() bool { } func (lm *linkedMap) Put(k, v interface{}) interface{} { - var retVal interface{} = nil + var retVal interface{} if oldElement, ok := lm.data[k]; ok { retVal = oldElement.value diff --git a/tools/rw-benchmark/linkedmap_test.go b/tools/rw-benchmark/linkedmap_test.go index 0dae405373f0..ae8c4271fa2f 100644 --- a/tools/rw-benchmark/linkedmap_test.go +++ b/tools/rw-benchmark/linkedmap_test.go @@ -1,5 +1,16 @@ -// Copyright (c) 2019, Benjamin Wang (benjamin_wang@aliyun.com). All rights reserved. -// Licensed under the MIT license that can be found in the LICENSE file. +// Copyright 2022 The etcd Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. package main diff --git a/tools/rw-benchmark/plot_data.go b/tools/rw-benchmark/plot_data.go index 915d7709d849..563e1f90751c 100644 --- a/tools/rw-benchmark/plot_data.go +++ b/tools/rw-benchmark/plot_data.go @@ -152,16 +152,16 @@ func loadCSV(filename string) (LinkedMap, error) { if len(qps) != 2 { return nil, fmt.Errorf("unexpected qps values %q at file %q:%d", rec[j], filename, i) } - read_qps, err := strconv.ParseFloat(qps[0], 64) + readQPS, err := strconv.ParseFloat(qps[0], 64) if err != nil { return nil, fmt.Errorf("failed to parse read qps %q at file %q:%d, error: %w", qps[0], filename, i, err) } - sumReadQPS += read_qps - write_qps, err := strconv.ParseFloat(qps[1], 64) + sumReadQPS += readQPS + writeQPS, err := strconv.ParseFloat(qps[1], 64) if err != nil { return nil, fmt.Errorf("failed to parse write qps %q at file %q:%d, error: %w", qps[1], filename, i, err) } - sumWriteQPS += write_qps + sumWriteQPS += writeQPS } avgReadQPS, avgWriteQPS = sumReadQPS/float64(cnt), sumWriteQPS/float64(cnt)