github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/entity/bulkinsert.go (about)

     1  package entity
     2  
     3  import "strconv"
     4  
     5  type BulkInsertState int32
     6  
     7  const (
     8  	BulkInsertPending          BulkInsertState = 0 // the task in in pending list of rootCoord, waiting to be executed
     9  	BulkInsertFailed           BulkInsertState = 1 // the task failed for some reason, get detail reason from GetImportStateResponse.infos
    10  	BulkInsertStarted          BulkInsertState = 2 // the task has been sent to datanode to execute
    11  	BulkInsertPersisted        BulkInsertState = 5 // all data files have been parsed and data already persisted
    12  	BulkInsertCompleted        BulkInsertState = 6 // all indexes are successfully built and segments are able to be compacted as normal.
    13  	BulkInsertFailedAndCleaned BulkInsertState = 7 // the task failed and all segments it generated are cleaned up.
    14  
    15  	ImportProgress = "progress_percent"
    16  )
    17  
    18  type BulkInsertTaskState struct {
    19  	ID           int64             // id of an import task
    20  	State        BulkInsertState   // is this import task finished or not
    21  	RowCount     int64             // if the task is finished, this value is how many rows are imported. if the task is not finished, this value is how many rows are parsed. return 0 if failed.
    22  	IDList       []int64           // auto generated ids if the primary key is autoid
    23  	Infos        map[string]string // more information about the task, progress percent, file path, failed reason, etc.
    24  	CollectionID int64             // collection ID of the import task.
    25  	SegmentIDs   []int64           // a list of segment IDs created by the import task.
    26  	CreateTs     int64             //timestamp when the import task is created.
    27  }
    28  
    29  func (state BulkInsertTaskState) Progress() int {
    30  	if val, ok := state.Infos[ImportProgress]; ok {
    31  		progress, err := strconv.Atoi(val)
    32  		if err != nil {
    33  			return 0
    34  		}
    35  		return progress
    36  	}
    37  	return 0
    38  }