MCPcopy
hub / github.com/uber/aresdb / SetDataValue

Method SetDataValue

memstore/vector_party.go:205–245  ·  view source on GitHub ↗

SetDataValue implements SetDataValue in cVectorParty

(offset int, value common.DataValue, countsUpdateMode common.ValueCountsUpdateMode, counts ...uint32)

Source from the content-addressed store, hash-verified

203
204// SetDataValue implements SetDataValue in cVectorParty
205func (vp *cVectorParty) SetDataValue(offset int, value common.DataValue, countsUpdateMode common.ValueCountsUpdateMode, counts ...uint32) {
206 vp.setValidity(offset, value.Valid)
207 if value.Valid {
208 if vp.values.DataType == common.Bool {
209 vp.values.SetBool(offset, value.BoolVal)
210 } else {
211 vp.values.SetValue(offset, value.OtherVal)
212 }
213 } else {
214 if vp.values.DataType == common.Bool {
215 vp.values.SetBool(offset, false)
216 } else {
217 var zero [2]uint64
218 vp.values.SetValue(offset, unsafe.Pointer(&zero))
219 }
220 }
221
222 if countsUpdateMode == common.IgnoreCount {
223 return
224 }
225
226 isNonDefault := value.Compare(vp.defaultValue) != 0
227
228 count := 1
229 if len(counts) > 0 {
230 count = int(counts[0])
231 }
232
233 if countsUpdateMode == common.IncrementCount {
234 if isNonDefault {
235 vp.nonDefaultValueCount += count
236 }
237 } else if countsUpdateMode == common.CheckExistingCount {
238 existing := vp.GetDataValue(offset).Compare(vp.defaultValue) != 0
239 if !existing && isNonDefault {
240 vp.nonDefaultValueCount += count
241 } else if existing && !isNonDefault {
242 vp.nonDefaultValueCount -= count
243 }
244 }
245}
246
247// JudgeMode judges column mode of current vector party according to value count fields.
248func (vp *cVectorParty) JudgeMode() common.ColumnMode {

Callers 1

toVectorPartyFunction · 0.95

Calls 5

setValidityMethod · 0.95
GetDataValueMethod · 0.95
CompareMethod · 0.80
SetBoolMethod · 0.65
SetValueMethod · 0.65

Tested by

no test coverage detected