Ompluscator / dynamic-struct

Golang package for editing struct's fields during runtime and mapping structs to other structs.
MIT License
672 stars 83 forks source link

Non deterministic #19

Closed pjebs closed 3 years ago

pjebs commented 3 years ago

It appears there is an element of randomness.


dataSchema := dynamicstruct.NewStruct()
for _, aSeries := range df.Series {
dataSchema.AddField(...)
}

schemaStruct := dataSchema.Build()

spew.Dump(schemaStruct)

Results

TRY 1:

(*dynamicstruct.dynamicStructImpl)(0xc0001f0fc0)({
 definition: (*reflect.rtype)(0xc0000a6540)(struct { E *string "parquet:\"name=e, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; A *string "parquet:\"name=a, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; B *string "parquet:\"name=b, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; C *string "parquet:\"name=c, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; D *string "parquet:\"name=d, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\"" })
})

TRY 2:

(*dynamicstruct.dynamicStructImpl)(0xc0000129f0)({
 definition: (*reflect.rtype)(0xc0001123c0)(struct { A *string "parquet:\"name=a, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; B *string "parquet:\"name=b, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; C *string "parquet:\"name=c, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; D *string "parquet:\"name=d, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\""; E *string "parquet:\"name=e, type=UTF8, encoding=PLAIN_DICTIONARY, repetitiontype=OPTIONAL\"" })
pjebs commented 3 years ago

You can see the order changes internally. Can this be changed to something deterministic?

This is effecting some of my code downstream. If you are really curious (but not necessary): https://github.com/rocketlaunchr/dataframe-go/blob/master/exports/parquet.go

Ompluscator commented 3 years ago

Hi @pjebs

Try to use version 1.3.0 - there was PR which removes this case of randomness.

pjebs commented 3 years ago

Thanks @Ompluscator