Example usage for java.lang IndexOutOfBoundsException IndexOutOfBoundsException

List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException

Introduction

In this page you can find the example usage for java.lang IndexOutOfBoundsException IndexOutOfBoundsException.

Prototype

public IndexOutOfBoundsException() 

Source Link

Document

Constructs an IndexOutOfBoundsException with no detail message.

Usage

From source file:eu.stratosphere.pact.runtime.task.RegularPactTask.java

@Override
public <X> MutableObjectIterator<X> getInput(int index) {
    if (index < 0 || index > this.driver.getNumberOfInputs()) {
        throw new IndexOutOfBoundsException();
    }//from   ww w .j a  v a2s  . c  o m

    // check for lazy assignment from input strategies
    if (this.inputs[index] != null) {
        @SuppressWarnings("unchecked")
        MutableObjectIterator<X> in = (MutableObjectIterator<X>) this.inputs[index];
        return in;
    } else {
        final MutableObjectIterator<X> in;
        try {
            if (this.tempBarriers[index] != null) {
                @SuppressWarnings("unchecked")
                MutableObjectIterator<X> iter = (MutableObjectIterator<X>) this.tempBarriers[index]
                        .getIterator();
                in = iter;
            } else if (this.localStrategies[index] != null) {
                @SuppressWarnings("unchecked")
                MutableObjectIterator<X> iter = (MutableObjectIterator<X>) this.localStrategies[index]
                        .getIterator();
                in = iter;
            } else {
                throw new RuntimeException(
                        "Bug: null input iterator, null temp barrier, and null local strategy.");
            }
            this.inputs[index] = in;
            return in;
        } catch (InterruptedException iex) {
            throw new RuntimeException(
                    "Interrupted while waiting for input " + index + " to become available.");
        } catch (IOException ioex) {
            throw new RuntimeException("An I/O Exception occurred whily obaining input " + index + ".");
        }
    }
}

From source file:eu.stratosphere.pact.runtime.task.RegularPactTask.java

@Override
public <X> TypeSerializerFactory<X> getInputSerializer(int index) {
    if (index < 0 || index >= this.driver.getNumberOfInputs()) {
        throw new IndexOutOfBoundsException();
    }/*from   w  w w  . j av  a  2s. c o m*/

    @SuppressWarnings("unchecked")
    final TypeSerializerFactory<X> serializerFactory = (TypeSerializerFactory<X>) this.inputSerializers[index];
    return serializerFactory;
}

From source file:eu.stratosphere.pact.runtime.task.RegularPactTask.java

@Override
public <X> TypeComparator<X> getInputComparator(int index) {
    if (this.inputComparators == null) {
        throw new IllegalStateException("Comparators have not been created!");
    } else if (index < 0 || index >= this.driver.getNumberOfInputs()) {
        throw new IndexOutOfBoundsException();
    }/*from www  .ja va  2 s.  c  o m*/

    @SuppressWarnings("unchecked")
    final TypeComparator<X> comparator = (TypeComparator<X>) this.inputComparators[index];
    return comparator;
}

From source file:com.mellanox.r4h.MiniDFSCluster.java

/**
 * /*from ww  w  . j ava2 s.c  om*/
 * @param dataNodeIndex
 *            - data node whose block report is desired - the index is same as for getDataNodes()
 * @return the block report for the specified data node
 */
public Map<DatanodeStorage, BlockListAsLongs> getBlockReport(String bpid, int dataNodeIndex) {
    if (dataNodeIndex < 0 || dataNodeIndex > dataNodes.size()) {
        throw new IndexOutOfBoundsException();
    }
    final DataNode dn = dataNodes.get(dataNodeIndex).datanode;
    return DataNodeTestUtils.getFSDataset(dn).getBlockReports(bpid);
}

From source file:com.mellanox.r4h.MiniDFSCluster.java

/**
 * This method is valid only if the data nodes have simulated data
 * //from   www  .  j av a  2 s.  c o m
 * @param dataNodeIndex
 *            - data node i which to inject - the index is same as for getDataNodes()
 * @param blocksToInject
 *            - the blocks
 * @param bpid
 *            - (optional) the block pool id to use for injecting blocks.
 *            If not supplied then it is queried from the in-process NameNode.
 * @throws IOException
 *             if not simulatedFSDataset
 *             if any of blocks already exist in the data node
 * 
 */
public void injectBlocks(int dataNodeIndex, Iterable<Block> blocksToInject, String bpid) throws IOException {
    if (dataNodeIndex < 0 || dataNodeIndex > dataNodes.size()) {
        throw new IndexOutOfBoundsException();
    }
    final DataNode dn = dataNodes.get(dataNodeIndex).datanode;
    final FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);
    if (!(dataSet instanceof SimulatedFSDataset)) {
        throw new IOException("injectBlocks is valid only for SimilatedFSDataset");
    }
    if (bpid == null) {
        bpid = getNamesystem().getBlockPoolId();
    }
    SimulatedFSDataset sdataset = (SimulatedFSDataset) dataSet;
    sdataset.injectBlocks(bpid, blocksToInject);
    dataNodes.get(dataNodeIndex).datanode.scheduleAllBlockReport(0);
}

From source file:com.mellanox.r4h.MiniDFSCluster.java

/**
 * Multiple-NameNode version of {@link #injectBlocks(Iterable[])}.
 *//*w ww . j  a v  a 2  s .c  o  m*/
public void injectBlocks(int nameNodeIndex, int dataNodeIndex, Iterable<Block> blocksToInject)
        throws IOException {
    if (dataNodeIndex < 0 || dataNodeIndex > dataNodes.size()) {
        throw new IndexOutOfBoundsException();
    }
    final DataNode dn = dataNodes.get(dataNodeIndex).datanode;
    final FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);
    if (!(dataSet instanceof SimulatedFSDataset)) {
        throw new IOException("injectBlocks is valid only for SimilatedFSDataset");
    }
    String bpid = getNamesystem(nameNodeIndex).getBlockPoolId();
    SimulatedFSDataset sdataset = (SimulatedFSDataset) dataSet;
    sdataset.injectBlocks(bpid, blocksToInject);
    dataNodes.get(dataNodeIndex).datanode.scheduleAllBlockReport(0);
}

From source file:gedi.util.ArrayUtils.java

/**
 * Computes the rank-order statistic of a (that is, the rank smallest element starting from 0)
 * This partially sorts the array!/*from  ww w.j  a v a  2 s .  c  om*/
 * 
 * @param a
 * @param rank
 * @return
 */
public static double orderStatistic(double[] a, int rank) {
    if (a == null || a.length <= rank)
        throw new IndexOutOfBoundsException();

    int from = 0, to = a.length - 1;

    // if from == to we reached the kth element
    while (from < to) {
        int r = from, w = to;
        double mid = a[(r + w) / 2];

        // stop if the reader and writer meets
        while (r < w) {

            if (a[r] >= mid) { // put the large values at the end
                double tmp = a[w];
                a[w] = a[r];
                a[r] = tmp;
                w--;
            } else { // the value is smaller than the pivot, skip
                r++;
            }
        }

        // if we stepped up (r++) we need to step one down
        if (a[r] > mid)
            r--;

        // the r pointer is on the end of the first k elements
        if (rank <= r) {
            to = r;
        } else {
            from = r + 1;
        }
    }

    return a[rank];
}

From source file:gedi.util.ArrayUtils.java

/**
 * Computes the rank-order statistic of a (that is, the rank smallest element starting from 0)
 * This partially sorts the array!/*ww  w .  j  a  v a2 s  .c o m*/
 * 
 * @param a
 * @param rank
 * @return
 */
public static double orderStatistic(int[] a, int rank) {
    if (a == null || a.length <= rank)
        throw new IndexOutOfBoundsException();

    int from = 0, to = a.length - 1;

    // if from == to we reached the kth element
    while (from < to) {
        int r = from, w = to;
        int mid = a[(r + w) / 2];

        // stop if the reader and writer meets
        while (r < w) {

            if (a[r] >= mid) { // put the large values at the end
                int tmp = a[w];
                a[w] = a[r];
                a[r] = tmp;
                w--;
            } else { // the value is smaller than the pivot, skip
                r++;
            }
        }

        // if we stepped up (r++) we need to step one down
        if (a[r] > mid)
            r--;

        // the r pointer is on the end of the first k elements
        if (rank <= r) {
            to = r;
        } else {
            from = r + 1;
        }
    }

    return a[rank];
}