@@ -314,7 +314,7 @@ protected static ConcurrentMap<Class<? extends MetadataType>, List<MetadataType>
314
314
315
315
/**
316
316
* Copy metadata. If oMetadata is not null, then copy from that when it has the corresponding items
317
- * @since 2.1.2
317
+ * @since 2.1
318
318
* @param metadata
319
319
* @param oMetadata can be null
320
320
* @return
@@ -378,18 +378,14 @@ interface MetadatasetAnnotationOperation {
378
378
379
379
class MdsSlice implements MetadatasetAnnotationOperation {
380
380
private boolean asView ;
381
- private int [] start ;
382
- private int [] stop ;
383
- private int [] step ;
381
+ private SliceND slice ;
384
382
private int [] oShape ;
385
383
private long oSize ;
386
384
387
- public MdsSlice (boolean asView , final int [] start , final int [] stop , final int [] step , final int [] oShape ) {
385
+ public MdsSlice (boolean asView , SliceND slice ) {
388
386
this .asView = asView ;
389
- this .start = start ;
390
- this .stop = stop ;
391
- this .step = step ;
392
- this .oShape = oShape ;
387
+ this .slice = slice ;
388
+ oShape = slice .getSourceShape ();
393
389
oSize = ShapeUtils .calcLongSize (oShape );
394
390
}
395
391
@@ -416,38 +412,30 @@ public int getNewRank() {
416
412
@ Override
417
413
public ILazyDataset run (ILazyDataset lz ) {
418
414
int rank = lz .getRank ();
419
- if (start .length != rank ) {
415
+ if (slice . getStart () .length != rank ) {
420
416
throw new IllegalArgumentException ("Slice dimensions do not match dataset!" );
421
417
}
422
418
423
419
int [] shape = lz .getShape ();
424
- int [] stt ;
425
- int [] stp ;
426
- int [] ste ;
420
+ SliceND nslice ;
427
421
if (lz .getSize () == oSize ) {
428
- stt = start ;
429
- stp = stop ;
430
- ste = step ;
422
+ nslice = slice ;
431
423
} else {
432
- stt = start .clone ();
433
- stp = stop .clone ();
434
- ste = step .clone ();
424
+ nslice = slice .clone ();
435
425
for (int i = 0 ; i < rank ; i ++) {
436
426
if (shape [i ] >= oShape [i ]) continue ;
437
427
if (shape [i ] == 1 ) {
438
- stt [i ] = 0 ;
439
- stp [i ] = 1 ;
440
- ste [i ] = 1 ;
428
+ nslice .setSlice (i , 0 , 1 , 1 );
441
429
} else {
442
430
throw new IllegalArgumentException ("Sliceable dataset has invalid size!" );
443
431
}
444
432
}
445
433
}
446
434
447
435
if (asView || (lz instanceof IDataset ))
448
- return lz .getSliceView (stt , stp , ste );
436
+ return lz .getSliceView (nslice );
449
437
try {
450
- return lz .getSlice (stt , stp , ste );
438
+ return lz .getSlice (nslice );
451
439
} catch (DatasetException e ) {
452
440
logger .error ("Could not slice dataset in metadata" , e );
453
441
return null ;
@@ -780,7 +768,7 @@ public ILazyDataset run(ILazyDataset lz) {
780
768
* @param slice
781
769
*/
782
770
protected void sliceMetadata (boolean asView , final SliceND slice ) {
783
- processAnnotatedMetadata (new MdsSlice (asView , slice . getStart (), slice . getStop (), slice . getStep (), slice . getSourceShape () ), true );
771
+ processAnnotatedMetadata (new MdsSlice (asView , slice ), true );
784
772
}
785
773
786
774
/**
0 commit comments