Package mpi

## Class Datatype

- java.lang.Object
- - mpi.Datatype

- All Implemented Interfaces:
    `java.lang.Cloneable`, `Freeable`

      public final class Datatype
      extends java.lang.Object
      implements Freeable, java.lang.Cloneable

  The `Datatype` class represents `MPI_Datatype` handles.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected int` | `baseSize` |
    `protected int` | `baseType` |
    `protected static int` | `BOOLEAN` |
    `protected static int` | `BYTE` |
    `protected static int` | `CHAR` |
    `protected static int` | `DOUBLE` |
    `protected static int` | `DOUBLE_COMPLEX` |
    `protected static int` | `DOUBLE_INT` |
    `protected static int` | `FLOAT` |
    `protected static int` | `FLOAT_COMPLEX` |
    `protected static int` | `FLOAT_INT` |
    `protected long` | `handle` |
    `protected static int` | `INT` |
    `protected static int` | `INT2` |
    `protected static int` | `LONG` |
    `protected static int` | `LONG_INT` |
    `protected static int` | `NULL` |
    `protected static int` | `PACKED` |
    `protected static int` | `SHORT` |
    `protected static int` | `SHORT_INT` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `Datatype()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Datatype` | `clone()` | Java binding of `MPI_TYPE_DUP`.
    `void` | `commit()` | Commits a derived datatype.
    `static Datatype` | `createContiguous​(int count, Datatype oldType)` | Construct new datatype representing replication of old datatype into contiguous locations.
    `static Datatype` | `createHIndexed​(int[] blockLengths, int[] displacements, Datatype oldType)` | Identical to `createIndexed` except that the displacements are expressed directly in terms of the buffer index, rather than the units of the old type.
    `static Datatype` | `createHVector​(int count, int blockLength, int stride, Datatype oldType)` | Identical to `createVector` except that the stride is expressed directly in terms of the buffer index, rather than the units of the old type.
    `static Datatype` | `createIndexed​(int[] blockLengths, int[] displacements, Datatype oldType)` | Construct new datatype representing replication of old datatype into a sequence of blocks where each block can contain a different number of copies and have a different displacement.
    `static int` | `createKeyval()` | Create a new attribute key.
    `static Datatype` | `createResized​(Datatype oldType, int lb, int extent)` | Create a datatype with a new lower bound and extent from an existing datatype.
    `static Datatype` | `createStruct​(int[] blockLengths, int[] displacements, Datatype[] types)` | The most general type constructor.
    `static Datatype` | `createVector​(int count, int blockLength, int stride, Datatype oldType)` | Construct new datatype representing replication of old datatype into locations that consist of equally spaced blocks.
    `void` | `deleteAttr​(int keyval)` | Deletes an attribute value associated with a key.
    `Datatype` | `dup()` | Java binding of `MPI_TYPE_DUP`.
    `void` | `free()` | Frees the datatype.
    `static void` | `freeKeyval​(int keyval)` | Frees an attribute key.
    `java.lang.Object` | `getAttr​(int keyval)` | Retrieves attribute value by key.
    `int` | `getExtent()` | Returns the extent of a datatype.
    `int` | `getLb()` | Returns the lower bound of a datatype.
    `java.lang.String` | `getName()` | Return the print name from the datatype.
    `protected int` | `getOffset​(java.lang.Object buffer)` | Gets the offset of a buffer in bytes.
    `int` | `getSize()` | Returns the total size of a datatype - the number of buffer elements it represents.
    `int` | `getTrueExtent()` | Returns the true extent of a datatype.
    `int` | `getTrueLb()` | Returns the true lower bound of a datatype.
    `boolean` | `isNull()` | Returns `true` if this datatype is MPI_DATATYPE_NULL.
    `void` | `setAttr​(int keyval, java.lang.Object value)` | Stores attribute value associated with a key.
    `protected void` | `setBasic​(int type)` |
    `protected void` | `setBasic​(int type, Datatype oldType)` |
    `void` | `setName​(java.lang.String name)` | Sets the print name for the datatype.

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### handle

          protected long handle

    - #### baseType

          protected int baseType

    - #### baseSize

          protected int baseSize

    - #### NULL

          protected static final int NULL

      See Also:
        Constant Field Values

    - #### BYTE

          protected static final int BYTE

      See Also:
        Constant Field Values

    - #### CHAR

          protected static final int CHAR

      See Also:
        Constant Field Values

    - #### SHORT

          protected static final int SHORT

      See Also:
        Constant Field Values

    - #### BOOLEAN

          protected static final int BOOLEAN

      See Also:
        Constant Field Values

    - #### INT

          protected static final int INT

      See Also:
        Constant Field Values

    - #### LONG

          protected static final int LONG

      See Also:
        Constant Field Values

    - #### FLOAT

          protected static final int FLOAT

      See Also:
        Constant Field Values

    - #### DOUBLE

          protected static final int DOUBLE

      See Also:
        Constant Field Values

    - #### PACKED

          protected static final int PACKED

      See Also:
        Constant Field Values

    - #### INT2

          protected static final int INT2

      See Also:
        Constant Field Values

    - #### SHORT_INT

          protected static final int SHORT_INT

      See Also:
        Constant Field Values

    - #### LONG_INT

          protected static final int LONG_INT

      See Also:
        Constant Field Values

    - #### FLOAT_INT

          protected static final int FLOAT_INT

      See Also:
        Constant Field Values

    - #### DOUBLE_INT

          protected static final int DOUBLE_INT

      See Also:
        Constant Field Values

    - #### FLOAT_COMPLEX

          protected static final int FLOAT_COMPLEX

      See Also:
        Constant Field Values

    - #### DOUBLE_COMPLEX

          protected static final int DOUBLE_COMPLEX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Datatype

          protected Datatype()

  - ### Method Detail

    - #### setBasic

          protected void setBasic​(int type)

    - #### setBasic

          protected void setBasic​(int type,
                                  Datatype oldType)

    - #### getLb

          public int getLb()
                    throws MPIException

      Returns the lower bound of a datatype.

      Java binding of the MPI operation `MPI_TYPE_GET_EXTENT`.

      Returns:
        lower bound of datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getExtent

          public int getExtent()
                        throws MPIException

      Returns the extent of a datatype.

      Java binding of the MPI operation `MPI_TYPE_GET_EXTENT`.

      Returns:
        datatype extent
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getTrueLb

          public int getTrueLb()
                        throws MPIException

      Returns the true lower bound of a datatype.

      Java binding of the MPI operation `MPI_TYPE_GET_TRUE_EXTENT`.

      Returns:
        lower bound of datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getTrueExtent

          public int getTrueExtent()
                            throws MPIException

      Returns the true extent of a datatype.

      Java binding of the MPI operation `MPI_TYPE_GET_TRUE_EXTENT`.

      Returns:
        datatype true extent
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getSize

          public int getSize()
                      throws MPIException

      Returns the total size of a datatype - the number of buffer elements it represents.

      Java binding of the MPI operation `MPI_TYPE_SIZE`.

      Returns:
        datatype size
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### commit

          public void commit()
                      throws MPIException

      Commits a derived datatype. Java binding of the MPI operation `MPI_TYPE_COMMIT`.
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### free

          public void free()
                    throws MPIException

      Frees the datatype.

      Java binding of the MPI operation `MPI_TYPE_FREE`.

      Specified by:
        `free` in interface `Freeable`
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### isNull

          public boolean isNull()

      Returns `true` if this datatype is MPI_DATATYPE_NULL.
      Returns:
        `true` if this datatype is MPI_DATATYPE_NULL

    - #### clone

          public Datatype clone()

      Java binding of `MPI_TYPE_DUP`.

      It is recommended to use `dup()` instead of `clone()` because the last can't throw an `MPIException`.

      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        new datatype

    - #### dup

          public Datatype dup()
                       throws MPIException

      Java binding of `MPI_TYPE_DUP`.
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createContiguous

          public static Datatype createContiguous​(int count,
                                                  Datatype oldType)
                                           throws MPIException

      Construct new datatype representing replication of old datatype into contiguous locations.

      Java binding of the MPI operation `MPI_TYPE_CONTIGUOUS`.

      The base type of the new datatype is the same as the base type of `oldType`.

      Parameters:
        `count` - replication count
        `oldType` - old datatype
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createVector

          public static Datatype createVector​(int count,
                                              int blockLength,
                                              int stride,
                                              Datatype oldType)
                                       throws MPIException

      Construct new datatype representing replication of old datatype into locations that consist of equally spaced blocks.

      Java binding of the MPI operation `MPI_TYPE_VECTOR`.

      The base type of the new datatype is the same as the base type of `oldType`.

      Parameters:
        `count` - number of blocks
        `blockLength` - number of elements in each block
        `stride` - number of elements between start of each block
        `oldType` - old datatype
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createHVector

          public static Datatype createHVector​(int count,
                                               int blockLength,
                                               int stride,
                                               Datatype oldType)
                                        throws MPIException

      Identical to `createVector` except that the stride is expressed directly in terms of the buffer index, rather than the units of the old type.

      Java binding of the MPI operation `MPI_TYPE_CREATE_HVECTOR`.

      Parameters:
        `count` - number of blocks
        `blockLength` - number of elements in each
        `stride` - number of bytes between start of each block
        `oldType` - old datatype
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createIndexed

          public static Datatype createIndexed​(int[] blockLengths,
                                               int[] displacements,
                                               Datatype oldType)
                                        throws MPIException

      Construct new datatype representing replication of old datatype into a sequence of blocks where each block can contain a different number of copies and have a different displacement.

      Java binding of the MPI operation `MPI_TYPE_INDEXED`.

      The number of blocks is taken to be size of the `blockLengths` argument. The second argument, `displacements`, should be the same size. The base type of the new datatype is the same as the base type of `oldType`.

      Parameters:
        `blockLengths` - number of elements per block
        `displacements` - displacement of each block in units of old type
        `oldType` - old datatype
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createHIndexed

          public static Datatype createHIndexed​(int[] blockLengths,
                                                int[] displacements,
                                                Datatype oldType)
                                         throws MPIException

      Identical to `createIndexed` except that the displacements are expressed directly in terms of the buffer index, rather than the units of the old type.

      Java binding of the MPI operation `MPI_TYPE_CREATE_HINDEXED`.

      Parameters:
        `blockLengths` - number of elements per block
        `displacements` - byte displacement in buffer for each block
        `oldType` - old datatype
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createStruct

          public static Datatype createStruct​(int[] blockLengths,
                                              int[] displacements,
                                              Datatype[] types)
                                       throws MPIException

      The most general type constructor.

      Java binding of the MPI operation `MPI_TYPE_CREATE_STRUCT`.

      The number of blocks is taken to be size of the `blockLengths` argument. The second and third arguments, `displacements`, and `types`, should be the same size.

      Parameters:
        `blockLengths` - number of elements in each block
        `displacements` - byte displacement of each block
        `types` - type of elements in each block
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createResized

          public static Datatype createResized​(Datatype oldType,
                                               int lb,
                                               int extent)
                                        throws MPIException

      Create a datatype with a new lower bound and extent from an existing datatype.

      Java binding of the MPI operation `MPI_TYPE_CREATE_RESIZED`.

      Parameters:
        `oldType` - input datatype
        `lb` - new lower bound of datatype (address integer)
        `extent` - new extent of datatype (address integer)
      Returns:
        new datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### setName

          public void setName​(java.lang.String name)
                       throws MPIException

      Sets the print name for the datatype.
      Parameters:
        `name` - name for the datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getName

          public java.lang.String getName()
                                   throws MPIException

      Return the print name from the datatype.
      Returns:
        name of the datatype
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### createKeyval

          public static int createKeyval()
                                  throws MPIException

      Create a new attribute key.

      Java binding of the MPI operation `MPI_TYPE_CREATE_KEYVAL`.

      Returns:
        attribute key for future access
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### freeKeyval

          public static void freeKeyval​(int keyval)
                                 throws MPIException

      Frees an attribute key.

      Java binding of the MPI operation `MPI_TYPE_FREE_KEYVAL`.

      Parameters:
        `keyval` - attribute key
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### setAttr

          public void setAttr​(int keyval,
                              java.lang.Object value)
                       throws MPIException

      Stores attribute value associated with a key.

      Java binding of the MPI operation `MPI_TYPE_SET_ATTR`.

      Parameters:
        `keyval` - attribute key
        `value` - attribute value
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getAttr

          public java.lang.Object getAttr​(int keyval)
                                   throws MPIException

      Retrieves attribute value by key.

      Java binding of the MPI operation `MPI_TYPE_GET_ATTR`.

      Parameters:
        `keyval` - attribute key
      Returns:
        attribute value or null if no attribute is associated with the key.
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### deleteAttr

          public void deleteAttr​(int keyval)
                          throws MPIException

      Deletes an attribute value associated with a key.

      Java binding of the MPI operation `MPI_TYPE_DELETE_ATTR`.

      Parameters:
        `keyval` - attribute key
      Throws:
        `MPIException` - Signals that an MPI exception of some sort has occurred.

    - #### getOffset

          protected int getOffset​(java.lang.Object buffer)

      Gets the offset of a buffer in bytes.
      Parameters:
        `buffer` - buffer
      Returns:
        offset in bytes