Exemplo n.º 1
0
// WriteValue takes a Value, schedules it to be written it to ds, and returns v.Ref(). v is not guaranteed to be actually written until after a successful Commit().
func (ds *dataStoreCommon) WriteValue(v types.Value) (r types.RefBase) {
	if v == nil {
		return
	}

	targetRef := v.Ref()
	r = types.PrivateRefFromType(targetRef, types.MakeRefType(v.Type()))
	if entry := ds.checkCache(targetRef); entry != nil && entry.Present() {
		return
	}

	// Encoding v causes any child chunks, e.g. internal nodes if v is a meta sequence, to get written. That needs to happen before we try to validate v.
	chunk := types.EncodeValue(v, ds)

	for _, reachable := range v.Chunks() {
		entry := ds.checkCache(reachable.TargetRef())
		d.Chk.True(entry != nil && entry.Present(), "Value to write contains ref %s, which points to a non-existent Value.", reachable.TargetRef())

		// BUG 1121
		// It's possible that entry.Type() will be simply 'Value', but that 'reachable' is actually a properly-typed object -- that is, a Ref to some specific Type. The Chk below would fail, though it's possible that the Type is actually correct. We wouldn't be able to verify without reading it, though, so we'll dig into this later.
		targetType := getTargetType(reachable)
		if targetType.Equals(types.MakePrimitiveType(types.ValueKind)) {
			continue
		}
		d.Chk.True(entry.Type().Equals(targetType), "Value to write contains ref %s, which points to a value of a different type: %+v != %+v", reachable.TargetRef(), entry.Type(), targetType)
	}
	ds.cs.Put(chunk) // TODO: DataStore should manage batching and backgrounding Puts.
	ds.setCache(targetRef, presentChunk(v.Type()))

	return
}
Exemplo n.º 2
0
func (s SetOfFloat32) Equals(other types.Value) bool {
	return other != nil && __typeForSetOfFloat32.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 3
0
func (l ListOfString) Equals(other types.Value) bool {
	return other != nil && __typeForListOfString.Equals(other.Type()) && l.Ref() == other.Ref()
}
Exemplo n.º 4
0
func (l ListOfRefOfFloat32) Equals(other types.Value) bool {
	return other != nil && __typeForListOfRefOfFloat32.Equals(other.Type()) && l.Ref() == other.Ref()
}
Exemplo n.º 5
0
func (s __unionOfEOfFloat64AndFOfString) Equals(other types.Value) bool {
	return other != nil && __typeFor__unionOfEOfFloat64AndFOfString.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 6
0
func (m MapOfStringToRefOfListOfPitch) Equals(other types.Value) bool {
	return other != nil && __typeForMapOfStringToRefOfListOfPitch.Equals(other.Type()) && m.Ref() == other.Ref()
}
Exemplo n.º 7
0
func (r RefOfRemotePhoto) Equals(other types.Value) bool {
	return other != nil && __typeForRefOfRemotePhoto.Equals(other.Type()) && r.Ref() == other.Ref()
}
Exemplo n.º 8
0
func (s S) Equals(other types.Value) bool {
	return other != nil && __typeForS.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 9
0
func (s Georectangle) Equals(other types.Value) bool {
	return other != nil && __typeForGeorectangle.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 10
0
func (s Geoposition) Equals(other types.Value) bool {
	return other != nil && __typeForGeoposition.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 11
0
func (m MapOfSizeToString) Equals(other types.Value) bool {
	return other != nil && __typeForMapOfSizeToString.Equals(other.Type()) && m.Ref() == other.Ref()
}
Exemplo n.º 12
0
func (r RefOfMapOfStringToValue) Equals(other types.Value) bool {
	return other != nil && __typeForRefOfMapOfStringToValue.Equals(other.Type()) && r.Ref() == other.Ref()
}
Exemplo n.º 13
0
func (s SetOfRefOfCommit) Equals(other types.Value) bool {
	return other != nil && __typeForSetOfRefOfCommit.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 14
0
func (r RefOfListOfPitch) Equals(other types.Value) bool {
	return other != nil && __typeForRefOfListOfPitch.Equals(other.Type()) && r.Ref() == other.Ref()
}
Exemplo n.º 15
0
func (s ImportUser) Equals(other types.Value) bool {
	return other != nil && __typeForImportUser.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 16
0
func (m MapOfStringToRefOfCompany) Equals(other types.Value) bool {
	return other != nil && __typeForMapOfStringToRefOfCompany.Equals(other.Type()) && m.Ref() == other.Ref()
}
Exemplo n.º 17
0
func (m MapOfRefOfKeyToSetOfRefOfRound) Equals(other types.Value) bool {
	return other != nil && __typeForMapOfRefOfKeyToSetOfRefOfRound.Equals(other.Type()) && m.Ref() == other.Ref()
}
Exemplo n.º 18
0
func (r RefOfUser) Equals(other types.Value) bool {
	return other != nil && __typeForRefOfUser.Equals(other.Type()) && r.Ref() == other.Ref()
}
Exemplo n.º 19
0
func (s EnumStruct) Equals(other types.Value) bool {
	return other != nil && __typeForEnumStruct.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 20
0
func (s StructWithList) Equals(other types.Value) bool {
	return other != nil && __typeForStructWithList.Equals(other.Type()) && s.Ref() == other.Ref()
}
Exemplo n.º 21
0
func (s StructPrimitives) Equals(other types.Value) bool {
	return other != nil && __typeForStructPrimitives.Equals(other.Type()) && s.Ref() == other.Ref()
}