diff --git a/codec/codec.go b/codec/codec.go index 76314aecf95..a3e3be5016e 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -406,7 +406,8 @@ func Decode(pack *pb.UidPack, seek uint64) []uint64 { // DecodeToBuffer is the same as Decode but it returns a z.Buffer which is // calloc'ed and can be SHOULD be freed up by calling buffer.Release(). -func DecodeToBuffer(buf *z.Buffer, pack *pb.UidPack) { +func DecodeToBuffer(buf *z.Buffer, pack *pb.UidPack) *z.Buffer { + var last uint64 tmp := make([]byte, 16) dec := Decoder{Pack: pack} @@ -417,6 +418,7 @@ func DecodeToBuffer(buf *z.Buffer, pack *pb.UidPack) { last = u } } + return buf } func match32MSB(num1, num2 uint64) bool { diff --git a/codec/codec_test.go b/codec/codec_test.go index ca0c6b7747b..862fa885f06 100644 --- a/codec/codec_test.go +++ b/codec/codec_test.go @@ -76,7 +76,6 @@ func TestBufferUidPack(t *testing.T) { // Some edge case tests. pack := Encode([]uint64{}, 128) FreePack(pack) - buf := z.NewBuffer(10<<10, "TestBufferUidPack") defer buf.Release() DecodeToBuffer(buf, &pb.UidPack{}) diff --git a/dgraph/cmd/zero/zero_test.go b/dgraph/cmd/zero/zero_test.go index 9f4e18f113f..24366b71eef 100644 --- a/dgraph/cmd/zero/zero_test.go +++ b/dgraph/cmd/zero/zero_test.go @@ -21,11 +21,11 @@ import ( "math" "testing" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/testutil" + + "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) func TestRemoveNode(t *testing.T) { diff --git a/ee/acl/acl_test.go b/ee/acl/acl_test.go index 0a3e11295ce..cf9b66ac5bc 100644 --- a/ee/acl/acl_test.go +++ b/ee/acl/acl_test.go @@ -24,13 +24,13 @@ import ( "testing" "time" - "github.com/golang/glog" - "github.com/stretchr/testify/require" - "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" + + "github.com/golang/glog" + "github.com/stretchr/testify/require" ) var ( diff --git a/ee/backup/run.go b/ee/backup/run.go index 08ebc89672d..d0c0e817ea3 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -23,12 +23,6 @@ import ( "path/filepath" "time" - "github.com/golang/glog" - "github.com/pkg/errors" - "github.com/spf13/cobra" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/posting" @@ -36,6 +30,12 @@ import ( "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" ) // Restore is the sub-command used to restore a backup. @@ -467,10 +467,8 @@ func runExportBackup() error { if err := worker.RunReducer(w, mapDir); err != nil { return errors.Wrap(err, "Failed to reduce the map") } - if files, err := exportStorage.FinishWriting(writers); err != nil { + if _, err := exportStorage.FinishWriting(writers); err != nil { return errors.Wrap(err, "Failed to finish write") - } else { - glog.Infof("done exporting files: %v\n", files) } } return nil diff --git a/ee/vault/vault.go b/ee/vault/vault.go index 6c25b45ce51..64ad7a212a9 100644 --- a/ee/vault/vault.go +++ b/ee/vault/vault.go @@ -20,10 +20,10 @@ package vault import ( + "github.com/dgraph-io/dgraph/ee" + "github.com/golang/glog" "github.com/spf13/viper" - - "github.com/dgraph-io/dgraph/ee" ) func GetKeys(config *viper.Viper) (*ee.Keys, error) { diff --git a/ee/vault_ee.go b/ee/vault_ee.go index 6bf7dd78053..6a8cac42c31 100644 --- a/ee/vault_ee.go +++ b/ee/vault_ee.go @@ -19,12 +19,12 @@ import ( "io/ioutil" "reflect" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + "github.com/golang/glog" "github.com/hashicorp/vault/api" "github.com/spf13/viper" - - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" ) func vaultGetKeys(config *viper.Viper) (aclKey, encKey x.Sensitive) { diff --git a/graphql/admin/schema.go b/graphql/admin/schema.go index 9558aa806c9..80de5fc5cbb 100644 --- a/graphql/admin/schema.go +++ b/graphql/admin/schema.go @@ -19,6 +19,7 @@ package admin import ( "context" "encoding/json" + "github.com/dgraph-io/dgraph/worker" "github.com/golang/glog" diff --git a/systest/backup/multi-tenancy/backup_test.go b/systest/backup/multi-tenancy/backup_test.go index d38b9aa35f4..92ff15e8aa7 100644 --- a/systest/backup/multi-tenancy/backup_test.go +++ b/systest/backup/multi-tenancy/backup_test.go @@ -22,6 +22,8 @@ import ( "strings" "testing" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/stretchr/testify/require" "github.com/dgraph-io/dgo/v210" diff --git a/worker/acl_cache.go b/worker/acl_cache.go index 21bbf2c6176..5992a4859c4 100644 --- a/worker/acl_cache.go +++ b/worker/acl_cache.go @@ -16,10 +16,10 @@ package worker import ( "sync" - "github.com/pkg/errors" - "github.com/dgraph-io/dgraph/ee/acl" "github.com/dgraph-io/dgraph/x" + + "github.com/pkg/errors" ) // aclCache is the cache mapping group names to the corresponding group acls diff --git a/worker/acl_cache_test.go b/worker/acl_cache_test.go index c643489ef0f..ab3e543547a 100644 --- a/worker/acl_cache_test.go +++ b/worker/acl_cache_test.go @@ -16,10 +16,10 @@ package worker import ( "testing" - "github.com/stretchr/testify/require" - "github.com/dgraph-io/dgraph/ee/acl" "github.com/dgraph-io/dgraph/x" + + "github.com/stretchr/testify/require" ) func TestAclCache(t *testing.T) { diff --git a/worker/backup.go b/worker/backup.go index b25af95302e..c4f7cc13e57 100644 --- a/worker/backup.go +++ b/worker/backup.go @@ -20,11 +20,11 @@ import ( "context" "math" - "github.com/pkg/errors" - "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + + "github.com/pkg/errors" ) // predicateSet is a map whose keys are predicates. It is meant to be used as a set. diff --git a/worker/backup_ee.go b/worker/backup_ee.go index 17781207509..0ce41c07d3c 100644 --- a/worker/backup_ee.go +++ b/worker/backup_ee.go @@ -25,12 +25,6 @@ import ( "sync" "time" - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/golang/snappy" - "github.com/pkg/errors" - ostats "go.opencensus.io/stats" - "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/badger/v3/y" @@ -39,6 +33,12 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/golang/snappy" + "github.com/pkg/errors" + ostats "go.opencensus.io/stats" ) // Backup handles a request coming from another node. diff --git a/worker/backup_handler.go b/worker/backup_handler.go index a0ed316cb8b..1d40de13d48 100644 --- a/worker/backup_handler.go +++ b/worker/backup_handler.go @@ -23,13 +23,13 @@ import ( "path/filepath" "time" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" + "github.com/golang/glog" "github.com/minio/minio-go/v6" "github.com/minio/minio-go/v6/pkg/credentials" "github.com/pkg/errors" - - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" ) const ( diff --git a/worker/backup_manifest.go b/worker/backup_manifest.go index 51b27184229..859c936d2f6 100644 --- a/worker/backup_manifest.go +++ b/worker/backup_manifest.go @@ -20,10 +20,10 @@ import ( "sort" "strings" - "github.com/pkg/errors" - "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + + "github.com/pkg/errors" ) func verifyManifests(manifests []*Manifest) error { diff --git a/worker/backup_oss.go b/worker/backup_oss.go index 51bb405ba06..815632a241a 100644 --- a/worker/backup_oss.go +++ b/worker/backup_oss.go @@ -22,10 +22,10 @@ package worker import ( "context" - "github.com/golang/glog" - "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + + "github.com/golang/glog" ) // Backup implements the Worker interface. diff --git a/worker/cdc_ee.go b/worker/cdc_ee.go index cc1c31f44b2..57995eaf115 100644 --- a/worker/cdc_ee.go +++ b/worker/cdc_ee.go @@ -23,15 +23,15 @@ import ( "sync/atomic" "time" - "github.com/golang/glog" - "github.com/pkg/errors" - "go.etcd.io/etcd/raft/raftpb" - "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/golang/glog" + "github.com/pkg/errors" + "go.etcd.io/etcd/raft/raftpb" ) const ( diff --git a/worker/draft.go b/worker/draft.go index 42c4e2a22aa..ebadfde5433 100644 --- a/worker/draft.go +++ b/worker/draft.go @@ -28,16 +28,6 @@ import ( "sync/atomic" "time" - "github.com/dustin/go-humanize" - "github.com/golang/glog" - "github.com/pkg/errors" - "go.etcd.io/etcd/raft" - "go.etcd.io/etcd/raft/raftpb" - ostats "go.opencensus.io/stats" - "go.opencensus.io/tag" - otrace "go.opencensus.io/trace" - "golang.org/x/net/trace" - "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/conn" @@ -48,6 +38,16 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/dustin/go-humanize" + "github.com/golang/glog" + "github.com/pkg/errors" + "go.etcd.io/etcd/raft" + "go.etcd.io/etcd/raft/raftpb" + ostats "go.opencensus.io/stats" + "go.opencensus.io/tag" + otrace "go.opencensus.io/trace" + "golang.org/x/net/trace" ) type operation struct { diff --git a/worker/draft_test.go b/worker/draft_test.go index 82a87be409d..c569e95a940 100644 --- a/worker/draft_test.go +++ b/worker/draft_test.go @@ -21,13 +21,13 @@ import ( "os" "testing" - "github.com/stretchr/testify/require" - "go.etcd.io/etcd/raft/raftpb" - "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" + + "github.com/stretchr/testify/require" + "go.etcd.io/etcd/raft/raftpb" ) func getEntryForMutation(index, startTs uint64) raftpb.Entry { diff --git a/worker/export.go b/worker/export.go index ac6f1d45d9f..9c9d61b9dd3 100644 --- a/worker/export.go +++ b/worker/export.go @@ -32,10 +32,6 @@ import ( "strings" "time" - "github.com/golang/glog" - "github.com/minio/minio-go/v6" - "github.com/pkg/errors" - "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgo/v210/protos/api" @@ -46,6 +42,10 @@ import ( "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/golang/glog" + "github.com/minio/minio-go/v6" + "github.com/pkg/errors" ) // DefaultExportFormat stores the name of the default format for exports. diff --git a/worker/export_test.go b/worker/export_test.go index 3b5b7f02898..4a5e62cea1e 100644 --- a/worker/export_test.go +++ b/worker/export_test.go @@ -32,9 +32,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" - "github.com/stretchr/testify/require" - "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/dql" @@ -46,6 +43,9 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" + + "github.com/golang/protobuf/proto" + "github.com/stretchr/testify/require" ) const ( diff --git a/worker/graphql_schema.go b/worker/graphql_schema.go index fc183cfc201..26439ede976 100644 --- a/worker/graphql_schema.go +++ b/worker/graphql_schema.go @@ -22,14 +22,14 @@ import ( "sync" "time" - "github.com/golang/glog" - "github.com/pkg/errors" - "google.golang.org/grpc/metadata" - "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" + + "github.com/golang/glog" + "github.com/pkg/errors" + "google.golang.org/grpc/metadata" ) const ( diff --git a/worker/groups.go b/worker/groups.go index 455acb0cca8..4e036c8e370 100644 --- a/worker/groups.go +++ b/worker/groups.go @@ -25,10 +25,6 @@ import ( "sync/atomic" "time" - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/pkg/errors" - badgerpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/conn" @@ -38,6 +34,10 @@ import ( "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" ) type groupi struct { diff --git a/worker/online_restore.go b/worker/online_restore.go index 6fe53921451..b457cf9dbbb 100644 --- a/worker/online_restore.go +++ b/worker/online_restore.go @@ -25,12 +25,6 @@ import ( "sync" "time" - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/pkg/errors" - "github.com/spf13/pflag" - "github.com/spf13/viper" - "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgraph/conn" @@ -39,6 +33,12 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" + + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" + "github.com/spf13/pflag" + "github.com/spf13/viper" ) const ( diff --git a/worker/online_restore_oss.go b/worker/online_restore_oss.go index 47b8d5b475f..43ccdefec13 100644 --- a/worker/online_restore_oss.go +++ b/worker/online_restore_oss.go @@ -23,10 +23,9 @@ import ( "context" "sync" - "github.com/golang/glog" - "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/golang/glog" ) func ProcessRestoreRequest(ctx context.Context, req *pb.RestoreRequest, wg *sync.WaitGroup) error { diff --git a/worker/restore_map.go b/worker/restore_map.go index 0dc0731c1b3..ac642f56547 100644 --- a/worker/restore_map.go +++ b/worker/restore_map.go @@ -30,12 +30,6 @@ import ( "sync/atomic" "time" - "github.com/dustin/go-humanize" - "github.com/golang/glog" - "github.com/golang/snappy" - "github.com/pkg/errors" - "golang.org/x/sync/errgroup" - bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/codec" @@ -45,6 +39,12 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/dustin/go-humanize" + "github.com/golang/glog" + "github.com/golang/snappy" + "github.com/pkg/errors" + "golang.org/x/sync/errgroup" ) type backupReader struct { diff --git a/worker/restore_reduce.go b/worker/restore_reduce.go index c0a49c8a654..a99751a1770 100644 --- a/worker/restore_reduce.go +++ b/worker/restore_reduce.go @@ -25,14 +25,14 @@ import ( "sync/atomic" "time" - "github.com/dustin/go-humanize" - "github.com/golang/glog" - "github.com/golang/snappy" - "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" + + "github.com/dustin/go-humanize" + "github.com/golang/glog" + "github.com/golang/snappy" ) const (