|
9 | 9 | "strings"
|
10 | 10 |
|
11 | 11 | lru "github.com/hashicorp/golang-lru"
|
12 |
| - "github.com/sirupsen/logrus" |
13 | 12 | bblfsh "gopkg.in/bblfsh/client-go.v2"
|
14 | 13 | "gopkg.in/bblfsh/client-go.v2/tools"
|
15 | 14 | "gopkg.in/bblfsh/sdk.v1/uast"
|
@@ -53,8 +52,7 @@ type uastFunc struct {
|
53 | 52 | Lang sql.Expression
|
54 | 53 | XPath sql.Expression
|
55 | 54 |
|
56 |
| - h hash.Hash |
57 |
| - errCache *lru.Cache |
| 55 | + h hash.Hash |
58 | 56 | }
|
59 | 57 |
|
60 | 58 | // IsNullable implements the Expression interface.
|
@@ -207,18 +205,10 @@ func (u *uastFunc) getUAST(
|
207 | 205 | if ok {
|
208 | 206 | node = value.(*uast.Node)
|
209 | 207 | } else {
|
210 |
| - if u.errCache != nil { |
211 |
| - _, ok := u.errCache.Get(key) |
212 |
| - if ok { |
213 |
| - return nil, nil |
214 |
| - } |
215 |
| - } |
216 |
| - |
217 | 208 | var err error
|
218 | 209 | node, err = getUASTFromBblfsh(ctx, blob, lang, xpath, mode)
|
219 | 210 | if err != nil {
|
220 | 211 | if ErrParseBlob.Is(err) {
|
221 |
| - u.errCache.Add(key, struct{}{}) |
222 | 212 | return nil, nil
|
223 | 213 | }
|
224 | 214 |
|
@@ -267,18 +257,12 @@ func NewUAST(args ...sql.Expression) (sql.Expression, error) {
|
267 | 257 | blob = args[0]
|
268 | 258 | }
|
269 | 259 |
|
270 |
| - errCache, err := lru.New(defaultUASTCacheSize) |
271 |
| - if err != nil { |
272 |
| - logrus.Warn("couldn't initialize UAST cache for errors") |
273 |
| - } |
274 |
| - |
275 | 260 | 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(), |
282 | 266 | }}, nil
|
283 | 267 | }
|
284 | 268 |
|
@@ -314,18 +298,12 @@ var _ sql.Expression = (*UASTMode)(nil)
|
314 | 298 |
|
315 | 299 | // NewUASTMode creates a new UASTMode UDF.
|
316 | 300 | 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 |
| - |
322 | 301 | 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(), |
329 | 307 | }}
|
330 | 308 | }
|
331 | 309 |
|
|
0 commit comments