public class UserIndex
extends java.lang.Object
As a performance optimization, when running directly on IBM i, it is possible to use native
methods to access the user space from the current job. To enable this support, use the
setMustUseNativeMethods()
method.
Modifier and Type | Field and Description |
---|---|
static int |
FIND_BETWEEN |
static int |
FIND_EQUALS |
static int |
FIND_FIRST |
static int |
FIND_GREATER |
static int |
FIND_LAST |
static int |
FIND_LESSER |
static int |
FIND_NOT_GREATER |
static int |
FIND_NOT_LESSER |
static byte |
FIXED_LENGTH_ENTRIES |
static byte |
IMMEDIATE_UPDATE |
static byte |
INSERTION_BY_KEY |
static byte |
NO_IMMEDIATE_UPDATE |
static byte |
NO_INSERTION_BY_KEY |
static byte |
OPTIMIZE_FOR_RANDOM_REFERENCES |
static byte |
OPTIMIZE_FOR_SEQUENTIAL_REFERENCES |
static int |
RULE_INSERT
Insert unique argument.
|
static int |
RULE_INSERT_NO_REPLACE
Insert argument only if the key is not already in the index
|
static int |
RULE_INSERT_REPLACE
Insert argument, replacing the nonkey portion if the key is already in the index
|
static byte |
VARIABLE_LENGTH_ENTRIES |
Constructor and Description |
---|
UserIndex(AS400 system,
java.lang.String path)
Constructs a UserIndex object.
|
Modifier and Type | Method and Description |
---|---|
void |
create(java.lang.String extendedAttribute,
byte entryLengthAttribute,
int entryLength,
byte keyInsertion,
int keyLength,
byte immediateUpdate,
byte optimization,
java.lang.String authority,
java.lang.String description)
Creates a user index on the system.
|
void |
delete()
Deletes the user index.
|
void |
findEntries(byte[] outputBytes,
byte[] optionBytes,
byte[] keyBytes)
Returns one or more entries from the user index using the FNDINXEN MI instruction.
|
java.lang.String[][] |
findEntries(java.lang.String key,
int rule,
int occCount)
Returns one or more entries from the user index.
|
static int |
getOptionBytesReturnCount(byte[] optionBytes)
Utility method to obtain the return count from the option bytes.
|
void |
insertEntry(byte[] entryBytes,
byte[] optionBytes)
Inserts one or more entries into the user index using the insinxen MI instruction.
|
void |
insertEntry(java.lang.String key,
java.lang.String value,
int insertionRuleOption)
Inserts key and value represented as Strings into the INDEX.
|
boolean |
isMustUseNativeMethods()
Indicates if the native methods will be used internally to perform user index insertion and retrieval requests.
|
static void |
resetOptionBytes(byte[] optionBytes)
Utility method to reset the optionBytes.
|
void |
setMustUseNativeMethods(boolean useNativeMethods)
Specifies whether native methods are used by the current job to perform user index operations.
|
static void |
setOptionBytesArgLength(byte[] optionBytes,
int argLength)
Utility method to set the argument length in the option bytes
|
static void |
setOptionBytesOccCount(byte[] optionBytes,
int occurrenceCount)
Utility method to set the occurrence count in the option bytes
|
static void |
setOptionBytesRule(byte[] optionBytes,
int insertionRuleOption)
Utility method to set the rule option in the option bytes
|
java.lang.String |
toString()
Returns the String representation of this user index object.
|
public static final int FIND_EQUALS
public static final int FIND_GREATER
public static final int FIND_LESSER
public static final int FIND_NOT_LESSER
public static final int FIND_NOT_GREATER
public static final int FIND_FIRST
public static final int FIND_LAST
public static final int FIND_BETWEEN
public static final byte FIXED_LENGTH_ENTRIES
public static final byte VARIABLE_LENGTH_ENTRIES
public static final byte INSERTION_BY_KEY
public static final byte NO_INSERTION_BY_KEY
public static final byte IMMEDIATE_UPDATE
public static final byte NO_IMMEDIATE_UPDATE
public static final byte OPTIMIZE_FOR_RANDOM_REFERENCES
public static final byte OPTIMIZE_FOR_SEQUENTIAL_REFERENCES
public static final int RULE_INSERT
public static final int RULE_INSERT_REPLACE
public static final int RULE_INSERT_NO_REPLACE
public UserIndex(AS400 system, java.lang.String path) throws java.lang.Exception
system
- The system object representing the system on which the user index exists.path
- The fully qualified integrated file system path name of the user index.java.lang.Exception
- If an exception occurs.public void create(java.lang.String extendedAttribute, byte entryLengthAttribute, int entryLength, byte keyInsertion, int keyLength, byte immediateUpdate, byte optimization, java.lang.String authority, java.lang.String description) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, IllegalObjectTypeException, java.lang.InterruptedException, ObjectAlreadyExistsException, java.lang.Exception
extendedAttribute
- The extended attribute of the user index to be created.entryLengthAttribute
- Length attribute of the queue entries. Must be set to
FIXED_LENGTH_ENTRIES or VARIABLE_LENGTH_ENTRIES. Currently only FIXED_LENGTH_ENTRIES is supported.entryLength
- The length of entries in the index.
The valid values for fixed-length entries are from 1 through 2000.
Valid values for variable length entries are 0 or -1.
A value of 0 enables a maximum entry length of 120 bytes and a key length from 1 through 120.
A value of -1 enables a maximum entry length of 2000 and a key length from 1 through 2000.keyInsertion
- Whether the inserts to the index are by key. The valid values are:
INSERTION_BY_KEY and NO_INSERTION_BY_KEYkeyLength
- The length of the key where the first byte of an entry is the beginning of the key for the index entries.
The value for this parameter must be 0 for NO_INSERTION_BY_KEY.
If you specify key length insertion, this value is from 1 through 2000immediateUpdate
- Whether the updates to the index are written synchronously to auxiliary storage on each
update to the index. The valid values are: IMMEDIATE_UPDATE and NO_IMMEDIATE_UPDATE.optimization
- The type of access in which to optimize the index. The valid values are: OPTIMIZE_FOR_RANDOM_REFERENCES and OPTIMIZE_FOR_SEQUENTIAL_REFERENCES.authority
- The public authority for the user space. This string must be 10 characters or less.
Valid values are:
description
- AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the system.IllegalObjectTypeException
- If the object on the system is not the required type.java.lang.InterruptedException
- If this thread is interrupted.ObjectAlreadyExistsException
- If the object already exists on the system.java.lang.Exception
- If an exception occurs.public void delete()
public void insertEntry(java.lang.String key, java.lang.String value, int insertionRuleOption) throws java.lang.Exception
key
- The key for the new entryvalue
- The value portion of the new entryinsertionRuleOption
- The rule used for inserting the entries. Valid values are :
RULE_INSERT, RULE_INSERT_REPLACE, RULE_INSERT_NO_REPLACEjava.lang.Exception
- If an exception occurs.public void insertEntry(byte[] entryBytes, byte[] optionBytes) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, IllegalObjectTypeException, java.lang.InterruptedException, ObjectDoesNotExistException
entryBytes
- Byte array containing the bytes of the entry or entries to be inserted.optionBytes
- Byte array containing insertion options.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the system.IllegalObjectTypeException
- If the object on the system is not the required type.java.lang.InterruptedException
- If this thread is interrupted.ObjectDoesNotExistException
- If the object does not exist on the system.public java.lang.String[][] findEntries(java.lang.String key, int rule, int occCount) throws java.lang.Exception
key
- rule
- occCount
- java.lang.Exception
- If an exception occurs.public void findEntries(byte[] outputBytes, byte[] optionBytes, byte[] keyBytes) throws java.lang.Exception
outputBytes
- Byte array into which the returned entries are placed.optionBytes
- Byte array containing the options for the query. Also returns
information about the retrieved entries.keyBytes
- Byte array containing the key used to find the entries.java.lang.Exception
- If an exception occurs.public java.lang.String toString()
toString
in class java.lang.Object
public boolean isMustUseNativeMethods()
setMustUseNativeMethods(boolean)
public void setMustUseNativeMethods(boolean useNativeMethods)
useNativeMethods
- Internally use ProgramCall to perform read and write requests.isMustUseNativeMethods()
public static void resetOptionBytes(byte[] optionBytes)
optionBytes
- public static void setOptionBytesRule(byte[] optionBytes, int insertionRuleOption)
optionBytes
- insertionRuleOption
- public static void setOptionBytesArgLength(byte[] optionBytes, int argLength)
optionBytes
- argLength
- public static void setOptionBytesOccCount(byte[] optionBytes, int occurrenceCount)
optionBytes
- occurrenceCount
- public static int getOptionBytesReturnCount(byte[] optionBytes)
optionBytes
-