List of usage examples for java.lang OutOfMemoryError OutOfMemoryError
public OutOfMemoryError(String s)
From source file:org.eclipse.dataset.ShortDataset.java
protected static short[] createArray(final int size) { // PRIM_TYPE short[] array = null; // PRIM_TYPE try {/*from w ww.jav a2s .c o m*/ array = new short[size]; // PRIM_TYPE } catch (OutOfMemoryError e) { logger.error("The size of the dataset ({}) that is being created is too large " + "and there is not enough memory to hold it.", size); throw new OutOfMemoryError("The dimensions given are too large, and there is " + "not enough memory available in the Java Virtual Machine"); } return array; }
From source file:org.eclipse.january.dataset.DatasetUtils.java
/** * Copy and cast a dataset/* www. j a va 2 s . co m*/ * * @param d * The dataset to be copied * @param dtype dataset type * @return copied dataset of given type */ public static Dataset copy(final IDataset d, final int dtype) { Dataset a = convertToDataset(d); Dataset c = null; try { // copy across the data switch (dtype) { case Dataset.STRING: c = new StringDataset(a); break; case Dataset.BOOL: c = new BooleanDataset(a); break; case Dataset.INT8: if (a instanceof CompoundDataset) c = new CompoundByteDataset(a); else c = new ByteDataset(a); break; case Dataset.INT16: if (a instanceof CompoundDataset) c = new CompoundShortDataset(a); else c = new ShortDataset(a); break; case Dataset.INT32: if (a instanceof CompoundDataset) c = new CompoundIntegerDataset(a); else c = new IntegerDataset(a); break; case Dataset.INT64: if (a instanceof CompoundDataset) c = new CompoundLongDataset(a); else c = new LongDataset(a); break; case Dataset.ARRAYINT8: if (a instanceof CompoundDataset) c = new CompoundByteDataset((CompoundDataset) a); else c = new CompoundByteDataset(a); break; case Dataset.ARRAYINT16: if (a instanceof CompoundDataset) c = new CompoundShortDataset((CompoundDataset) a); else c = new CompoundShortDataset(a); break; case Dataset.ARRAYINT32: if (a instanceof CompoundDataset) c = new CompoundIntegerDataset((CompoundDataset) a); else c = new CompoundIntegerDataset(a); break; case Dataset.ARRAYINT64: if (a instanceof CompoundDataset) c = new CompoundLongDataset((CompoundDataset) a); else c = new CompoundLongDataset(a); break; case Dataset.FLOAT32: c = new FloatDataset(a); break; case Dataset.FLOAT64: c = new DoubleDataset(a); break; case Dataset.ARRAYFLOAT32: if (a instanceof CompoundDataset) c = new CompoundFloatDataset((CompoundDataset) a); else c = new CompoundFloatDataset(a); break; case Dataset.ARRAYFLOAT64: if (a instanceof CompoundDataset) c = new CompoundDoubleDataset((CompoundDataset) a); else c = new CompoundDoubleDataset(a); break; case Dataset.COMPLEX64: c = new ComplexFloatDataset(a); break; case Dataset.COMPLEX128: c = new ComplexDoubleDataset(a); break; case Dataset.RGB: if (a instanceof CompoundDataset) c = RGBDataset.createFromCompoundDataset((CompoundDataset) a); else c = new RGBDataset(a); break; default: utilsLogger.error("Dataset of unknown type!"); break; } } catch (OutOfMemoryError e) { utilsLogger.error("Not enough memory available to create dataset"); throw new OutOfMemoryError("Not enough memory available to create dataset"); } return c; }
From source file:org.eclipse.january.dataset.DatasetUtils.java
/** * Cast a dataset// w ww . ja v a 2 s .c om * * @param d * The dataset to be cast. * @param repeat repeat elements over item * @param dtype dataset type * @param isize item size */ public static Dataset cast(final IDataset d, final boolean repeat, final int dtype, final int isize) { Dataset a = convertToDataset(d); if (a.getDType() == dtype && a.getElementsPerItem() == isize) { return a; } if (isize <= 0) { utilsLogger.error("Item size is invalid (>0)"); throw new IllegalArgumentException("Item size is invalid (>0)"); } if (isize > 1 && dtype <= Dataset.FLOAT64) { utilsLogger.error("Item size is inconsistent with dataset type"); throw new IllegalArgumentException("Item size is inconsistent with dataset type"); } Dataset c = null; try { // copy across the data switch (dtype) { case Dataset.BOOL: c = new BooleanDataset(a); break; case Dataset.INT8: c = new ByteDataset(a); break; case Dataset.INT16: c = new ShortDataset(a); break; case Dataset.INT32: c = new IntegerDataset(a); break; case Dataset.INT64: c = new LongDataset(a); break; case Dataset.ARRAYINT8: c = new CompoundByteDataset(isize, repeat, a); break; case Dataset.ARRAYINT16: c = new CompoundShortDataset(isize, repeat, a); break; case Dataset.ARRAYINT32: c = new CompoundIntegerDataset(isize, repeat, a); break; case Dataset.ARRAYINT64: c = new CompoundLongDataset(isize, repeat, a); break; case Dataset.FLOAT32: c = new FloatDataset(a); break; case Dataset.FLOAT64: c = new DoubleDataset(a); break; case Dataset.ARRAYFLOAT32: c = new CompoundFloatDataset(isize, repeat, a); break; case Dataset.ARRAYFLOAT64: c = new CompoundDoubleDataset(isize, repeat, a); break; case Dataset.COMPLEX64: c = new ComplexFloatDataset(a); break; case Dataset.COMPLEX128: c = new ComplexDoubleDataset(a); break; default: utilsLogger.error("Dataset of unknown type!"); break; } } catch (OutOfMemoryError e) { utilsLogger.error("Not enough memory available to create dataset"); throw new OutOfMemoryError("Not enough memory available to create dataset"); } return c; }
From source file:org.springframework.batch.repeat.support.TaskExecutorRepeatTemplateBulkAsynchronousTests.java
@Test public void testErrorThrownByCallback() throws Exception { callback = new RepeatCallback() { private volatile AtomicInteger count = new AtomicInteger(0); @Override//w w w . j av a2s . c o m public RepeatStatus doInIteration(RepeatContext context) throws Exception { int position = count.incrementAndGet(); if (position == 4) { throw new OutOfMemoryError("Planned"); } else { return RepeatStatus.CONTINUABLE; } } }; template.setCompletionPolicy(new SimpleCompletionPolicy(10)); try { template.iterate(callback); fail("Expected planned exception"); } catch (OutOfMemoryError oome) { assertEquals("Planned", oome.getMessage()); } catch (Exception e) { e.printStackTrace(); fail("Wrong exception was thrown: " + e); } }
From source file:uk.ac.diamond.scisoft.analysis.dataset.AbstractDataset.java
@Override public AbstractDataset clone() { AbstractDataset c = null;// www.j ava 2 s . c om try { // copy across the data switch (getDtype()) { case BOOL: c = new BooleanDataset((BooleanDataset) this); break; case INT8: c = new ByteDataset((ByteDataset) this); break; case INT16: c = new ShortDataset((ShortDataset) this); break; case INT32: c = new IntegerDataset((IntegerDataset) this); break; case INT64: c = new LongDataset((LongDataset) this); break; case ARRAYINT8: c = new CompoundByteDataset((CompoundByteDataset) this); break; case ARRAYINT16: c = new CompoundShortDataset((CompoundShortDataset) this); break; case ARRAYINT32: c = new CompoundIntegerDataset((CompoundIntegerDataset) this); break; case ARRAYINT64: c = new CompoundLongDataset((CompoundLongDataset) this); break; case FLOAT32: c = new FloatDataset((FloatDataset) this); break; case FLOAT64: c = new DoubleDataset((DoubleDataset) this); break; case ARRAYFLOAT32: c = new CompoundFloatDataset((CompoundFloatDataset) this); break; case ARRAYFLOAT64: c = new CompoundDoubleDataset((CompoundDoubleDataset) this); break; case COMPLEX64: c = new ComplexFloatDataset((ComplexFloatDataset) this); break; case COMPLEX128: c = new ComplexDoubleDataset((ComplexDoubleDataset) this); break; default: abstractLogger.error("Dataset of unknown type!"); break; } } catch (OutOfMemoryError e) { throw new OutOfMemoryError("Not enough memory available to create dataset"); } return c; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.ByteDataset.java
private static byte[] createArray(final int size) { // PRIM_TYPE byte[] array = null; // PRIM_TYPE try {//from w w w. ja va 2s. c om array = new byte[size]; // PRIM_TYPE } catch (OutOfMemoryError e) { logger.error("The size of the dataset ({}) that is being created is too large " + "and there is not enough memory to hold it.", size); throw new OutOfMemoryError("The dimensions given are too large, and there is " + "not enough memory available in the Java Virtual Machine"); } return array; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.DoubleDataset.java
private static double[] createArray(final int size) { // PRIM_TYPE double[] array = null; // PRIM_TYPE try {/* w w w. j a v a 2 s.co m*/ array = new double[size]; // PRIM_TYPE } catch (OutOfMemoryError e) { logger.error("The size of the dataset ({}) that is being created is too large " + "and there is not enough memory to hold it.", size); throw new OutOfMemoryError("The dimensions given are too large, and there is " + "not enough memory available in the Java Virtual Machine"); } return array; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.FloatDataset.java
private static float[] createArray(final int size) { // PRIM_TYPE float[] array = null; // PRIM_TYPE try {/*from w w w .jav a2s .c o m*/ array = new float[size]; // PRIM_TYPE } catch (OutOfMemoryError e) { logger.error("The size of the dataset ({}) that is being created is too large " + "and there is not enough memory to hold it.", size); throw new OutOfMemoryError("The dimensions given are too large, and there is " + "not enough memory available in the Java Virtual Machine"); } return array; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.IntegerDataset.java
private static int[] createArray(final int size) { // PRIM_TYPE int[] array = null; // PRIM_TYPE try {//www. j a v a 2s. c om array = new int[size]; // PRIM_TYPE } catch (OutOfMemoryError e) { logger.error("The size of the dataset ({}) that is being created is too large " + "and there is not enough memory to hold it.", size); throw new OutOfMemoryError("The dimensions given are too large, and there is " + "not enough memory available in the Java Virtual Machine"); } return array; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.LongDataset.java
private static long[] createArray(final int size) { // PRIM_TYPE long[] array = null; // PRIM_TYPE try {// w ww .j a va 2 s . com array = new long[size]; // PRIM_TYPE } catch (OutOfMemoryError e) { logger.error("The size of the dataset ({}) that is being created is too large " + "and there is not enough memory to hold it.", size); throw new OutOfMemoryError("The dimensions given are too large, and there is " + "not enough memory available in the Java Virtual Machine"); } return array; }