Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/setup-go-5
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-spike authored Feb 12, 2025
2 parents f90c7e1 + d446cc7 commit d7c2412
Show file tree
Hide file tree
Showing 26 changed files with 207 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/create-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ jobs:

sign:
needs: build
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: 'Git checkout'
uses: actions/checkout@v4
Expand Down Expand Up @@ -333,11 +333,11 @@ jobs:
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3.4.0
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: setup jfrog
uses: jfrog/setup-jfrog-cli@v4
Expand Down
4 changes: 4 additions & 0 deletions cmd/flags/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
HnswMergeParallelism = "hnsw-merge-index-parallelism"
HnswMergeReIndexParallelism = "hnsw-merge-reindex-parallelism"
HnswVectorIntegrityCheck = "hnsw-vector-integrity-check"
IndexMode = "index-mode"
TLSProtocols = "tls-protocols"
TLSCaFile = "tls-cafile"
TLSCaPath = "tls-capath"
Expand All @@ -80,6 +81,9 @@ const (
MaxDataColWidthShort = "w"
YesShort = "y"

// Flag types
FlagTypeEnum = "enum"

DefaultIPv4 = "127.0.0.1"
DefaultPort = 5000

Expand Down
2 changes: 1 addition & 1 deletion cmd/flags/distanceMetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (f *DistanceMetricFlag) Set(val string) error {
}

func (f *DistanceMetricFlag) Type() string {
return "enum"
return FlagTypeEnum
}

func (f *DistanceMetricFlag) String() string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/flags/distanceMetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (suite *DistanceMetricFlagTestSuite) TestSet() {

func (suite *DistanceMetricFlagTestSuite) TestType() {
flag := DistanceMetricFlag("")
suite.Equal("enum", flag.Type())
suite.Equal(FlagTypeEnum, flag.Type())
}

func (suite *DistanceMetricFlagTestSuite) TestString() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/flags/logLevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (f *LogLevelFlag) Set(val string) error {
}

func (f *LogLevelFlag) Type() string {
return "enum"
return FlagTypeEnum
}

func (f *LogLevelFlag) String() string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/flags/logLevel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (suite *LogLevelSuite) TestSet() {

func (suite *LogLevelSuite) TestType() {
flag := LogLevelFlag("")
suite.Equal("enum", flag.Type())
suite.Equal(FlagTypeEnum, flag.Type())
}

func (suite *LogLevelSuite) TestString() {
Expand Down
50 changes: 50 additions & 0 deletions cmd/flags/optionals.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@ import (
"asvec/utils"
"fmt"
"math"
"slices"
"strconv"
"strings"
"time"

"github.com/aerospike/avs-client-go/protos"
)

var indexModeSet = protos.IndexMode_value
var indexModeNames []string

// sort the index mode names
// other optionals that require name sets should follow this pattern
func init() {
indexModeNames = make([]string, 0, len(indexModeSet))

for key := range indexModeSet {
indexModeNames = append(indexModeNames, key)
}

slices.Sort(indexModeNames)
}

const optionalEmptyString = "<nil>"

type StringOptionalFlag struct {
Expand Down Expand Up @@ -275,3 +293,35 @@ func (f *InfDurationOptionalFlag) Int64() *int64 {

return f.duration.Int64()
}

type IndexModeOptionalFlag struct {
Val *string
}

func (f *IndexModeOptionalFlag) Set(val string) error {
val = strings.ToUpper(val)
if _, ok := indexModeSet[val]; ok {
f.Val = &val
return nil
}

return fmt.Errorf("unrecognized index mode")
}

func (f *IndexModeOptionalFlag) Type() string {
return FlagTypeEnum
}

func (f *IndexModeOptionalFlag) String() string {
val := f.Val

if val != nil {
return *val
}

return optionalEmptyString
}

func IndexModeFlagEnum() []string {
return indexModeNames
}
18 changes: 18 additions & 0 deletions cmd/flags/optionals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,21 @@ func (suite *OptionalFlagSuite) TestInfDurationOptionalFlag() {
suite.Equal(expectedDuration.String(), f.String())
suite.Equal(expectedDuration.Milliseconds(), *f.Int64())
}

func (suite *OptionalFlagSuite) TestIndexModeOptionalFlag() {
f := &IndexModeOptionalFlag{}

err := f.Set("standalone")
if err != nil {
suite.T().Errorf("Unexpected error: %v", err)
}

if f.Val == nil || *f.Val != "STANDALONE" {
suite.T().Errorf("Expected 'approx', got %v", f.Val)
}

err = f.Set("not a mode")
if err == nil {
suite.T().Errorf("Expected error, got nil")
}
}
10 changes: 10 additions & 0 deletions cmd/indexCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"asvec/cmd/flags"
"asvec/utils"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -43,6 +44,7 @@ var indexCreateFlags = &struct {
hnswHealer flags.HealerFlags
hnswMerge flags.MergeFlags
hnswVectorIntegrityCheck flags.BoolOptionalFlag
indexMode flags.IndexModeOptionalFlag
}{
clientFlags: rootFlags.clientFlags,
set: flags.StringOptionalFlag{},
Expand All @@ -58,6 +60,7 @@ var indexCreateFlags = &struct {
hnswHealer: *flags.NewHnswHealerFlags(),
hnswMerge: *flags.NewHnswMergeFlags(),
hnswVectorIntegrityCheck: flags.BoolOptionalFlag{},
indexMode: flags.IndexModeOptionalFlag{},
}

func newIndexCreateFlagSet() *pflag.FlagSet {
Expand All @@ -83,6 +86,7 @@ func newIndexCreateFlagSet() *pflag.FlagSet {
flagSet.AddFlagSet(indexCreateFlags.hnswRecordCache.NewFlagSet())
flagSet.AddFlagSet(indexCreateFlags.hnswHealer.NewFlagSet())
flagSet.AddFlagSet(indexCreateFlags.hnswMerge.NewFlagSet())
flagSet.Var(&indexCreateFlags.indexMode, flags.IndexMode, fmt.Sprintf("The index mode. Valid values: %s", strings.Join(flags.IndexModeFlagEnum(), ", "))) //nolint:lll // For readability

// For backwards compatibility
flagSet.Var(&indexCreateFlags.set, "sets", "The sets for the index.")
Expand Down Expand Up @@ -325,6 +329,11 @@ func runCreateIndexFromFlags(client *avs.Client) error {
sets = append(sets, *indexCreateFlags.set.Val)
}

var indexMode *protos.IndexMode
if indexCreateFlags.indexMode.Val != nil {
indexMode = utils.Ptr(protos.IndexMode(protos.IndexMode_value[indexCreateFlags.indexMode.String()]))
}

indexOpts := &avs.IndexCreateOpts{
Sets: sets,
Labels: indexCreateFlags.indexLabels,
Expand Down Expand Up @@ -364,6 +373,7 @@ func runCreateIndexFromFlags(client *avs.Client) error {
},
EnableVectorIntegrityCheck: indexCreateFlags.hnswVectorIntegrityCheck.Val,
},
Mode: indexMode,
}

ctx, cancel := context.WithTimeout(context.Background(), indexCreateFlags.clientFlags.Timeout)
Expand Down
11 changes: 11 additions & 0 deletions cmd/indexUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package cmd

import (
"asvec/cmd/flags"
"asvec/utils"
"context"
"fmt"
"log/slog"
"strings"

"github.com/aerospike/avs-client-go/protos"
"github.com/spf13/cobra"
Expand All @@ -25,6 +27,7 @@ var indexUpdateFlags = &struct {
hnswHealer flags.HealerFlags
hnswMerge flags.MergeFlags
hnswVectorIntegrityCheck flags.BoolOptionalFlag
indexMode flags.IndexModeOptionalFlag
}{
clientFlags: rootFlags.clientFlags,
hnswMaxMemQueueSize: flags.Uint32OptionalFlag{},
Expand All @@ -34,6 +37,7 @@ var indexUpdateFlags = &struct {
hnswHealer: *flags.NewHnswHealerFlags(),
hnswMerge: *flags.NewHnswMergeFlags(),
hnswVectorIntegrityCheck: flags.BoolOptionalFlag{},
indexMode: flags.IndexModeOptionalFlag{},
}

func newIndexUpdateFlagSet() *pflag.FlagSet {
Expand All @@ -49,6 +53,7 @@ func newIndexUpdateFlagSet() *pflag.FlagSet {
flagSet.AddFlagSet(indexUpdateFlags.hnswRecordCache.NewFlagSet())
flagSet.AddFlagSet(indexUpdateFlags.hnswHealer.NewFlagSet())
flagSet.AddFlagSet(indexUpdateFlags.hnswMerge.NewFlagSet())
flagSet.Var(&indexUpdateFlags.indexMode, flags.IndexMode, fmt.Sprintf("The index mode. Valid values: %s", strings.Join(flags.IndexModeFlagEnum(), ", "))) //nolint:lll // For readability

return flagSet
}
Expand Down Expand Up @@ -139,6 +144,11 @@ asvec index update -i myindex -n test --%s 10000 --%s 10000ms --%s 10s --%s 16 -
EnableVectorIntegrityCheck: indexUpdateFlags.hnswVectorIntegrityCheck.Val,
}

var indexMode *protos.IndexMode
if indexUpdateFlags.indexMode.Val != nil {
indexMode = utils.Ptr(protos.IndexMode(protos.IndexMode_value[indexUpdateFlags.indexMode.String()]))
}

ctx, cancel := context.WithTimeout(context.Background(), indexUpdateFlags.clientFlags.Timeout)
defer cancel()

Expand All @@ -148,6 +158,7 @@ asvec index update -i myindex -n test --%s 10000 --%s 10000ms --%s 10s --%s 16 -
indexUpdateFlags.indexName,
indexUpdateFlags.indexLabels,
hnswParams,
indexMode,
)
if err != nil {
logger.Error("unable to update index", slog.Any("error", err))
Expand Down
16 changes: 16 additions & 0 deletions cmd/writers/indexList.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func NewIndexTableWriter(writer io.Writer, verbose bool, logger *slog.Logger) *I
"Vector Records",
"Size",
"Unmerged %",
"Mode*",
"Status",
}
verboseHeadings := append(table.Row{}, headings...)
verboseHeadings = append(
Expand All @@ -41,6 +43,7 @@ func NewIndexTableWriter(writer io.Writer, verbose bool, logger *slog.Logger) *I
"Labels*",
"Storage",
"Index Parameters",
"Standalone Index Metrics",
)

if verbose {
Expand Down Expand Up @@ -84,6 +87,8 @@ func (itw *IndexTableWriter) AppendIndexRow(
status.GetIndexHealerVectorRecordsIndexed(),
formatBytes(calculateIndexSize(index, status)),
getPercentUnmerged(status),
index.Mode,
status.Status,
}

if itw.verbose {
Expand Down Expand Up @@ -129,6 +134,17 @@ func (itw *IndexTableWriter) AppendIndexRow(
default:
itw.logger.Warn("the server returned unrecognized index type params. recognized index param types are: HNSW")
}

if *index.Mode == protos.IndexMode_STANDALONE {
tStandaloneIndexMetrics := NewDefaultWriter(nil)
tStandaloneIndexMetrics.SetTitle("Standalone Index Metrics")
tStandaloneIndexMetrics.AppendRows([]table.Row{
{"State", status.StandaloneIndexMetrics.GetState()},
{"Inserted Records", status.StandaloneIndexMetrics.GetInsertedRecordCount()},
})

row = append(row, renderTable(tStandaloneIndexMetrics, format))
}
}

itw.table.AppendRow(row)
Expand Down
2 changes: 2 additions & 0 deletions cmd/writers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func Test_formatRole(t *testing.T) {
},
{
name: "TestRoleSecondary",
//nolint:staticcheck // This value is deprecated but is still returned by the server as a default node role
args: args{role: protos.NodeRole_INDEX_UPDATE},
want: "INDEX_UPDATE",
},
Expand Down Expand Up @@ -55,6 +56,7 @@ func Test_formatRoles(t *testing.T) {
args: args{
roles: []protos.NodeRole{
protos.NodeRole_INDEX_QUERY,
//nolint:staticcheck // This value is deprecated but is still returned by the server as a default node role
protos.NodeRole_INDEX_UPDATE,
protos.NodeRole_KV_READ,
},
Expand Down
2 changes: 1 addition & 1 deletion docker/auth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
timeout: 20s
retries: 20
avs:
image: aerospike/aerospike-vector-search:1.0.0
image: aerospike.jfrog.io/docker/aerospike/aerospike-vector-search-private:1.0.1-SNAPSHOT
depends_on:
aerospike:
condition: service_healthy
Expand Down
2 changes: 1 addition & 1 deletion docker/mtls/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
timeout: 20s
retries: 20
avs:
image: aerospike/aerospike-vector-search:1.0.0
image: aerospike.jfrog.io/docker/aerospike/aerospike-vector-search-private:1.0.1-SNAPSHOT
depends_on:
aerospike:
condition: service_healthy
Expand Down
6 changes: 3 additions & 3 deletions docker/multi-node-LB/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
depends_on:
aerospike:
condition: service_healthy
image: aerospike/aerospike-vector-search:1.0.0
image: aerospike.jfrog.io/docker/aerospike/aerospike-vector-search-private:1.0.1-SNAPSHOT
volumes:
- ./config/aerospike-vector-search-1.yml:/etc/aerospike-vector-search/aerospike-vector-search.yml
- type: bind
Expand All @@ -39,7 +39,7 @@ services:
depends_on:
aerospike:
condition: service_healthy
image: aerospike/aerospike-vector-search:1.0.0
image: aerospike.jfrog.io/docker/aerospike/aerospike-vector-search-private:1.0.1-SNAPSHOT
volumes:
- ./config/aerospike-vector-search-2.yml:/etc/aerospike-vector-search/aerospike-vector-search.yml
- type: bind
Expand All @@ -56,7 +56,7 @@ services:
depends_on:
aerospike:
condition: service_healthy
image: aerospike/aerospike-vector-search:1.0.0
image: aerospike.jfrog.io/docker/aerospike/aerospike-vector-search-private:1.0.1-SNAPSHOT
volumes:
- ./config/aerospike-vector-search-3.yml:/etc/aerospike-vector-search/aerospike-vector-search.yml
- type: bind
Expand Down
Loading

0 comments on commit d7c2412

Please sign in to comment.