Space space = spaces.get(spaceNum);
Index primary = space.indexes.get(0);
Tuple stored = primary.getOne(tuple);
if (stored != null) {
if (stored.size() < fieldNo || fieldNo < 0) {
throw new TarantoolException(54, String.format("Field %d was not found in the tuple", fieldNo));
}
if (up == Updates.ADD || up == Updates.AND || up == Updates.XOR || up == Updates.OR || up == Updates.MAX || up == Updates.SUB) {
int storedFieldLength = stored.getBytes(fieldNo).length;
if (storedFieldLength == 4) {
stored.setInt(fieldNo, (int) arithmeticUpdate(up, stored.getInt(fieldNo), args.getInt(0)));
} else if (storedFieldLength == 8) {
stored.setLong(fieldNo, arithmeticUpdate(up, stored.getLong(fieldNo), args.getBytes(0).length == 4 ? args.getInt(0) : args.getLong(0)));
} else {
throw new TarantoolException(40, String.format("Field type does not match one required by operation: expected a %s", "NUM or NUM 64"));
}
} else if (up == Updates.DELETE) {
stored = deleteField(fieldNo, stored);
if (stored.size() < 2) {
throw new TarantoolException(25, "UPDATE error: the new tuple has no fields");
}
} else if (up == Updates.INSERT) {
stored = insertField(fieldNo, args, stored);
} else if (up == Updates.SPLICE) {
splice(fieldNo, args, stored);