From 335c82f8ecbbb13b1304bf24c2b13974bb5b43fb Mon Sep 17 00:00:00 2001 From: HarrisChu <1726587+HarrisChu@users.noreply.github.com> Date: Mon, 13 Apr 2026 15:53:14 +0800 Subject: [PATCH] skip scan --- pkg/common/env.go | 5 +++++ pkg/common/env_test.go | 8 ++++++++ pkg/nebulagraph5/client.go | 11 ++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pkg/common/env.go b/pkg/common/env.go index 649d37f..77d1747 100644 --- a/pkg/common/env.go +++ b/pkg/common/env.go @@ -4,6 +4,7 @@ import "github.com/kelseyhightower/envconfig" type Environment struct { NebulaStmtPrefix string `envconfig:"STMT_PREFIX" ` + NebulaSkipScan bool `envconfig:"SKIP_SCAN" default:"false"` } var nebulaEnv *Environment @@ -27,3 +28,7 @@ func ProcessStmt(stmt string) string { } return stmt } + +func ShouldSkipScan() bool { + return nebulaEnv.NebulaSkipScan +} diff --git a/pkg/common/env_test.go b/pkg/common/env_test.go index 14d9c1f..e4574cf 100644 --- a/pkg/common/env_test.go +++ b/pkg/common/env_test.go @@ -18,3 +18,11 @@ func TestProcessStmt(t *testing.T) { getEnv() assert.Equal(t, "nebula stmt", ProcessStmt("stmt")) } + +func TestSkipScan(t *testing.T) { + getEnv() + assert.False(t, ShouldSkipScan()) + os.Setenv("NEBULA_SKIP_SCAN", "true") + getEnv() + assert.True(t, ShouldSkipScan()) +} diff --git a/pkg/nebulagraph5/client.go b/pkg/nebulagraph5/client.go index edc32a6..64bc941 100644 --- a/pkg/nebulagraph5/client.go +++ b/pkg/nebulagraph5/client.go @@ -354,11 +354,12 @@ func (gc *GraphClient) Execute(stmt string) (common.IGraphResponse, error) { } } } - //TODO could add a flag to just decode the first row - if rows != 0 { - for resp.HasNext() { - if err := resp.Scan(anyValues...); err != nil { - return nil, err + if !common.ShouldSkipScan() { + if rows != 0 { + for resp.HasNext() { + if err := resp.Scan(anyValues...); err != nil { + return nil, err + } } } }