Interface LowLevelCAS

All Known Implementing Classes:
CASImpl

public interface LowLevelCAS
Defines the low-level CAS APIs. The low-level CAS APIs provide no access to feature structure objects. All access to CAS data is through integer IDs that represent handles to the CAS data.

The basic concepts of the low-level APIs is very simple. The CAS does not internally hold its data as Java objects, for performance reasons. The low-level APIs give you access to this data more or less directly. Instead of creating Java objects that you can manipulate in an OO fashion, you only obtain int values that are used as references to internal data. Thus, if you would like to change values on a particular piece of data, you need to hand the FS reference to the API, as opposed to calling methods on a FS object. The tricky part about the low-level APIs is that it's all just ints, and it is very easy to confuse an int that represents a type code with an int that represents a feature code or a FS reference. Particular care is therefore necessary when using the low-level APIs. Please follow the guidelines for turning on a minimum of checks below.

This API represents the supported access to low-level features of the UIMA framework CAS implementation. Other public APIs in the implementation are not supported and are subject to change without notice.

Please note that you really need to know what you're doing when using these APIs. Incorrect usage of these APIs can and will cause completely unpredictable results; likely your application will crash, and it will do so much later than where the incorrect usage occured. The low-level APIs are very hard to debug. You should only use the low-level APIs if you have carefully profiled your application and are sure that the high-level CAS APIs or the JCAS represent a performance bottleneck.

Note that most low-level APIs have versions that allow you to turn some form of parameter checking on. We strongly encourage you to use those versions during development, they may save you a lot of time. One way you can use the type checking switch is by having a constant

 
 static final boolean DO_TYPE_CHECK = true;
 

which you can use during development. For production level code, you can later change the constant to false. The performance difference to the non-parametrized versions of the getters and setters is probably negligible or may not even exist, depending on the Java runtime.

Please note that even with the check switches turned on, it is still possible to make mistakes that only show up much later in processing. The main problem is that it is simply impossible to determine for certain whether a given FS reference is valid or not. The implementation can only determine that it looks like a reference that points at a valid piece of data, but this could be accidental.

  • Field Details

  • Method Details

    • ll_getTypeSystem

      LowLevelTypeSystem ll_getTypeSystem()
      Get the low-level version of the type system object. It provides access to the low-level type and feature codes you need to use the data creation and access APIs.
      Returns:
      The low-level type system.
    • ll_getIndexRepository

      LowLevelIndexRepository ll_getIndexRepository()
      Get the low-level version of the index repository. Use it to gain access to low-level indexes, and thus, low-level iterators.
      Returns:
      A low-level version of the index repository.
    • ll_createFS

      int ll_createFS(int typeCode)
      Create a new FS on the heap.
      Parameters:
      typeCode - The low-level code of the type of the FS that should be created. If the typeCode is not a valid type code, the results of this call are undefined.
      Returns:
      The reference of the newly created FS.
    • ll_createFS

      int ll_createFS(int typeCode, boolean doTypeCheck)
      Create a new FS on the heap.
      Parameters:
      typeCode - The low-level code of the type of the FS that should be created. If the typeCode is not a valid type code and the type check flag is not set, the results of this call are undefined.
      doTypeCheck - -
      Returns:
      The reference of the newly created FS.
      Throws:
      LowLevelException - If the type checking switch is set and the type code argument is not valid.
    • ll_createArray

      int ll_createArray(int typeCode, int arrayLength)
      Create a new array.
      Parameters:
      typeCode - The type code of the array type. If this is not a valid array type code, the behavior of this call is undefined. Only works for arrays where a value is kept in the main heap (use other ll_createXxxArray for boolean, byte, short, long, and double)
      arrayLength - The length of the array to be created.
      Returns:
      The address of the newly created array.
    • ll_createArray

      int ll_createArray(int typeCode, int arrayLength, boolean doChecks)
      Create a new array.
      Parameters:
      typeCode - The type code of the array to be created.
      arrayLength - The length of the array to be created.
      doChecks - Switch to turn on various sanity checks.
      Returns:
      The address of the newly created array.
    • ll_createBooleanArray

      int ll_createBooleanArray(int arrayLength)
    • ll_createByteArray

      int ll_createByteArray(int arrayLength)
    • ll_createShortArray

      int ll_createShortArray(int arrayLength)
    • ll_createLongArray

      int ll_createLongArray(int arrayLength)
    • ll_createDoubleArray

      int ll_createDoubleArray(int arrayLength)
    • ll_getArraySize

      int ll_getArraySize(int arrayFsRef)
      Get the size of an array.
      Parameters:
      arrayFsRef - The array reference.
      Returns:
      The size of the array.
    • ll_getFSRef

      int ll_getFSRef(FeatureStructure fsImpl)
      Get the low-level reference from an existing FS object. Use this API if you already have a FS object from somewhere, and want to apply low-level APIs to it. Has a side effect of adding the FS to the internal table allowing ll_getFSforRef. Note: This prevents the object from being GC'd, so this use is deprecated.
      Parameters:
      fsImpl - The FS object for which we want the reference.
      Returns:
      The low-level reference of the FS object parameter.
    • ll_getFSForRef

      <T extends TOP> T ll_getFSForRef(int fsRef)

      Return a FS object that corresponds to a low-level reference. Note that this must be a valid reference that has been obtained from the low-level APIs. If the input reference parameter does not represent a valid reference, an exception is thrown.

      In version 3, the map this API uses is not normally populated; it is populated only for Feature Structures created using the low-level APIs, and also when the ll_getFSRef API (above) is used, or the getAddress method is called on a Feature Structure

      Type Parameters:
      T - the Java class for the Feature Structure
      Parameters:
      fsRef - The FS reference.
      Returns:
      A FS object corresponding to the input reference.
    • ll_getIntValue

      int ll_getIntValue(int fsRef, int featureCode)
      Get the value of an integer valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      Returns:
      The value of the feature.
    • ll_getFloatValue

      float ll_getFloatValue(int fsRef, int featureCode)
      Get the value of a float valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      Returns:
      The value of the feature.
    • ll_getStringValue

      String ll_getStringValue(int fsRef, int featureCode)
      Get the value of a string valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      Returns:
      The value of the feature.
    • ll_getRefValue

      int ll_getRefValue(int fsRef, int featureCode)
      Get the value of a FS reference valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      Returns:
      The value of the feature.
    • ll_getIntValue

      int ll_getIntValue(int fsRef, int featureCode, boolean doTypeChecks)
      Get the value of an integer valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value of the feature.
    • ll_getFloatValue

      float ll_getFloatValue(int fsRef, int featureCode, boolean doTypeChecks)
      Get the value of a float valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value of the feature.
    • ll_getStringValue

      String ll_getStringValue(int fsRef, int featureCode, boolean doTypeChecks)
      Get the value of a string valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value of the feature.
    • ll_getRefValue

      int ll_getRefValue(int fsRef, int featureCode, boolean doTypeChecks)
      Get the value of a FS reference valued feature.
      Parameters:
      fsRef - The reference to the FS from which to obtain the feature value.
      featureCode - The low-level code of the feature whose value is to be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value of the feature.
    • ll_setIntValue

      void ll_setIntValue(int fsRef, int featureCode, int value)
      Set the value of an integer feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
    • ll_setFloatValue

      void ll_setFloatValue(int fsRef, int featureCode, float value)
      Set the value of a float feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
    • ll_setStringValue

      void ll_setStringValue(int fsRef, int featureCode, String value)
      Set the value of a string feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
    • ll_setRefValue

      void ll_setRefValue(int fsRef, int featureCode, int value)
      Set the value of a FS reference feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
    • ll_setIntValue

      void ll_setIntValue(int fsRef, int featureCode, int value, boolean doTypeChecks)
      Set the value of an integer feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
      doTypeChecks - Switch to turn on type checking.
    • ll_setFloatValue

      void ll_setFloatValue(int fsRef, int featureCode, float value, boolean doTypeChecks)
      Set the value of a float feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
      doTypeChecks - Switch to turn on type checking.
    • ll_setStringValue

      void ll_setStringValue(int fsRef, int featureCode, String value, boolean doTypeChecks)
      Set the value of a string feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
      doTypeChecks - Switch to turn on type checking.
    • ll_setCharBufferValue

      void ll_setCharBufferValue(int fsRef, int featureCode, char[] buffer, int start, int length, boolean doChecks)
    • ll_setCharBufferValue

      void ll_setCharBufferValue(int fsRef, int featureCode, char[] buffer, int start, int length)
    • ll_getCharBufferValueSize

      int ll_getCharBufferValueSize(int fsRef, int featureCode)
    • ll_copyCharBufferValue

      int ll_copyCharBufferValue(int fsRef, int featureCode, char[] buffer, int start)
    • ll_setRefValue

      void ll_setRefValue(int fsRef, int featureCode, int value, boolean doTypeChecks)
      Set the value of a FS reference feature.
      Parameters:
      fsRef - The reference of the FS on which the feature should be set.
      featureCode - The low-level feature code for the feature that should be set.
      value - The value to be assigned to the feature.
      doTypeChecks - Switch to turn on type checking.
    • ll_getIntArrayValue

      int ll_getIntArrayValue(int fsRef, int position)
      Get the value of an array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      Returns:
      The value at position.
    • ll_getFloatArrayValue

      float ll_getFloatArrayValue(int fsRef, int position)
      Get the value of a float array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      Returns:
      The value at position.
    • ll_getStringArrayValue

      String ll_getStringArrayValue(int fsRef, int position)
      Get the value of a string array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      Returns:
      The value at position.
    • ll_getRefArrayValue

      int ll_getRefArrayValue(int fsRef, int position)
      Get the value of a FS reference array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      Returns:
      The value at position.
    • ll_getIntArrayValue

      int ll_getIntArrayValue(int fsRef, int position, boolean doTypeChecks)
      Get the value of an integer array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value at position.
    • ll_getFloatArrayValue

      float ll_getFloatArrayValue(int fsRef, int position, boolean doTypeChecks)
      Get the value of a float array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value at position.
    • ll_getStringArrayValue

      String ll_getStringArrayValue(int fsRef, int position, boolean doTypeChecks)
      Get the value of a string array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value at position.
    • ll_getRefArrayValue

      int ll_getRefArrayValue(int fsRef, int position, boolean doTypeChecks)
      Get the value of a FS reference array at a certain position.
      Parameters:
      fsRef - The reference to the array FS.
      position - The position whose value should be returned.
      doTypeChecks - Switch to turn on type checking.
      Returns:
      The value at position.
    • ll_setIntArrayValue

      void ll_setIntArrayValue(int fsRef, int position, int value, boolean doTypeChecks)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      doTypeChecks - Switch to turn on type and bounds checking.
      value - The new value.
    • ll_setFloatArrayValue

      void ll_setFloatArrayValue(int fsRef, int position, float value, boolean doTypeChecks)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      doTypeChecks - Switch to turn on type and bounds checking.
      value - The new value.
    • ll_setStringArrayValue

      void ll_setStringArrayValue(int fsRef, int position, String value, boolean doTypeChecks)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      doTypeChecks - Switch to turn on type and bounds checking.
      value - The new value.
    • ll_setRefArrayValue

      void ll_setRefArrayValue(int fsRef, int position, int value, boolean doTypeChecks)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      doTypeChecks - Switch to turn on type and bounds checking.
      value - The new value.
    • ll_setIntArrayValue

      void ll_setIntArrayValue(int fsRef, int position, int value)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      value - The new value.
    • ll_setFloatArrayValue

      void ll_setFloatArrayValue(int fsRef, int position, float value)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      value - The new value.
    • ll_setStringArrayValue

      void ll_setStringArrayValue(int fsRef, int position, String value)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      value - The new value.
    • ll_setRefArrayValue

      void ll_setRefArrayValue(int fsRef, int position, int value)
      Set the value of an integer array at a certain position.
      Parameters:
      fsRef - The FS reference of the array.
      position - The position whose value will be changed.
      value - The new value.
    • ll_getFSRefType

      int ll_getFSRefType(int fsRef)
      Get the type code for a FS reference. No bounds checks are performed. If fsRef is not a fs reference, the results are undefined. There is also a checked version of this call, which will give better error messages in case of problems.
      Parameters:
      fsRef - The FS reference.
      Returns:
      The type code for the FS reference; a return value of 0 means that the fsRef is invalid, i.e., NULL_FS_REF (but see remarks on bounds checking for this method).
    • ll_getFSRefType

      int ll_getFSRefType(int fsRef, boolean doChecks)
      Get the type code for a FS reference.
      Parameters:
      fsRef - The FS reference.
      doChecks - Check fsRef for out-of-range errors. If this switch is not set, and the input reference is not a valid reference, the results are undefined.
      Returns:
      The type code for the FS reference; a return value of 0 means that the fsRef is invalid, i.e., NULL_FS_REF (but see remarks on bounds checking for this method).
    • ll_getTypeClass

      int ll_getTypeClass(int typeCode)
      Determine the type class of a type. This is useful for generic CAS exploiters to determine what kind of data they're looking at. The type classes currently defined are:
      • TYPE_CLASS_INVALID -- Not a valid type code.
      • TYPE_CLASS_INT -- Integer type.
      • TYPE_CLASS_FLOAT -- Float type.
      • TYPE_CLASS_STRING -- String type.
      • TYPE_CLASS_BOOLEAN -- Boolean type.
      • TYPE_CLASS_BYTE -- Byte type.
      • TYPE_CLASS_SHORT -- Short type.
      • TYPE_CLASS_LONG -- Long type.
      • TYPE_CLASS_DOUBLE -- Double type.
      • TYPE_CLASS_INTARRAY -- Integer array.
      • TYPE_CLASS_FLOATARRAY -- Float array.
      • TYPE_CLASS_STRINGARRAY -- String array.
      • TYPE_CLASS_BOOLEANARRAY -- Boolean array.
      • TYPE_CLASS_BYTEARRAY -- Byte array.
      • TYPE_CLASS_SHORTARRAY -- Short array.
      • TYPE_CLASS_LONGARRAY -- Long array.
      • TYPE_CLASS_DOUBLEARRAY -- Double array.
      • TYPE_CLASS_FSARRAY -- FS array.
      • TYPE_CLASS_FS -- FS type, i.e., all other types, including all user-defined types.
      This method is on the CAS, not the type system, since the specific properties of types are specific to the CAS. The type system does not know, for example, that the CAS treats arrays specially.
      Parameters:
      typeCode - The type code.
      Returns:
      A type class for the type code. TYPE_CLASS_INVALID if the type code argument does not represent a valid type code.
    • ll_isRefType

      boolean ll_isRefType(int typeCode)
      Checks if the type code is that of a reference type (anything that's not a basic type, currently Integer, String and Float).
      Parameters:
      typeCode - The type code to check.
      Returns:
      true iff typeCode is the type code of a reference type.
    • ll_getByteValue

      byte ll_getByteValue(int fsRef, int featureCode)
    • ll_getBooleanValue

      boolean ll_getBooleanValue(int fsRef, int featureCode)
    • ll_getShortValue

      short ll_getShortValue(int fsRef, int featureCode)
    • ll_getLongValue

      long ll_getLongValue(int fsRef, int featureCode)
    • ll_getDoubleValue

      double ll_getDoubleValue(int fsRef, int featureCode)
    • ll_getByteValue

      byte ll_getByteValue(int fsRef, int featureCode, boolean doTypeChecks)
    • ll_getBooleanValue

      boolean ll_getBooleanValue(int fsRef, int featureCode, boolean doTypeChecks)
    • ll_getShortValue

      short ll_getShortValue(int fsRef, int featureCode, boolean doTypeChecks)
    • ll_getLongValue

      long ll_getLongValue(int fsRef, int featureCode, boolean doTypeChecks)
    • ll_getDoubleValue

      double ll_getDoubleValue(int fsRef, int featureCode, boolean doTypeChecks)
    • ll_setBooleanValue

      void ll_setBooleanValue(int fsRef, int featureCode, boolean value)
    • ll_setByteValue

      void ll_setByteValue(int fsRef, int featureCode, byte value)
    • ll_setShortValue

      void ll_setShortValue(int fsRef, int featureCode, short value)
    • ll_setLongValue

      void ll_setLongValue(int fsRef, int featureCode, long value)
    • ll_setDoubleValue

      void ll_setDoubleValue(int fsRef, int featureCode, double value)
    • ll_setBooleanValue

      void ll_setBooleanValue(int fsRef, int featureCode, boolean value, boolean doTypeChecks)
    • ll_setByteValue

      void ll_setByteValue(int fsRef, int featureCode, byte value, boolean doTypeChecks)
    • ll_setShortValue

      void ll_setShortValue(int fsRef, int featureCode, short value, boolean doTypeChecks)
    • ll_setLongValue

      void ll_setLongValue(int fsRef, int featureCode, long value, boolean doTypeChecks)
    • ll_setDoubleValue

      void ll_setDoubleValue(int fsRef, int featureCode, double value, boolean doTypeChecks)
    • ll_getByteArrayValue

      byte ll_getByteArrayValue(int fsRef, int position)
    • ll_getBooleanArrayValue

      boolean ll_getBooleanArrayValue(int fsRef, int position)
    • ll_getShortArrayValue

      short ll_getShortArrayValue(int fsRef, int position)
    • ll_getLongArrayValue

      long ll_getLongArrayValue(int fsRef, int position)
    • ll_getDoubleArrayValue

      double ll_getDoubleArrayValue(int fsRef, int position)
    • ll_getByteArrayValue

      byte ll_getByteArrayValue(int fsRef, int position, boolean doTypeChecks)
    • ll_getBooleanArrayValue

      boolean ll_getBooleanArrayValue(int fsRef, int position, boolean doTypeChecks)
    • ll_getShortArrayValue

      short ll_getShortArrayValue(int fsRef, int position, boolean doTypeChecks)
    • ll_getLongArrayValue

      long ll_getLongArrayValue(int fsRef, int position, boolean doTypeChecks)
    • ll_getDoubleArrayValue

      double ll_getDoubleArrayValue(int fsRef, int position, boolean doTypeChecks)
    • ll_setByteArrayValue

      void ll_setByteArrayValue(int fsRef, int position, byte value)
    • ll_setBooleanArrayValue

      void ll_setBooleanArrayValue(int fsRef, int position, boolean b)
    • ll_setShortArrayValue

      void ll_setShortArrayValue(int fsRef, int position, short value)
    • ll_setLongArrayValue

      void ll_setLongArrayValue(int fsRef, int position, long value)
    • ll_setDoubleArrayValue

      void ll_setDoubleArrayValue(int fsRef, int position, double d)
    • ll_setByteArrayValue

      void ll_setByteArrayValue(int fsRef, int position, byte value, boolean doTypeChecks)
    • ll_setBooleanArrayValue

      void ll_setBooleanArrayValue(int fsRef, int position, boolean b, boolean doTypeChecks)
    • ll_setShortArrayValue

      void ll_setShortArrayValue(int fsRef, int position, short value, boolean doTypeChecks)
    • ll_setLongArrayValue

      void ll_setLongArrayValue(int fsRef, int position, long value, boolean doTypeChecks)
    • ll_setDoubleArrayValue

      void ll_setDoubleArrayValue(int fsRef, int position, double d, boolean doTypeChecks)
    • ll_getSofaCasView

      CASImpl ll_getSofaCasView(int addr)
    • ll_getSofa

      int ll_getSofa()
    • ll_enableV2IdRefs

      default AutoCloseableNoException ll_enableV2IdRefs()
      Enables the id_to_fs_map mode.
      Returns:
      an AutoClosable whose close method doesn't throw an exception that will reset the mode to what it was when it was changed
    • ll_enableV2IdRefs

      AutoCloseableNoException ll_enableV2IdRefs(boolean enable)
      Enables or disables the id_to_fs_map mode.
      Parameters:
      enable - true to enable, false to disable
      Returns:
      an AutoClosable whose close method doesn't throw an exception that will reset the mode to what it was when it was changed
    • is_ll_enableV2IdRefs

      boolean is_ll_enableV2IdRefs()
      Returns:
      true if the id_to_fs_map mode is enabled
    • ll_defaultV2IdRefs

      static AutoCloseableNoException ll_defaultV2IdRefs()
      Defaults new CASs to have the id_to_fs_map enabled
      Returns:
      an AutoCloseable which restores the previous setting
    • ll_defaultV2IdRefs

      static AutoCloseableNoException ll_defaultV2IdRefs(boolean enable)
      Sets the defaults for new CASs to have the id_to_fs_map enabled.
      Parameters:
      enable - true to enable, false to disable
      Returns:
      an AutoCloseable which restores the previous setting