This commit is contained in:
Aliaksandr Valialkin 2024-05-17 11:32:27 +02:00
parent bddc715c0c
commit c38d3dab4d
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
20 changed files with 27 additions and 27 deletions

View file

@ -37,13 +37,13 @@ func (fs fieldsSet) getAll() []string {
return a return a
} }
func (fs fieldsSet) addAll(fields []string) { func (fs fieldsSet) addFields(fields []string) {
for _, f := range fields { for _, f := range fields {
fs.add(f) fs.add(f)
} }
} }
func (fs fieldsSet) removeAll(fields []string) { func (fs fieldsSet) removeFields(fields []string) {
for _, f := range fields { for _, f := range fields {
fs.remove(f) fs.remove(f)
} }

View file

@ -73,8 +73,8 @@ func TestFieldsSet(t *testing.T) {
t.Fatalf("fs must be empty") t.Fatalf("fs must be empty")
} }
// verify addAll, getAll, removeAll // verify addFields, removeFields, getAll
fs.addAll([]string{"foo", "bar", "_msg"}) fs.addFields([]string{"foo", "bar", "_msg"})
if !fs.contains("foo") || !fs.contains("bar") || !fs.contains("_msg") { if !fs.contains("foo") || !fs.contains("bar") || !fs.contains("_msg") {
t.Fatalf("fs must contain foo, bar and _msg") t.Fatalf("fs must contain foo, bar and _msg")
} }
@ -82,7 +82,7 @@ func TestFieldsSet(t *testing.T) {
if !reflect.DeepEqual(a, []string{"_msg", "bar", "foo"}) { if !reflect.DeepEqual(a, []string{"_msg", "bar", "foo"}) {
t.Fatalf("unexpected result from getAll(); got %q; want %q", a, []string{"_msg", "bar", "foo"}) t.Fatalf("unexpected result from getAll(); got %q; want %q", a, []string{"_msg", "bar", "foo"})
} }
fs.removeAll([]string{"bar", "baz", "_msg"}) fs.removeFields([]string{"bar", "baz", "_msg"})
if fs.contains("bar") || fs.contains("baz") || fs.contains("_msg") { if fs.contains("bar") || fs.contains("baz") || fs.contains("_msg") {
t.Fatalf("fs mustn't contain bar, baz and _msg") t.Fatalf("fs mustn't contain bar, baz and _msg")
} }
@ -91,7 +91,7 @@ func TestFieldsSet(t *testing.T) {
} }
// verify clone // verify clone
fs.addAll([]string{"foo", "bar", "baz"}) fs.addFields([]string{"foo", "bar", "baz"})
fsStr := fs.String() fsStr := fs.String()
fsCopy := fs.clone() fsCopy := fs.clone()
fsCopyStr := fsCopy.String() fsCopyStr := fsCopy.String()

View file

@ -40,7 +40,7 @@ func (pc *pipeCopy) updateNeededFields(neededFields, unneededFields fieldsSet) {
} }
if neededFields.contains("*") { if neededFields.contains("*") {
// update only unneeded fields // update only unneeded fields
unneededFields.addAll(pc.dstFields) unneededFields.addFields(pc.dstFields)
for i, srcField := range pc.srcFields { for i, srcField := range pc.srcFields {
if neededSrcFields[i] { if neededSrcFields[i] {
unneededFields.remove(srcField) unneededFields.remove(srcField)
@ -48,7 +48,7 @@ func (pc *pipeCopy) updateNeededFields(neededFields, unneededFields fieldsSet) {
} }
} else { } else {
// update only needed fields and reset unneeded fields // update only needed fields and reset unneeded fields
neededFields.removeAll(pc.dstFields) neededFields.removeFields(pc.dstFields)
for i, srcField := range pc.srcFields { for i, srcField := range pc.srcFields {
if neededSrcFields[i] { if neededSrcFields[i] {
neededFields.add(srcField) neededFields.add(srcField)

View file

@ -75,7 +75,7 @@ func assertNeededFields(t *testing.T, nfs, unfs fieldsSet, neededFieldsExpected,
func newTestFieldsSet(fields string) fieldsSet { func newTestFieldsSet(fields string) fieldsSet {
fs := newFieldsSet() fs := newFieldsSet()
if fields != "" { if fields != "" {
fs.addAll(strings.Split(fields, ",")) fs.addFields(strings.Split(fields, ","))
} }
return fs return fs
} }

View file

@ -25,10 +25,10 @@ func (pd *pipeDelete) String() string {
func (pd *pipeDelete) updateNeededFields(neededFields, unneededFields fieldsSet) { func (pd *pipeDelete) updateNeededFields(neededFields, unneededFields fieldsSet) {
if neededFields.contains("*") { if neededFields.contains("*") {
// update only unneeded fields // update only unneeded fields
unneededFields.addAll(pd.fields) unneededFields.addFields(pd.fields)
} else { } else {
// update only needed fields // update only needed fields
neededFields.removeAll(pd.fields) neededFields.removeFields(pd.fields)
} }
} }

View file

@ -32,7 +32,7 @@ func (pf *pipeFields) updateNeededFields(neededFields, unneededFields fieldsSet)
if neededFields.contains("*") { if neededFields.contains("*") {
// subtract unneeded fields from pf.fields // subtract unneeded fields from pf.fields
neededFields.reset() neededFields.reset()
neededFields.addAll(pf.fields) neededFields.addFields(pf.fields)
for _, f := range unneededFields.getAll() { for _, f := range unneededFields.getAll() {
neededFields.remove(f) neededFields.remove(f)
} }

View file

@ -40,7 +40,7 @@ func (pr *pipeRename) updateNeededFields(neededFields, unneededFields fieldsSet)
} }
if neededFields.contains("*") { if neededFields.contains("*") {
// update only unneeded fields // update only unneeded fields
unneededFields.addAll(pr.dstFields) unneededFields.addFields(pr.dstFields)
for i, srcField := range pr.srcFields { for i, srcField := range pr.srcFields {
if neededSrcFields[i] { if neededSrcFields[i] {
unneededFields.remove(srcField) unneededFields.remove(srcField)
@ -50,7 +50,7 @@ func (pr *pipeRename) updateNeededFields(neededFields, unneededFields fieldsSet)
} }
} else { } else {
// update only needed fields and reset unneeded fields // update only needed fields and reset unneeded fields
neededFields.removeAll(pr.dstFields) neededFields.removeFields(pr.dstFields)
for i, srcField := range pr.srcFields { for i, srcField := range pr.srcFields {
if neededSrcFields[i] { if neededSrcFields[i] {
neededFields.add(srcField) neededFields.add(srcField)

View file

@ -40,7 +40,7 @@ func (pu *pipeUniq) updateNeededFields(neededFields, unneededFields fieldsSet) {
if len(pu.byFields) == 0 { if len(pu.byFields) == 0 {
neededFields.add("*") neededFields.add("*")
} else { } else {
neededFields.addAll(pu.byFields) neededFields.addFields(pu.byFields)
} }
} }

View file

@ -16,7 +16,7 @@ func (sa *statsAvg) String() string {
} }
func (sa *statsAvg) updateNeededFields(neededFields fieldsSet) { func (sa *statsAvg) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sa.fields) neededFields.addFields(sa.fields)
} }
func (sa *statsAvg) newStatsProcessor() (statsProcessor, int) { func (sa *statsAvg) newStatsProcessor() (statsProcessor, int) {

View file

@ -22,7 +22,7 @@ func (sc *statsCount) updateNeededFields(neededFields fieldsSet) {
// There is no need in fetching any columns for count(*) - the number of matching rows can be calculated as len(blockResult.timestamps) // There is no need in fetching any columns for count(*) - the number of matching rows can be calculated as len(blockResult.timestamps)
return return
} }
neededFields.addAll(sc.fields) neededFields.addFields(sc.fields)
} }
func (sc *statsCount) newStatsProcessor() (statsProcessor, int) { func (sc *statsCount) newStatsProcessor() (statsProcessor, int) {

View file

@ -18,7 +18,7 @@ func (sc *statsCountEmpty) String() string {
} }
func (sc *statsCountEmpty) updateNeededFields(neededFields fieldsSet) { func (sc *statsCountEmpty) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sc.fields) neededFields.addFields(sc.fields)
} }
func (sc *statsCountEmpty) newStatsProcessor() (statsProcessor, int) { func (sc *statsCountEmpty) newStatsProcessor() (statsProcessor, int) {

View file

@ -25,7 +25,7 @@ func (su *statsCountUniq) String() string {
} }
func (su *statsCountUniq) updateNeededFields(neededFields fieldsSet) { func (su *statsCountUniq) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(su.fields) neededFields.addFields(su.fields)
} }
func (su *statsCountUniq) newStatsProcessor() (statsProcessor, int) { func (su *statsCountUniq) newStatsProcessor() (statsProcessor, int) {

View file

@ -20,7 +20,7 @@ func (sm *statsMax) String() string {
} }
func (sm *statsMax) updateNeededFields(neededFields fieldsSet) { func (sm *statsMax) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sm.fields) neededFields.addFields(sm.fields)
} }
func (sm *statsMax) newStatsProcessor() (statsProcessor, int) { func (sm *statsMax) newStatsProcessor() (statsProcessor, int) {

View file

@ -15,7 +15,7 @@ func (sm *statsMedian) String() string {
} }
func (sm *statsMedian) updateNeededFields(neededFields fieldsSet) { func (sm *statsMedian) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sm.fields) neededFields.addFields(sm.fields)
} }
func (sm *statsMedian) newStatsProcessor() (statsProcessor, int) { func (sm *statsMedian) newStatsProcessor() (statsProcessor, int) {

View file

@ -20,7 +20,7 @@ func (sm *statsMin) String() string {
} }
func (sm *statsMin) updateNeededFields(neededFields fieldsSet) { func (sm *statsMin) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sm.fields) neededFields.addFields(sm.fields)
} }
func (sm *statsMin) newStatsProcessor() (statsProcessor, int) { func (sm *statsMin) newStatsProcessor() (statsProcessor, int) {

View file

@ -25,7 +25,7 @@ func (sq *statsQuantile) String() string {
} }
func (sq *statsQuantile) updateNeededFields(neededFields fieldsSet) { func (sq *statsQuantile) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sq.fields) neededFields.addFields(sq.fields)
} }
func (sq *statsQuantile) newStatsProcessor() (statsProcessor, int) { func (sq *statsQuantile) newStatsProcessor() (statsProcessor, int) {

View file

@ -17,7 +17,7 @@ func (ss *statsSum) String() string {
} }
func (ss *statsSum) updateNeededFields(neededFields fieldsSet) { func (ss *statsSum) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(ss.fields) neededFields.addFields(ss.fields)
} }
func (ss *statsSum) newStatsProcessor() (statsProcessor, int) { func (ss *statsSum) newStatsProcessor() (statsProcessor, int) {

View file

@ -16,7 +16,7 @@ func (ss *statsSumLen) String() string {
} }
func (ss *statsSumLen) updateNeededFields(neededFields fieldsSet) { func (ss *statsSumLen) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(ss.fields) neededFields.addFields(ss.fields)
} }
func (ss *statsSumLen) newStatsProcessor() (statsProcessor, int) { func (ss *statsSumLen) newStatsProcessor() (statsProcessor, int) {

View file

@ -25,7 +25,7 @@ func (su *statsUniqValues) String() string {
} }
func (su *statsUniqValues) updateNeededFields(neededFields fieldsSet) { func (su *statsUniqValues) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(su.fields) neededFields.addFields(su.fields)
} }
func (su *statsUniqValues) newStatsProcessor() (statsProcessor, int) { func (su *statsUniqValues) newStatsProcessor() (statsProcessor, int) {

View file

@ -22,7 +22,7 @@ func (sv *statsValues) String() string {
} }
func (sv *statsValues) updateNeededFields(neededFields fieldsSet) { func (sv *statsValues) updateNeededFields(neededFields fieldsSet) {
neededFields.addAll(sv.fields) neededFields.addFields(sv.fields)
} }
func (sv *statsValues) newStatsProcessor() (statsProcessor, int) { func (sv *statsValues) newStatsProcessor() (statsProcessor, int) {