HewlettPackard / mds

Managed Data Structures
GNU General Public License v3.0
27 stars 5 forks source link

Add immutable blob<K> to core, APIs. #22

Open EvanKirshenbaum opened 7 years ago

EvanKirshenbaum commented 7 years ago

[imported from HPE issue 146]

One of the knocks on MDS is going to be the extreme overhead for data that is going to be write-once, especially arrays and especially especially data that is essentially byte-array blobs. We already special-case strings, but it's worthwhile to make it possible to create an immutable array of bytes, ints, pointers, whatever, that doesn't need to use MSVs. If we construct it by passing in a size and a function to be used to obtain the value to initialize each element, before handing back the pointer, we know that nobody could possibly get hold of the value in a partially initialized state. We might even be able to do the initialization in parallel (if the caller says the function can be called concurrently or if we have a Java stream initializer that hands in a parallel stream). For initialization from a Java array of primitives, we should be able to get our hands on the underlying array in the JNI call and do a copy initialization. The actual object would just need to have the element type (or, for primitives, just the kind) and a pointer to a gc_array of the appropriate type.