Skip to content

Commit fb62788

Browse files
authored
Merge pull request #583 from saalfeldlab/1.13.6
fix: revert EMPTY_ACCESS special case, it has some bugs that need to …
2 parents 0dcec97 + 3d9ff12 commit fb62788

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/main/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ private static VolatileLabelMultisetArray downsampleVolatileLabelMultisetArrayAn
409409
maxNumEntries
410410
);
411411

412-
if (updatedAccess.isValid() && updatedAccess.getCurrentStorageArray().length == 0) {
412+
boolean currentEmptyBehavior = updatedAccess.getArrayLength() == 0;
413+
if (updatedAccess.isValid() && currentEmptyBehavior) {
413414
n5.deleteBlock(dataset, blockPosition);
414415
return null;
415416
}

src/main/java/org/janelia/saalfeldlab/paintera/ui/dialogs/open/VolatileHelpers.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import net.imglib2.img.cell.CellGrid;
66
import net.imglib2.type.label.Label;
77
import net.imglib2.type.label.VolatileLabelMultisetArray;
8+
import net.imglib2.util.Intervals;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
1011

1112
import java.lang.invoke.MethodHandles;
13+
import java.util.Arrays;
1214

1315
public class VolatileHelpers {
1416

@@ -34,10 +36,15 @@ public Cell<VolatileLabelMultisetArray> createInvalid(final Long key) throws Exc
3436
final int[] cellDims = new int[cellPosition.length];
3537
grid.getCellDimensions(cellPosition, cellMin, cellDims);
3638

37-
return new Cell<>(cellDims, cellMin, EMPTY_ACCESS);
39+
return new Cell<>(cellDims, cellMin, newEmptyAccess((int)Intervals.numElements(cellDims), false));
3840
}
3941
}
4042

41-
private static final VolatileLabelMultisetArray EMPTY_ACCESS = new VolatileLabelMultisetArray(0, false, new long[]{Label.INVALID});
43+
public static VolatileLabelMultisetArray newEmptyAccess(int numElements, boolean isValid) {
44+
45+
long[] argMaxes = new long[numElements];
46+
Arrays.fill(argMaxes, Label.INVALID);
47+
return new VolatileLabelMultisetArray(numElements, isValid, argMaxes);
48+
}
4249

4350
}

src/main/kotlin/org/janelia/saalfeldlab/paintera/data/n5/LabelMultisetUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.janelia.saalfeldlab.n5.DatasetAttributes
1414
import org.janelia.saalfeldlab.n5.N5Exception
1515
import org.janelia.saalfeldlab.n5.N5Reader
1616
import org.janelia.saalfeldlab.n5.imglib2.N5LabelMultisets
17+
import org.janelia.saalfeldlab.paintera.ui.dialogs.open.VolatileHelpers
1718
import java.nio.ByteBuffer
1819
import java.util.function.BiFunction
1920

@@ -141,12 +142,11 @@ class LabelMultisetCacheLoader(private val n5: N5Reader, private val dataset: St
141142
val n = Intervals.numElements(*cellSize).toInt()
142143
val access = bytes
143144
?.let { LabelUtils.fromBytes(bytes, n) }
144-
?: EMPTY_ACCESS
145+
?: VolatileHelpers.newEmptyAccess(n, true)
145146
return Cell(cellSize, cellMin, access)
146147
}
147148

148149
companion object {
149-
private val EMPTY_ACCESS = VolatileLabelMultisetArray(0, false, longArrayOf(Label.INVALID))
150150

151151
private fun generateCellGrid(n5: N5Reader, dataset: String): CellGrid {
152152
val attributes = n5.getDatasetAttributes(dataset)

0 commit comments

Comments
 (0)