Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 1424c9d

Browse files
authored
Remove quesma/concurrent (#1022)
Moving `concurrent.Map` to `util.SyncMap` Related: #1017
1 parent dff14b8 commit 1424c9d

22 files changed

+167
-176
lines changed

quesma/clickhouse/clickhouse.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"context"
77
"database/sql"
88
"fmt"
9-
"quesma/concurrent"
109
"quesma/end_user_errors"
1110
"quesma/logger"
1211
"quesma/persistence"
@@ -34,7 +33,7 @@ type (
3433
cfg *config.QuesmaConfiguration
3534
phoneHomeAgent telemetry.PhoneHomeAgent
3635
}
37-
TableMap = concurrent.Map[string, *Table]
36+
TableMap = util.SyncMap[string, *Table]
3837
SchemaMap = map[string]interface{} // TODO remove
3938
Attribute struct {
4039
KeysArrayName string
@@ -68,7 +67,7 @@ type (
6867
)
6968

7069
func NewTableMap() *TableMap {
71-
return concurrent.NewMap[string, *Table]()
70+
return util.NewSyncMap[string, *Table]()
7271
}
7372

7473
func (lm *LogManager) Start() {

quesma/clickhouse/clickhouse_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ package clickhouse
44

55
import (
66
"context"
7-
"quesma/concurrent"
87
"quesma/quesma/config"
98
"quesma/quesma/types"
9+
"quesma/util"
1010
"strings"
1111
"sync/atomic"
1212
"testing"
@@ -646,49 +646,49 @@ func TestLogManager_GetTable(t *testing.T) {
646646
}{
647647
{
648648
name: "empty",
649-
predefinedTables: *concurrent.NewMap[string, *Table](),
649+
predefinedTables: *util.NewSyncMap[string, *Table](),
650650
tableNamePattern: "table",
651651
found: false,
652652
},
653653
{
654654
name: "should find by name",
655-
predefinedTables: *concurrent.NewMapWith("table1", &Table{Name: "table1"}),
655+
predefinedTables: *util.NewSyncMapWith("table1", &Table{Name: "table1"}),
656656
tableNamePattern: "table1",
657657
found: true,
658658
},
659659
{
660660
name: "should not find by name",
661-
predefinedTables: *concurrent.NewMapWith("table1", &Table{Name: "table1"}),
661+
predefinedTables: *util.NewSyncMapWith("table1", &Table{Name: "table1"}),
662662
tableNamePattern: "foo",
663663
found: false,
664664
},
665665
{
666666
name: "should find by pattern",
667-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
667+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
668668
tableNamePattern: "logs-generic-*",
669669
found: true,
670670
},
671671
{
672672
name: "should find by pattern",
673-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
673+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
674674
tableNamePattern: "*-*-*",
675675
found: true,
676676
},
677677
{
678678
name: "should find by pattern",
679-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
679+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
680680
tableNamePattern: "logs-*-default",
681681
found: true,
682682
},
683683
{
684684
name: "should find by pattern",
685-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
685+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
686686
tableNamePattern: "*",
687687
found: true,
688688
},
689689
{
690690
name: "should not find by pattern",
691-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
691+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &Table{Name: "logs-generic-default"}),
692692
tableNamePattern: "foo-*",
693693
found: false,
694694
},
@@ -784,7 +784,7 @@ func TestLogManager_ResolveIndexes(t *testing.T) {
784784
}
785785

786786
func newTableMap(tables ...string) *TableMap {
787-
newMap := concurrent.NewMap[string, *Table]()
787+
newMap := util.NewSyncMap[string, *Table]()
788788
for _, table := range tables {
789789
newMap.Store(table, &Table{Name: table})
790790
}

quesma/concurrent/map.go

Lines changed: 0 additions & 100 deletions
This file was deleted.

quesma/ingest/alter_table_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ package ingest
55
import (
66
"github.com/stretchr/testify/assert"
77
"quesma/clickhouse"
8-
"quesma/concurrent"
98
"quesma/quesma/config"
109
"quesma/quesma/types"
1110
"quesma/schema"
11+
"quesma/util"
1212
"strconv"
1313
"testing"
1414
)
@@ -45,7 +45,7 @@ func TestAlterTable(t *testing.T) {
4545
Name: "tableName",
4646
Cols: map[string]*clickhouse.Column{},
4747
}
48-
fieldsMap := concurrent.NewMapWith("tableName", table)
48+
fieldsMap := util.NewSyncMapWith("tableName", table)
4949

5050
encodings := make(map[schema.FieldEncodingKey]schema.EncodedFieldName)
5151

@@ -108,7 +108,7 @@ func TestAlterTableHeuristic(t *testing.T) {
108108
Name: tableName,
109109
Cols: map[string]*clickhouse.Column{},
110110
}
111-
fieldsMap := concurrent.NewMapWith(tableName, table)
111+
fieldsMap := util.NewSyncMapWith(tableName, table)
112112
ip := newIngestProcessorWithEmptyTableMap(fieldsMap, &config.QuesmaConfiguration{})
113113

114114
rowsToInsert := make([]string, 0)

quesma/ingest/ingest_validator_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/DATA-DOG/go-sqlmock"
1010
"github.com/stretchr/testify/assert"
1111
"quesma/clickhouse"
12-
"quesma/concurrent"
1312
"quesma/quesma/config"
1413
"quesma/quesma/types"
1514
"quesma/table_resolver"
@@ -124,7 +123,7 @@ func TestIngestValidation(t *testing.T) {
124123
fmt.Sprintf(`INSERT INTO "%s" FORMAT JSONEachRow {"uint8_field":255}`, tableName),
125124
fmt.Sprintf(`INSERT INTO "%s" FORMAT JSONEachRow {"attributes_values":{"uint8_field":"1000"},"attributes_metadata":{"uint8_field":"v1;Int64"}}`, tableName),
126125
}
127-
tableMap := concurrent.NewMapWith(tableName, &clickhouse.Table{
126+
tableMap := util.NewSyncMapWith(tableName, &clickhouse.Table{
128127
Name: tableName,
129128
Config: NewChTableConfigFourAttrs(),
130129
Cols: map[string]*clickhouse.Column{

quesma/ingest/insert_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/DATA-DOG/go-sqlmock"
99
"github.com/stretchr/testify/assert"
1010
"quesma/clickhouse"
11-
"quesma/concurrent"
1211
"quesma/jsonprocessor"
1312
"quesma/persistence"
1413
"quesma/quesma/config"
@@ -142,7 +141,7 @@ func (*IngestTransformer) Transform(document types.JSON) (types.JSON, error) {
142141
func ingestProcessorsNonEmpty(cfg *clickhouse.ChTableConfig) []ingestProcessorHelper {
143142
lms := make([]ingestProcessorHelper, 0, 4)
144143
for _, created := range []bool{true, false} {
145-
full := concurrent.NewMapWith(tableName, &clickhouse.Table{
144+
full := util.NewSyncMapWith(tableName, &clickhouse.Table{
146145
Name: tableName,
147146
Config: cfg,
148147
Cols: map[string]*clickhouse.Column{
@@ -310,7 +309,7 @@ func TestInsertVeryBigIntegers(t *testing.T) {
310309
}
311310

312311
// big integer as an attribute field
313-
tableMapNoSchemaFields := concurrent.NewMapWith(tableName, &clickhouse.Table{
312+
tableMapNoSchemaFields := util.NewSyncMapWith(tableName, &clickhouse.Table{
314313
Name: tableName,
315314
Config: NewChTableConfigFourAttrs(),
316315
Cols: map[string]*clickhouse.Column{},

quesma/ingest/processor.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
chLib "quesma/clickhouse"
1212
"quesma/comment_metadata"
1313
"quesma/common_table"
14-
"quesma/concurrent"
1514
"quesma/end_user_errors"
1615
"quesma/jsonprocessor"
1716
"quesma/logger"
@@ -69,7 +68,7 @@ type (
6968
virtualTableStorage persistence.JSONDatabase
7069
tableResolver table_resolver.TableResolver
7170
}
72-
TableMap = concurrent.Map[string, *chLib.Table]
71+
TableMap = util.SyncMap[string, *chLib.Table]
7372
SchemaMap = map[string]interface{} // TODO remove
7473
Attribute struct {
7574
KeysArrayName string
@@ -82,7 +81,7 @@ type (
8281
)
8382

8483
func NewTableMap() *TableMap {
85-
return concurrent.NewMap[string, *chLib.Table]()
84+
return util.NewSyncMap[string, *chLib.Table]()
8685
}
8786

8887
func (ip *IngestProcessor) Start() {

quesma/ingest/processor_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package ingest
55
import (
66
"encoding/json"
77
"quesma/clickhouse"
8-
"quesma/concurrent"
98
"quesma/persistence"
109
"quesma/quesma/config"
1110
"quesma/quesma/types"
1211
"quesma/schema"
1312
"quesma/telemetry"
13+
"quesma/util"
1414
"strings"
1515
"sync/atomic"
1616
"testing"
@@ -55,7 +55,7 @@ func TestInsertNonSchemaFieldsToOthers_1(t *testing.T) {
5555
rowToInsert := `{"host.name":"hermes","message":"User password reset requested","service.name":"queue","non-schema2":"2","severity":"info","source":"azure","timestamp":"2024-01-08T18:56:08.454Z","non-schema1":{"a":"b"}}`
5656
var emptyMap TableMap
5757
// TODO fix clickhouse.Columns
58-
fieldsMap := concurrent.NewMapWith("tableName", &clickhouse.Table{
58+
fieldsMap := util.NewSyncMapWith("tableName", &clickhouse.Table{
5959
Cols: map[string]*clickhouse.Column{
6060
"host::name": nil,
6161
"message": nil,
@@ -787,49 +787,49 @@ func TestLogManager_GetTable(t *testing.T) {
787787
}{
788788
{
789789
name: "empty",
790-
predefinedTables: *concurrent.NewMap[string, *clickhouse.Table](),
790+
predefinedTables: *util.NewSyncMap[string, *clickhouse.Table](),
791791
tableNamePattern: "table",
792792
found: false,
793793
},
794794
{
795795
name: "should find by name",
796-
predefinedTables: *concurrent.NewMapWith("table1", &clickhouse.Table{Name: "table1"}),
796+
predefinedTables: *util.NewSyncMapWith("table1", &clickhouse.Table{Name: "table1"}),
797797
tableNamePattern: "table1",
798798
found: true,
799799
},
800800
{
801801
name: "should not find by name",
802-
predefinedTables: *concurrent.NewMapWith("table1", &clickhouse.Table{Name: "table1"}),
802+
predefinedTables: *util.NewSyncMapWith("table1", &clickhouse.Table{Name: "table1"}),
803803
tableNamePattern: "foo",
804804
found: false,
805805
},
806806
{
807807
name: "should find by pattern",
808-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
808+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
809809
tableNamePattern: "logs-generic-*",
810810
found: true,
811811
},
812812
{
813813
name: "should find by pattern",
814-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
814+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
815815
tableNamePattern: "*-*-*",
816816
found: true,
817817
},
818818
{
819819
name: "should find by pattern",
820-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
820+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
821821
tableNamePattern: "logs-*-default",
822822
found: true,
823823
},
824824
{
825825
name: "should find by pattern",
826-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
826+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
827827
tableNamePattern: "*",
828828
found: true,
829829
},
830830
{
831831
name: "should not find by pattern",
832-
predefinedTables: *concurrent.NewMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
832+
predefinedTables: *util.NewSyncMapWith("logs-generic-default", &clickhouse.Table{Name: "logs-generic-default"}),
833833
tableNamePattern: "foo-*",
834834
found: false,
835835
},

0 commit comments

Comments
 (0)