Skip to content

Commit

Permalink
correct tricky bug caused by discrete shared memory pages in mac and win
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 20, 2024
1 parent 734583d commit 45a1a14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -897,12 +897,15 @@ public ByteBuffer getDataBuffer() {
*/
public ByteBuffer getDataBufferNoHeader() {
int offset = 0;
long totSize = this.size;
for (long l : this.originalDims)
totSize *= l;
if (this.isNumpyFormat()) {
long flatSize = 1;
for (long l : this.originalDims) flatSize *= l;
offset = (int) (this.size - DecodeNumpy.DATA_TYPES_MAP.get(this.originalDataType) * flatSize);
long npSize = DecodeNumpy.calculateNpyStyleByteArrayLength(originalDims, Cast.unchecked(CommonUtils.getImgLib2DataType(originalDataType)), this.isFortran);
offset = (int) (npSize - DecodeNumpy.DATA_TYPES_MAP.get(this.originalDataType) * totSize);
totSize = npSize;
}
return pSharedMemory.getByteBuffer(offset, this.size - offset);
return pSharedMemory.getByteBuffer(offset, totSize - offset);
}

private static <T extends RealType<T> & NativeType<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,15 @@ public ByteBuffer getDataBuffer() {
*/
public ByteBuffer getDataBufferNoHeader() {
int offset = 0;
long totSize = this.size;
for (long l : this.originalDims)
totSize *= l;
if (this.isNumpyFormat()) {
long flatSize = 1;
for (long l : this.originalDims) flatSize *= l;
offset = (int) (this.size - DecodeNumpy.DATA_TYPES_MAP.get(this.originalDataType) * flatSize);
long npSize = DecodeNumpy.calculateNpyStyleByteArrayLength(originalDims, Cast.unchecked(CommonUtils.getImgLib2DataType(originalDataType)), this.isFortran);
offset = (int) (npSize - DecodeNumpy.DATA_TYPES_MAP.get(this.originalDataType) * totSize);
totSize = npSize;
}
return pSharedMemory.getByteBuffer(offset, this.size - offset);
return pSharedMemory.getByteBuffer(offset, totSize - offset);
}

private static <T extends RealType<T> & NativeType<T>>
Expand Down

0 comments on commit 45a1a14

Please sign in to comment.