-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got rid of Slice() on AttributeValues, fixed race in edge statistics, fixed attribute value bug in Absorb(), Moved some Object methods to Edges(direction), changed Attribute type from int16 to uint16, AttributeValueMap supports pre-allocation if we switch to a map type that supports it, EdgeConnections points to IDs not Objects, created a weak ID -> Object slice tracker, made everything thread safe all the time (LOL, at least that's the ambition), added cache for AttributeValueToIndex to minimize ToLower calls, added Iterate and IterateParallel to Objects,
- Loading branch information
1 parent
0fe3ebb
commit ffc9f9d
Showing
27 changed files
with
505 additions
and
495 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,67 @@ | ||
package engine | ||
|
||
import ( | ||
gsync "github.com/SaveTheRbtz/generic-sync-map-go" | ||
) | ||
|
||
type AttributeValueMap struct { | ||
m map[Attribute]AttributeValues | ||
// m *xsync.MapOf[Attribute, AttributeValues] | ||
// m map[Attribute]AttributeValues | ||
// m *haxmap.Map[Attribute, AttributeValues] | ||
m gsync.MapOf[Attribute, AttributeValues] | ||
} | ||
|
||
func (avm *AttributeValueMap) init(preloadAttributes int) { | ||
// avm.m = haxmap.New[Attribute, AttributeValues](1) | ||
// avm.m = make(map[Attribute]AttributeValues) | ||
// avm.m = xsync.NewTypedMapOf[Attribute, AttributeValues](func(a Attribute) uint64 { | ||
// return uint64(a) | ||
// }) | ||
} | ||
|
||
func (avm AttributeValueMap) Get(a Attribute) (av AttributeValues, found bool) { | ||
if avm.m == nil { | ||
return nil, false | ||
} | ||
av, found = avm.m[a] | ||
func (avm *AttributeValueMap) Get(a Attribute) (av AttributeValues, found bool) { | ||
// av, found = avm.m.Get(a) | ||
// if found && av.Len() == 0 { | ||
// found = false // workaround until haxmap performance for deletes is fixed | ||
// } | ||
// av, found = avm.m[a] | ||
av, found = avm.m.Load(a) | ||
return | ||
} | ||
|
||
func (avm *AttributeValueMap) Set(a Attribute, av AttributeValues) { | ||
if avm.m == nil { | ||
avm.m = make(map[Attribute]AttributeValues) | ||
} | ||
avm.m[a] = av | ||
// avm.m.Set(a, av) | ||
// avm.m[a] = av | ||
avm.m.Store(a, av) | ||
} | ||
|
||
func (avm AttributeValueMap) Len() int { | ||
return len(avm.m) | ||
func (avm *AttributeValueMap) Len() int { | ||
var count int | ||
avm.m.Range(func(u Attribute, av AttributeValues) bool { | ||
// if av.Len() > 0 { | ||
count++ | ||
// } | ||
return true | ||
}) | ||
return count | ||
// return len(avm.m) | ||
// return avm.m.Size() | ||
} | ||
|
||
func (avm *AttributeValueMap) Clear(a Attribute) { | ||
if avm.m != nil { | ||
delete(avm.m, a) | ||
} | ||
// avm.m.Set(a, NoValues{}) // Workaround until haxmap performance | ||
// delete(avm.m, a) | ||
avm.m.Delete(a) | ||
} | ||
|
||
func (avm AttributeValueMap) Iterate(f func(attr Attribute, values AttributeValues) bool) { | ||
for attr, values := range avm.m { | ||
if !f(attr, values) { | ||
break | ||
} | ||
} | ||
func (avm *AttributeValueMap) Iterate(f func(attr Attribute, values AttributeValues) bool) { | ||
avm.m.Range(f) | ||
// for a, av := range avm.m { | ||
// if !f(a, av) { | ||
// break | ||
// } | ||
// } | ||
// avm.m.Range(func(a Attribute, av AttributeValues) bool { | ||
// return f(a, av) | ||
// }) | ||
} |
Oops, something went wrong.