Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] memory limit checks #327

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public sealed interface TornadoCollectionInterface<T extends Buffer> //
permits VectorDouble, VectorDouble2, VectorDouble3, VectorDouble4, VectorDouble8, VectorDouble16, //
VectorFloat, VectorFloat2, VectorFloat3, VectorFloat4, VectorFloat8, VectorFloat16, //
VectorInt, VectorInt2, VectorInt3, VectorInt4, VectorInt8, VectorInt16 {
long getNumBytes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,9 @@ public int getLength() {
public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public final class VectorDouble16 implements TornadoCollectionInterface<DoubleBu
public static final Class<VectorDouble16> TYPE = VectorDouble16.class;

private static final int ELEMENT_SIZE = 16;

/**
* backing array.
*/
protected final DoubleArray storage;
private final DoubleArray storage;

/**
* number of elements in the storage.
*/
Expand All @@ -42,7 +44,7 @@ public final class VectorDouble16 implements TornadoCollectionInterface<DoubleBu
* @param numElements
* @param array
*/
protected VectorDouble16(int numElements, DoubleArray array) {
VectorDouble16(int numElements, DoubleArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -211,4 +213,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public final class VectorDouble2 implements TornadoCollectionInterface<DoubleBuf

public static final Class<VectorDouble2> TYPE = VectorDouble2.class;
private static final int ELEMENT_SIZE = 2;

/**
* backing array.
*/
protected final DoubleArray storage;
private final DoubleArray storage;

/**
* number of elements in the storage.
*/
Expand All @@ -43,7 +45,7 @@ public final class VectorDouble2 implements TornadoCollectionInterface<DoubleBuf
* @param numElements
* @param array
*/
protected VectorDouble2(int numElements, DoubleArray array) {
VectorDouble2(int numElements, DoubleArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -210,4 +212,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class VectorDouble3 implements TornadoCollectionInterface<DoubleBuf
/**
* backing array.
*/
protected final DoubleArray storage;
private final DoubleArray storage;
/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +44,7 @@ public final class VectorDouble3 implements TornadoCollectionInterface<DoubleBuf
* @param numElements
* @param array
*/
protected VectorDouble3(int numElements, DoubleArray array) {
VectorDouble3(int numElements, DoubleArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -213,4 +213,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public final class VectorDouble4 implements TornadoCollectionInterface<DoubleBuf
public static final Class<VectorDouble4> TYPE = VectorDouble4.class;

private static final int ELEMENT_SIZE = 4;

/**
* backing array.
*/
protected final DoubleArray storage;
private final DoubleArray storage;
/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +45,7 @@ public final class VectorDouble4 implements TornadoCollectionInterface<DoubleBuf
* @param numElements
* @param array
*/
protected VectorDouble4(int numElements, DoubleArray array) {
VectorDouble4(int numElements, DoubleArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -215,4 +216,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public final class VectorDouble8 implements TornadoCollectionInterface<DoubleBuf
public static final Class<VectorDouble8> TYPE = VectorDouble8.class;

private static final int ELEMENT_SIZE = 8;

/**
* backing array.
*/
protected final DoubleArray storage;
private final DoubleArray storage;
/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +45,7 @@ public final class VectorDouble8 implements TornadoCollectionInterface<DoubleBuf
* @param numElements
* @param array
*/
protected VectorDouble8(int numElements, DoubleArray array) {
VectorDouble8(int numElements, DoubleArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -213,4 +214,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,9 @@ public int getLength() {
public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public final class VectorFloat16 implements TornadoCollectionInterface<FloatBuff
public static final Class<VectorFloat16> TYPE = VectorFloat16.class;

private static final int ELEMENT_SIZE = 16;
protected final FloatArray storage;
private final FloatArray storage;
private final int numElements;

protected VectorFloat16(int numElements, FloatArray array) {
VectorFloat16(int numElements, FloatArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -159,4 +159,9 @@ public FloatArray getArray() {
public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class VectorFloat2 implements TornadoCollectionInterface<FloatBuffe
/**
* backing array.
*/
protected final FloatArray storage;
private final FloatArray storage;

/**
* number of elements in the storage.
Expand All @@ -45,7 +45,7 @@ public final class VectorFloat2 implements TornadoCollectionInterface<FloatBuffe
* @param numElements
* @param array
*/
protected VectorFloat2(int numElements, FloatArray array) {
VectorFloat2(int numElements, FloatArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -207,4 +207,9 @@ public FloatArray getArray() {
public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public final class VectorFloat3 implements TornadoCollectionInterface<FloatBuffe
public static final Class<VectorFloat3> TYPE = VectorFloat3.class;

private static final int ELEMENT_SIZE = 3;

/**
* backing array.
*/
protected final FloatArray storage;
private final FloatArray storage;

/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +46,7 @@ public final class VectorFloat3 implements TornadoCollectionInterface<FloatBuffe
* @param array
* array to be copied
*/
protected VectorFloat3(int numElements, FloatArray array) {
VectorFloat3(int numElements, FloatArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -215,4 +217,8 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,8 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class VectorFloat8 implements TornadoCollectionInterface<FloatBuffe
/**
* backing array.
*/
protected final FloatArray storage;
private final FloatArray storage;
/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +44,7 @@ public final class VectorFloat8 implements TornadoCollectionInterface<FloatBuffe
* @param numElements
* @param array
*/
protected VectorFloat8(int numElements, FloatArray array) {
VectorFloat8(int numElements, FloatArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -215,4 +215,9 @@ public FloatArray getArray() {
public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,9 @@ public int getLength() {
public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public final class VectorInt16 implements TornadoCollectionInterface<IntBuffer>
public static final Class<VectorInt16> TYPE = VectorInt16.class;

private static final int ELEMENT_SIZE = 16;

/**
* backing array.
*/
protected final IntArray storage;
private final IntArray storage;
/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +45,7 @@ public final class VectorInt16 implements TornadoCollectionInterface<IntBuffer>
* @param numElements
* @param array
*/
protected VectorInt16(int numElements, IntArray array) {
VectorInt16(int numElements, IntArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -210,4 +211,8 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class VectorInt2 implements TornadoCollectionInterface<IntBuffer> {
/**
* backing array.
*/
protected final IntArray storage;
private final IntArray storage;
/**
* number of elements in the storage.
*/
Expand All @@ -44,7 +44,7 @@ public final class VectorInt2 implements TornadoCollectionInterface<IntBuffer> {
* @param numElements
* @param array
*/
protected VectorInt2(int numElements, IntArray array) {
VectorInt2(int numElements, IntArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -208,4 +208,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class VectorInt3 implements TornadoCollectionInterface<IntBuffer> {
* @param numElements
* @param array
*/
protected VectorInt3(int numElements, IntArray array) {
VectorInt3(int numElements, IntArray array) {
this.numElements = numElements;
this.storage = array;
}
Expand Down Expand Up @@ -210,4 +210,9 @@ public void clear() {
storage.clear();
}

@Override
public long getNumBytes() {
return storage.getNumBytesOfSegment();
}

}
Loading