Class DirectBufferResolver


  • public final class DirectBufferResolver
    extends java.lang.Object
    Decodes the zero-copy ByteBuffer the native layer hands back for responses above the 16 KB threshold. Every response path shares this one decoder so no two of them can drift apart.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object[] deserializeByteBufferArray​(java.nio.ByteBuffer buffer, boolean expectUtf8Response)
      Deserialize a ByteBuffer containing a serialized array back to Object[].
      static java.util.LinkedHashMap<java.lang.Object,​java.lang.Object> deserializeByteBufferMap​(java.nio.ByteBuffer buffer, boolean expectUtf8)
      Deserialize a ByteBuffer containing a serialized map back to Map.
      static java.lang.Object normalizeDirectBuffer​(java.nio.ByteBuffer buffer, boolean expectUtf8Response)
      Decode a direct buffer into the same object a smaller response would have produced: a String or GlideString for a bulk value, an Object[] for an array, or a LinkedHashMap for a map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • normalizeDirectBuffer

        public static java.lang.Object normalizeDirectBuffer​(java.nio.ByteBuffer buffer,
                                                             boolean expectUtf8Response)
        Decode a direct buffer into the same object a smaller response would have produced: a String or GlideString for a bulk value, an Object[] for an array, or a LinkedHashMap for a map.
      • deserializeByteBufferMap

        public static java.util.LinkedHashMap<java.lang.Object,​java.lang.Object> deserializeByteBufferMap​(java.nio.ByteBuffer buffer,
                                                                                                                boolean expectUtf8)
        Deserialize a ByteBuffer containing a serialized map back to Map. Format: '%' + count(u32 BE) + repeated [keyLen(u32) + keyBytes + valLen(u32) + valBytes]

        This method includes defense-in-depth validation to protect against malformed buffers from the native layer (due to bugs or memory corruption).

        Throws:
        java.lang.IllegalArgumentException - if the buffer format is invalid or contains out-of-bounds values
      • deserializeByteBufferArray

        public static java.lang.Object[] deserializeByteBufferArray​(java.nio.ByteBuffer buffer,
                                                                    boolean expectUtf8Response)
        Deserialize a ByteBuffer containing a serialized array back to Object[]. This handles DirectByteBuffer responses for large data (>16KB). Format uses Redis-like protocol: '*' + array_len(4 bytes BE) + elements Each element: type_marker + data

        This method includes defense-in-depth validation to protect against malformed buffers from the native layer (due to bugs or memory corruption).

        Throws:
        java.lang.IllegalArgumentException - if the buffer format is invalid or contains out-of-bounds values