Skip to content

Commit 8957ad3

Browse files
committed
Use correct method for list deserialization
1 parent 7396d6f commit 8957ad3

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

SequenceAnalysis/src/org/labkey/sequenceanalysis/pipeline/SequenceJobSupportImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.junit.Assert;
77
import org.junit.Test;
88
import org.labkey.api.collections.IntHashMap;
9+
import org.labkey.api.collections.LongArrayList;
910
import org.labkey.api.collections.LongHashMap;
1011
import org.labkey.api.exp.api.ExpData;
1112
import org.labkey.api.exp.api.ExperimentService;
@@ -28,6 +29,7 @@
2829
import java.io.StringReader;
2930
import java.io.StringWriter;
3031
import java.util.ArrayList;
32+
import java.util.Arrays;
3133
import java.util.Collection;
3234
import java.util.Collections;
3335
import java.util.HashMap;
@@ -319,6 +321,7 @@ public void testSerializeWithMap() throws Exception
319321
js1._cachedObjects.put("cachedInt", 1);
320322
js1._cachedObjects.put("cachedString", "foo");
321323
js1._cachedObjects.put("cachedLong", 2L);
324+
js1._cachedObjects.put("cachedListLong", new LongArrayList(Arrays.asList(1L, 2L)));
322325

323326
LongHashMap<Long> longMap = new LongHashMap<>();
324327
longMap.put(1L, 2L);
@@ -349,10 +352,15 @@ public void testSerializeWithMap() throws Exception
349352
assertEquals("Object not serialized with correct key type", Integer.class, serializedMap.keySet().iterator().next().getClass());
350353
assertNotNull("Map keys not serialized properly", serializedMap.get(1));
351354

352-
LongHashMap<Long> serializedLongMap = (LongHashMap<Long>)deserialized.getCachedObject("cachedLongMap", LongHashMap.class);
355+
LongHashMap<Long> serializedLongMap = deserialized.getCachedObject("cachedLongMap", LongHashMap.class);
353356
assertEquals("LongMap not serialized properly", 1, serializedLongMap.size());
354357
assertEquals("Object not serialized with correct key type", Long.class, serializedLongMap.keySet().iterator().next().getClass());
355358
assertNotNull("LongMap keys not serialized properly", serializedLongMap.get(1L));
359+
360+
List<Long> serializedListLong = deserialized.getCachedObject("cachedListLong", mapper.getTypeFactory().constructType(LongArrayList.class));
361+
assertEquals("List<Long> not serialized properly", 2, serializedListLong.size());
362+
assertNotNull("List<Long> values not serialized properly", serializedListLong.get(1));
363+
assertNotNull("List<Long> values not serialized properly", serializedListLong.get(2));
356364
}
357365

358366
@Test

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/variant/WhatsHapStep.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import htsjdk.variant.vcf.VCFHeader;
66
import org.apache.logging.log4j.Logger;
77
import org.jetbrains.annotations.Nullable;
8+
import org.labkey.api.collections.LongArrayList;
89
import org.labkey.api.data.Container;
910
import org.labkey.api.data.SimpleFilter;
1011
import org.labkey.api.data.TableInfo;
@@ -81,7 +82,7 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
8182
throw new IllegalStateException("No samples found in VCF file");
8283
}
8384

84-
ArrayList<Long> toCache = new ArrayList<>();
85+
ArrayList<Long> toCache = new LongArrayList();
8586
Container targetContainer = getPipelineCtx().getJob().getContainer().isWorkbookOrTab() ? getPipelineCtx().getJob().getContainer().getParent() : getPipelineCtx().getJob().getContainer();
8687
TableInfo outputFiles = QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_OUTPUTFILES);
8788
for (String sample : samples)
@@ -110,7 +111,7 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
110111

111112
private List<File> getCachedBams() throws PipelineJobException
112113
{
113-
List<Long> cachedFiles = getPipelineCtx().getSequenceSupport().getCachedObject(CACHE_KEY, PipelineJob.createObjectMapper().getTypeFactory().constructCollectionType(List.class, Long.class));
114+
List<Long> cachedFiles = getPipelineCtx().getSequenceSupport().getCachedObject(CACHE_KEY, PipelineJob.createObjectMapper().getTypeFactory().constructType(LongArrayList.class));
114115

115116
return cachedFiles.stream().map(x -> getPipelineCtx().getSequenceSupport().getCachedData(x)).toList();
116117
}

0 commit comments

Comments
 (0)