Skip to content

Commit 3787eba

Browse files
committed
internal/function: remove cache for errors from uast functions
Signed-off-by: Manuel Carmona <[email protected]>
1 parent aa57988 commit 3787eba

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

internal/function/uast.go

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010

1111
lru "github.com/hashicorp/golang-lru"
12-
"github.com/sirupsen/logrus"
1312
bblfsh "gopkg.in/bblfsh/client-go.v2"
1413
"gopkg.in/bblfsh/client-go.v2/tools"
1514
"gopkg.in/bblfsh/sdk.v1/uast"
@@ -53,8 +52,7 @@ type uastFunc struct {
5352
Lang sql.Expression
5453
XPath sql.Expression
5554

56-
h hash.Hash
57-
errCache *lru.Cache
55+
h hash.Hash
5856
}
5957

6058
// IsNullable implements the Expression interface.
@@ -207,18 +205,10 @@ func (u *uastFunc) getUAST(
207205
if ok {
208206
node = value.(*uast.Node)
209207
} else {
210-
if u.errCache != nil {
211-
_, ok := u.errCache.Get(key)
212-
if ok {
213-
return nil, nil
214-
}
215-
}
216-
217208
var err error
218209
node, err = getUASTFromBblfsh(ctx, blob, lang, xpath, mode)
219210
if err != nil {
220211
if ErrParseBlob.Is(err) {
221-
u.errCache.Add(key, struct{}{})
222212
return nil, nil
223213
}
224214

@@ -267,18 +257,12 @@ func NewUAST(args ...sql.Expression) (sql.Expression, error) {
267257
blob = args[0]
268258
}
269259

270-
errCache, err := lru.New(defaultUASTCacheSize)
271-
if err != nil {
272-
logrus.Warn("couldn't initialize UAST cache for errors")
273-
}
274-
275260
return &UAST{&uastFunc{
276-
Mode: mode,
277-
Blob: blob,
278-
Lang: lang,
279-
XPath: xpath,
280-
h: sha1.New(),
281-
errCache: errCache,
261+
Mode: mode,
262+
Blob: blob,
263+
Lang: lang,
264+
XPath: xpath,
265+
h: sha1.New(),
282266
}}, nil
283267
}
284268

@@ -314,18 +298,12 @@ var _ sql.Expression = (*UASTMode)(nil)
314298

315299
// NewUASTMode creates a new UASTMode UDF.
316300
func NewUASTMode(mode, blob, lang sql.Expression) sql.Expression {
317-
errCache, err := lru.New(defaultUASTCacheSize)
318-
if err != nil {
319-
logrus.Warn("couldn't initialize UAST cache for errors")
320-
}
321-
322301
return &UASTMode{&uastFunc{
323-
Mode: mode,
324-
Blob: blob,
325-
Lang: lang,
326-
XPath: nil,
327-
h: sha1.New(),
328-
errCache: errCache,
302+
Mode: mode,
303+
Blob: blob,
304+
Lang: lang,
305+
XPath: nil,
306+
h: sha1.New(),
329307
}}
330308
}
331309

0 commit comments

Comments
 (0)