(idxType string, nid string, colNum int, ctx context.Context)
| 13 | ) |
| 14 | |
| 15 | func AsyncIndexer(idxType string, nid string, colNum int, ctx context.Context) { |
| 16 | // use function closure to get current value of err at return time |
| 17 | var err error |
| 18 | defer func() { |
| 19 | locker.IndexLockMgr.Error(nid, idxType, err) |
| 20 | }() |
| 21 | |
| 22 | // get node - this is read only |
| 23 | var n *Node |
| 24 | n, err = Load(nid) |
| 25 | if err != nil { |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | avgSize := int64(0) |
| 30 | subsetSize := int64(0) |
| 31 | count := int64(0) |
| 32 | indexFormat := "" |
| 33 | subsetName := "" |
| 34 | |
| 35 | var f *os.File |
| 36 | if idxType == "bai" { |
| 37 | err = index.CreateBamIndex(n.FilePath()) |
| 38 | if err != nil { |
| 39 | return |
| 40 | } |
| 41 | indexFormat = "bai" |
| 42 | } else if idxType == "column" { |
| 43 | idxType = fmt.Sprintf("%s%d", idxType, colNum) |
| 44 | f, err = os.Open(n.FilePath()) |
| 45 | if err != nil { |
| 46 | return |
| 47 | } |
| 48 | defer f.Close() |
| 49 | idxer := index.NewColumnIndexer(f) |
| 50 | count, indexFormat, err = index.CreateColumnIndex(&idxer, colNum, n.IndexPath()+"/"+idxType+".idx") |
| 51 | if err != nil { |
| 52 | return |
| 53 | } |
| 54 | } else if idxType == "subset" { |
| 55 | // Utilizing the multipart form parser since we need to upload a file. |
| 56 | var params map[string]string |
| 57 | var files file.FormFiles |
| 58 | params, files, err = request.ParseMultipartForm(ctx.HttpRequest()) |
| 59 | // clean up temp dir !! |
| 60 | defer file.RemoveAllFormFiles(files) |
| 61 | if err != nil { |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | parentIndex, hasParent := params["parent_index"] |
| 66 | if !hasParent { |
| 67 | err = errors.New("Index type subset requires parent_index param.") |
| 68 | return |
| 69 | } else if _, has := n.Indexes[parentIndex]; !has { |
| 70 | err = fmt.Errorf("Node %s does not have index of type %s.", n.Id, parentIndex) |
| 71 | return |
| 72 | } |
nothing calls this directly
no test coverage detected