| 2055 | } |
| 2056 | |
| 2057 | func (t *BleveDestPartition) DataUpdate(partition string, |
| 2058 | key []byte, seq uint64, val []byte, cas uint64, |
| 2059 | extrasType cbgt.DestExtrasType, extras []byte) error { |
| 2060 | atomic.AddUint64(&aggregateBDPStats.TotDataUpdateBeg, 1) |
| 2061 | |
| 2062 | t.m.Lock() |
| 2063 | |
| 2064 | if t.batch == nil { |
| 2065 | t.m.Unlock() |
| 2066 | atomic.AddUint64(&aggregateBDPStats.TotDataUpdateEnd, 1) |
| 2067 | return fmt.Errorf("bleve: DataUpdate nil batch") |
| 2068 | } |
| 2069 | |
| 2070 | defaultType := "_default" |
| 2071 | if imi, ok := t.bindex.Mapping().(*mapping.IndexMappingImpl); ok { |
| 2072 | defaultType = imi.DefaultType |
| 2073 | } |
| 2074 | |
| 2075 | cbftDoc, key, errv := t.bdest.bleveDocConfig.BuildDocumentEx(key, val, |
| 2076 | defaultType, extrasType, extras) |
| 2077 | |
| 2078 | erri := t.batch.Index(string(key), cbftDoc) |
| 2079 | |
| 2080 | revNeedsUpdate, err := t.updateSeqLOCKED(seq) |
| 2081 | |
| 2082 | t.m.Unlock() |
| 2083 | |
| 2084 | if err == nil && revNeedsUpdate { |
| 2085 | t.incRev() |
| 2086 | } |
| 2087 | if errv != nil { |
| 2088 | t.bdest.AddError("json.Unmarshal", partition, key, seq, val, errv) |
| 2089 | } |
| 2090 | if erri != nil { |
| 2091 | t.bdest.AddError("batch.Index", partition, key, seq, val, erri) |
| 2092 | } |
| 2093 | |
| 2094 | atomic.AddUint64(&aggregateBDPStats.TotDataUpdateEnd, 1) |
| 2095 | return err |
| 2096 | } |
| 2097 | |
| 2098 | func (t *BleveDestPartition) DataDelete(partition string, |
| 2099 | key []byte, seq uint64, |