Giter VIP home page Giter VIP logo

Comments (10)

cornelk avatar cornelk commented on May 18, 2024

@lunemec are you using the current master branch that included a race fix? if so, can you create a unit test to replicate that behavior?

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

Well, I only noticed when creating kinda huge hashmaps. I tested this with my tests, but it did not trigger. Only when I load real data 70MB in heap, then it triggers this. My current revision is this: b893f49

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

I'll try to force the newest commit with the fix - dep automatically takes released version.

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

Nope, the current master does not work either. I'll write a test case for this.

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

Well, I kinda created this problem:

func TestHashMap_SetWithContainer(t *testing.T) {
	type Container struct {
		Map HashMap
	}
	type mapItem struct {
		InnerData HashMap
	}
	var container Container
	for i := 0; i < 10; i++ {
		var innerMap HashMap
		for z := 0; z < 10; z++ {
			innerMap.Set(z, struct{}{})
		}
		container.Map.Set(i, mapItem{InnerData: innerMap})
	}
}

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

Well at least I can now fix it by simply moving the HashMap outside of the struct, but I have some metadata packed with it, so that would not be ideal.

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

@cornelk do you think a fix is possible? Or should I work around this?

from hashmap.

cornelk avatar cornelk commented on May 18, 2024

this is the fixed unit test without a race condition:

func TestHashMap_SetWithContainer(t *testing.T) {
	type Container struct {
		Map *HashMap
	}
	type mapItem struct {
		InnerData *HashMap
	}
	container := Container{Map: &HashMap{}}
	for i := 0; i < 10; i++ {
		innerMap := &HashMap{}
		for z := 0; z < 10; z++ {
			innerMap.Set(z, struct{}{})
		}
		container.Map.Set(i, mapItem{InnerData: innerMap})
	}
}

from hashmap.

lunemec avatar lunemec commented on May 18, 2024

Okay, so it was misunderstanding of usage on my part. Could you maybe update readme/doc with a example of this?

from hashmap.

cornelk avatar cornelk commented on May 18, 2024

The readme and tests already contain code that shows how to initiate the map: m := &HashMap{}

from hashmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.