using the concurrentmap Map constructor in order to properly initialise the map everywhere it is used

This commit is contained in:
Alex Giurgiu
2023-11-13 21:28:14 +02:00
parent 3afc0b4449
commit d927344205
5 changed files with 9 additions and 2 deletions

View File

@@ -181,7 +181,7 @@ func CreateRepoState(fs filesys.ReadWriteFS, br string) (*RepoState, error) {
rs := &RepoState{
Head: ref.MarshalableRef{Ref: headRef},
Remotes: &concurrentmap.Map[string, Remote]{},
Remotes: concurrentmap.New[string, Remote](),
Branches: make(map[string]BranchConfig),
Backups: make(map[string]Remote),
}

View File

@@ -26,6 +26,7 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
"github.com/dolthub/dolt/go/libraries/utils/concurrentmap"
)
const DoltClusterDbName = "dolt_cluster"
@@ -111,6 +112,7 @@ func (db database) InitialDBState(ctx *sql.Context) (dsess.InitialDbState, error
Rsw: noopRepoStateWriter{},
},
ReadOnly: true,
Remotes: concurrentmap.New[string, env.Remote](),
}, nil
}

View File

@@ -417,7 +417,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
sess := dsess.DSessFromSess(ctx.Session)
adapter := dsess.NewSessionStateAdapter(
sess, db.RevisionQualifiedName(),
&concurrentmap.Map[string, env.Remote]{},
concurrentmap.New[string, env.Remote](),
map[string]env.BranchConfig{},
map[string]env.Remote{})
ws, err := sess.WorkingSet(ctx, db.RevisionQualifiedName())

View File

@@ -37,6 +37,7 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
"github.com/dolthub/dolt/go/libraries/doltcore/sqlserver"
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
"github.com/dolthub/dolt/go/libraries/utils/concurrentmap"
"github.com/dolthub/dolt/go/libraries/utils/filesys"
"github.com/dolthub/dolt/go/libraries/utils/lockutil"
"github.com/dolthub/dolt/go/store/datas"
@@ -1443,6 +1444,7 @@ func initialStateForTagDb(ctx context.Context, srcDb ReadOnlyDatabase) (dsess.In
Rsw: srcDb.DbData().Rsw,
Rsr: srcDb.DbData().Rsr,
},
Remotes: concurrentmap.New[string, env.Remote](),
// todo: should we initialize
// - Remotes
// - Branches
@@ -1493,6 +1495,7 @@ func initialStateForCommit(ctx context.Context, srcDb ReadOnlyDatabase) (dsess.I
Rsw: srcDb.DbData().Rsw,
Rsr: srcDb.DbData().Rsr,
},
Remotes: concurrentmap.New[string, env.Remote](),
// todo: should we initialize
// - Remotes
// - Branches

View File

@@ -21,6 +21,7 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
"github.com/dolthub/dolt/go/libraries/utils/concurrentmap"
)
// UserSpaceDatabase in an implementation of sql.Database for root values. Does not expose any of the internal dolt tables.
@@ -84,6 +85,7 @@ func (db *UserSpaceDatabase) InitialDBState(ctx *sql.Context) (dsess.InitialDbSt
DbData: env.DbData{
Rsw: noopRepoStateWriter{},
},
Remotes: concurrentmap.New[string, env.Remote](),
}, nil
}