Class BinarySchema

  • All Implemented Interfaces:
    Externalizable, Serializable

    public class BinarySchema
    extends Object
    implements Externalizable
    Schema describing binary object content. We rely on the following assumptions: - When amount of fields in the object is low, it is better to inline these values into int fields thus allowing for quick comparisons performed within already fetched L1 cache line. - When there are more fields, we store them inside a hash map.
    See Also:
    Serialized Form
    • Field Detail

      • ORDER_NOT_FOUND

        public static final int ORDER_NOT_FOUND
        Order returned if field is not found.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BinarySchema

        public BinarySchema​(int schemaId,
                            List<Integer> fieldIds)
        Constructor.
        Parameters:
        schemaId - Schema ID.
        fieldIds - Field IDs.
    • Method Detail

      • schemaId

        public int schemaId()
        Returns:
        Schema ID.
      • confirmOrder

        public BinarySchema.Confirmation confirmOrder​(int expOrder,
                                                      String expName)
        Try speculatively confirming order for the given field name.
        Parameters:
        expOrder - Expected order.
        expName - Expected name.
        Returns:
        Field ID.
      • clarifyFieldName

        public void clarifyFieldName​(int order,
                                     String name)
        Add field name.
        Parameters:
        order - Order.
        name - Name.
      • fieldId

        public int fieldId​(int order)
        Get field ID by order in footer.
        Parameters:
        order - Order.
        Returns:
        Field ID.
      • order

        public int order​(int id)
        Get field order in footer by field ID.
        Parameters:
        id - Field ID.
        Returns:
        Offset or 0 if there is no such field.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • writeTo

        public void writeTo​(DataOutput out)
                     throws IOException
        The object implements the writeTo method to save its contents by calling the methods of DataOutput for its primitive values and strings or calling the writeTo method for other objects.
        Parameters:
        out - the stream to write the object to.
        Throws:
        IOException - Includes any I/O exceptions that may occur.
      • readFrom

        public void readFrom​(DataInput in)
                      throws IOException
        The object implements the readFrom method to restore its contents by calling the methods of DataInput for primitive types and strings or calling readFrom for other objects. The readFrom method must read the values in the same sequence and with the same types as were written by writeTo.
        Parameters:
        in - the stream to read data from in order to restore the object
        Throws:
        IOException - if I/O errors occur
      • fieldIds

        public int[] fieldIds()
        Gets field ids array.
        Returns:
        Field ids.