(q *Query, restrict []uint32)
| 335 | } |
| 336 | |
| 337 | func (ix *Index) postingQuery(q *Query, restrict []uint32) (ret []uint32) { |
| 338 | var list []uint32 |
| 339 | switch q.Op { |
| 340 | case QNone: |
| 341 | // nothing |
| 342 | case QAll: |
| 343 | if restrict != nil { |
| 344 | return restrict |
| 345 | } |
| 346 | list = make([]uint32, ix.numName) |
| 347 | for i := range list { |
| 348 | list[i] = uint32(i) |
| 349 | } |
| 350 | return list |
| 351 | case QAnd: |
| 352 | for _, t := range q.Trigram { |
| 353 | tri := uint32(t[0])<<16 | uint32(t[1])<<8 | uint32(t[2]) |
| 354 | if list == nil { |
| 355 | list = ix.postingList(tri, restrict) |
| 356 | } else { |
| 357 | list = ix.postingAnd(list, tri, restrict) |
| 358 | } |
| 359 | if len(list) == 0 { |
| 360 | return nil |
| 361 | } |
| 362 | } |
| 363 | for _, sub := range q.Sub { |
| 364 | if list == nil { |
| 365 | list = restrict |
| 366 | } |
| 367 | list = ix.postingQuery(sub, list) |
| 368 | if len(list) == 0 { |
| 369 | return nil |
| 370 | } |
| 371 | } |
| 372 | case QOr: |
| 373 | for _, t := range q.Trigram { |
| 374 | tri := uint32(t[0])<<16 | uint32(t[1])<<8 | uint32(t[2]) |
| 375 | if list == nil { |
| 376 | list = ix.postingList(tri, restrict) |
| 377 | } else { |
| 378 | list = ix.postingOr(list, tri, restrict) |
| 379 | } |
| 380 | } |
| 381 | for _, sub := range q.Sub { |
| 382 | list1 := ix.postingQuery(sub, restrict) |
| 383 | list = mergeOr(list, list1) |
| 384 | } |
| 385 | } |
| 386 | return list |
| 387 | } |
| 388 | |
| 389 | func mergeOr(l1, l2 []uint32) []uint32 { |
| 390 | var l []uint32 |
no test coverage detected