MapBuffer

MapBuffer is an optimized sparse array format for transferring props-like data between C++ and JNI. It is designed to:

  • be compact to optimize space when sparse (sparse is the common case).

  • be accessible through JNI with zero/minimal copying.

  • work recursively for nested maps/arrays.

  • support dynamic types that map to JSON.

  • have minimal APK size and build time impact.

See for more information and native implementation.

Limitations:

  • Keys are usually sized as 2 bytes, with each buffer supporting up to 65536 entries as a result.

  • O(log(N)) random key access for native buffers due to selected structure. Faster access can be achieved by retrieving MapBuffer.Entry with entryAt on known offsets.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Data types supported by MapBuffer. Keep in sync with definition in <react/renderer/mapbuffer/MapBuffer.h>, as enum serialization relies on correct order.

Link copied to clipboard
interface Entry

Iterable entry representing parsed MapBuffer values

Properties

Link copied to clipboard
abstract val count: Int

Number of elements inserted into current MapBuffer.

Functions

Link copied to clipboard
abstract fun contains(key: Int): Boolean

Checks whether entry for given key exists in MapBuffer.

Link copied to clipboard
abstract fun entryAt(offset: Int): MapBuffer.Entry

Provides parsed access to a MapBuffer without additional lookups for provided offset.

Link copied to clipboard
open fun forEach(p0: Consumer<in MapBuffer.Entry>)
Link copied to clipboard
abstract fun getBoolean(key: Int): Boolean

Provides parsed Boolean value if the entry for given key exists with DataType.BOOL type

Link copied to clipboard
abstract fun getDouble(key: Int): Double

Provides parsed Double value if the entry for given key exists with DataType.DOUBLE type

Link copied to clipboard
abstract fun getInt(key: Int): Int

Provides parsed Int value if the entry for given key exists with DataType.INT type

Link copied to clipboard
abstract fun getKeyOffset(key: Int): Int

Provides offset of the key to use for entryAt, for cases when offset is not statically known but can be cached.

Link copied to clipboard
abstract fun getLong(key: Int): Long

Provides parsed Long value if the entry for given key exists with DataType.LONG type

Link copied to clipboard
abstract fun getMapBuffer(key: Int): MapBuffer

Provides parsed MapBuffer value if the entry for given key exists with DataType.MAP type

Link copied to clipboard
abstract fun getMapBufferList(key: Int): List<MapBuffer>

Provides parsed List value if the entry for given key exists with DataType.MAP type

Link copied to clipboard
abstract fun getString(key: Int): String

Provides parsed String value if the entry for given key exists with DataType.STRING type

Link copied to clipboard
abstract fun getType(key: Int): MapBuffer.DataType

Provides parsed DataType annotation associated with the given key.

Link copied to clipboard
abstract operator fun iterator(): Iterator<MapBuffer.Entry>
Link copied to clipboard