Skip to content

Commit 9d2960b

Browse files
Merge pull request #259 from LabKey/fb_long_is_the_new_int
2 parents ae5fb56 + 2fe8242 commit 9d2960b

File tree

12 files changed

+90
-70
lines changed

12 files changed

+90
-70
lines changed

GenotypeAssays/src/org/labkey/genotypeassays/GenotypeAssaysController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
130130
return null;
131131
}
132132

133-
Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, form.getAlleleNames());
133+
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, form.getAlleleNames());
134134
resultProperties.put("runsCreated", ret.first);
135135
resultProperties.put("runsDeleted", ret.second);
136136
}
@@ -209,7 +209,7 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
209209
return null;
210210
}
211211

212-
Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheHaplotypes(getViewContext(), protocol, new JSONArray(form.getJson()));
212+
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheHaplotypes(getViewContext(), protocol, new JSONArray(form.getJson()));
213213
resultProperties.put("runsCreated", ret.first);
214214
resultProperties.put("runsDeleted", ret.second);
215215
}

GenotypeAssays/src/org/labkey/genotypeassays/GenotypeAssaysManager.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.labkey.api.assay.AssayProvider;
2525
import org.labkey.api.assay.AssayService;
2626
import org.labkey.api.collections.CaseInsensitiveHashMap;
27+
import org.labkey.api.collections.IntHashMap;
28+
import org.labkey.api.collections.IntHashSet;
2729
import org.labkey.api.data.ColumnInfo;
2830
import org.labkey.api.data.CompareType;
2931
import org.labkey.api.data.Container;
@@ -88,11 +90,11 @@ public static GenotypeAssaysManager get()
8890
}
8991

9092

91-
public Pair<List<Integer>, List<Integer>> cacheAnalyses(final ViewContext ctx, final ExpProtocol protocol, String[] pks) throws IllegalArgumentException
93+
public Pair<List<Long>, List<Long>> cacheAnalyses(final ViewContext ctx, final ExpProtocol protocol, String[] pks) throws IllegalArgumentException
9294
{
9395
final User u = ctx.getUser();
94-
final List<Integer> runsCreated = new ArrayList<>();
95-
final List<Integer> runsDeleted = new ArrayList<>();
96+
final List<Long> runsCreated = new ArrayList<>();
97+
final List<Long> runsDeleted = new ArrayList<>();
9698

9799
try (DbScope.Transaction transaction = DbScope.getLabKeyScope().ensureTransaction())
98100
{
@@ -118,8 +120,8 @@ public Pair<List<Integer>, List<Integer>> cacheAnalyses(final ViewContext ctx, f
118120
AssayProtocolSchema schema = ap.createProtocolSchema(u, ctx.getContainer(), protocol, null);
119121
final TableInfo assayDataTable = schema.getTable(AssayProtocolSchema.DATA_TABLE_NAME);
120122

121-
final Map<Integer, List<Map<String, Object>>> rowHash = new HashMap<>();
122-
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new HashMap<>();
123+
final Map<Integer, List<Map<String, Object>>> rowHash = new IntHashMap<>();
124+
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new IntHashMap<>();
123125

124126
TableSelector tsAlignments = new TableSelector(tableAlignments, cols.values(), new SimpleFilter(FieldKey.fromString("key"), Arrays.asList(pks), CompareType.IN), null);
125127
tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
@@ -139,7 +141,7 @@ public void exec(ResultSet object) throws SQLException
139141
filter.addCondition(FieldKey.fromString("Run/assayType"), SBT_LINEAGE_ASSAY_TYPE);
140142

141143
TableSelector ts = new TableSelector(assayDataTable, PageFlowUtil.set("RowId"), filter, null);
142-
Set<Integer> existing = new HashSet<>(ts.getArrayList(Integer.class));
144+
Set<Integer> existing = new IntHashSet(ts.getArrayList(Integer.class));
143145
if (!existing.isEmpty())
144146
{
145147
Set<Integer> toDelete = toDeleteByAnalysis.containsKey(analysisId) ? toDeleteByAnalysis.get(analysisId) : new HashSet<Integer>();
@@ -178,11 +180,11 @@ public void exec(ResultSet object) throws SQLException
178180
}
179181
}
180182

181-
public Pair<List<Integer>, List<Integer>> cacheHaplotypes(final ViewContext ctx, final ExpProtocol protocol, JSONArray data) throws IllegalArgumentException
183+
public Pair<List<Long>, List<Long>> cacheHaplotypes(final ViewContext ctx, final ExpProtocol protocol, JSONArray data) throws IllegalArgumentException
182184
{
183185
final User u = ctx.getUser();
184-
final List<Integer> runsCreated = new ArrayList<>();
185-
final List<Integer> runsDeleted = new ArrayList<>();
186+
final List<Long> runsCreated = new ArrayList<>();
187+
final List<Long> runsDeleted = new ArrayList<>();
186188

187189
//next identify a build up the results
188190
TableInfo tableAnalyses = QueryService.get().getUserSchema(u, ctx.getContainer(), SEQUENCEANALYSIS_SCHEMA).getTable("sequence_analyses");
@@ -196,8 +198,8 @@ public Pair<List<Integer>, List<Integer>> cacheHaplotypes(final ViewContext ctx,
196198
fieldKeys.add(FieldKey.fromString("readset/subjectid"));
197199
fieldKeys.add(FieldKey.fromString("readset/sampledate"));
198200

199-
Set<Integer> analysisIds = new HashSet<>();
200-
final Map<Integer, List<JSONObject>> haploMap = new HashMap<>();
201+
Set<Integer> analysisIds = new IntHashSet();
202+
final Map<Integer, List<JSONObject>> haploMap = new IntHashMap<>();
201203
for (JSONObject row : JsonUtil.toJSONObjectList(data))
202204
{
203205
Integer analysisId = row.getInt("analysisId");
@@ -217,8 +219,8 @@ public Pair<List<Integer>, List<Integer>> cacheHaplotypes(final ViewContext ctx,
217219
AssayProtocolSchema schema = ap.createProtocolSchema(u, ctx.getContainer(), protocol, null);
218220
final TableInfo assayDataTable = schema.getTable(AssayProtocolSchema.DATA_TABLE_NAME);
219221

220-
final Map<Integer, List<Map<String, Object>>> rowHash = new HashMap<>();
221-
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new HashMap<>();
222+
final Map<Integer, List<Map<String, Object>>> rowHash = new IntHashMap<>();
223+
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new IntHashMap<>();
222224

223225
TableSelector tsAlignments = new TableSelector(tableAnalyses, cols.values(), new SimpleFilter(FieldKey.fromString("rowid"), analysisIds, CompareType.IN), null);
224226
tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
@@ -244,10 +246,10 @@ public void exec(ResultSet object) throws SQLException
244246
filter.addCondition(FieldKey.fromString("Run/assayType"), HAPLOTYPE_ASSAY_TYPE);
245247

246248
TableSelector ts = new TableSelector(assayDataTable, PageFlowUtil.set("RowId"), filter, null);
247-
Set<Integer> existing = new HashSet<>(ts.getArrayList(Integer.class));
249+
Set<Integer> existing = new IntHashSet(ts.getArrayList(Integer.class));
248250
if (!existing.isEmpty())
249251
{
250-
Set<Integer> toDelete = toDeleteByAnalysis.containsKey(analysisId) ? toDeleteByAnalysis.get(analysisId) : new HashSet<>();
252+
Set<Integer> toDelete = toDeleteByAnalysis.containsKey(analysisId) ? toDeleteByAnalysis.get(analysisId) : new IntHashSet();
251253
toDelete.addAll(existing);
252254
toDeleteByAnalysis.put(analysisId, toDelete);
253255
}
@@ -288,7 +290,7 @@ public void exec(ResultSet object) throws SQLException
288290
return Pair.of(runsCreated, runsDeleted);
289291
}
290292

291-
private void processSet(String assayType, Map<Integer, List<Map<String, Object>>> rowHash, TableInfo assayDataTable, User u, ViewContext ctx, Map<Integer, Set<Integer>> toDeleteByAnalysis, AssayProvider ap, ExpProtocol protocol, List<Integer> runsCreated)
293+
private void processSet(String assayType, Map<Integer, List<Map<String, Object>>> rowHash, TableInfo assayDataTable, User u, ViewContext ctx, Map<Integer, Set<Integer>> toDeleteByAnalysis, AssayProvider ap, ExpProtocol protocol, List<Long> runsCreated)
292294
{
293295
for (Integer analysisId : rowHash.keySet())
294296
{

elispot_assay/src/org/labkey/elispot_assay/assay/DefaultImportMethod.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.util.List;
3333
import java.util.Map;
3434

35+
import static org.labkey.api.exp.api.ExperimentService.asInteger;
36+
3537
/**
3638
* Created with IntelliJ IDEA.
3739
* User: bimber
@@ -134,7 +136,7 @@ protected List<Map<String, Object>> calculatePositivity(List<Map<String, Object>
134136

135137
if (TYPE.NEG.getText().equals(row.get(CATEGORY_FIELD)))
136138
{
137-
Integer spots = (Integer)row.get(SPOTS_FIELD);
139+
Integer spots = asInteger(row.get(SPOTS_FIELD));
138140
List<Double> negCtls = negWellMap.get(negCtlKey);
139141
if (negCtls == null)
140142
negCtls = new ArrayList<Double>();
@@ -188,8 +190,8 @@ protected List<Map<String, Object>> calculatePositivity(List<Map<String, Object>
188190
int rowIdx = 0;
189191
for (Map<String, Object> row : rowSet)
190192
{
191-
totalSpots += (Integer)row.get(SPOTS_FIELD);
192-
allSpots[rowIdx] = (Integer)row.get(SPOTS_FIELD);
193+
totalSpots += asInteger(row.get(SPOTS_FIELD));
194+
allSpots[rowIdx] = asInteger(row.get(SPOTS_FIELD));
193195
rowIdx++;
194196
}
195197
Double avgSpots = totalSpots / rowSet.size();
@@ -262,7 +264,7 @@ protected List<Map<String, Object>> calculatePositivity(List<Map<String, Object>
262264
row.put(QCFLAG_FIELD, StringUtils.join(qcflags, "\n"));
263265

264266
//subtract background
265-
Integer spots = (Integer)row.get(SPOTS_FIELD);
267+
Integer spots = asInteger(row.get(SPOTS_FIELD));
266268
Double adj = spots - negCtlSummary.getMean();
267269
List<String> comments = new ArrayList<String>();
268270
if (row.get("comment") != null)

mGAP/src/org/labkey/mgap/mGAPController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
import java.util.zip.ZipEntry;
123123
import java.util.zip.ZipOutputStream;
124124

125+
import static org.labkey.api.exp.api.ExperimentService.asInteger;
126+
125127

126128
public class mGAPController extends SpringActionController
127129
{
@@ -413,7 +415,7 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws
413415
User u;
414416
if (map.get("userId") != null)
415417
{
416-
Integer userId = (Integer) map.get("userId");
418+
Integer userId = asInteger(map.get("userId"));
417419
u = UserManager.getUser(userId);
418420
existingUsersGivenAccess.add(u);
419421
}
@@ -556,7 +558,7 @@ else if (!rowContainer.hasPermission(u, ReadPermission.class))
556558

557559
private static SequenceOutputFile getOutputFile(Map<String, Object> row, ReleaseForm form, Errors errors)
558560
{
559-
SequenceOutputFile so = SequenceOutputFile.getForId((Integer) row.get("vcfId"));
561+
SequenceOutputFile so = SequenceOutputFile.getForId(asInteger(row.get("vcfId")));
560562
if (so == null)
561563
{
562564
errors.reject(ERROR_MSG, "Unknown VCF file ID: " + form.getReleaseId());

mcc/src/org/labkey/mcc/MccController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
import java.util.stream.Collectors;
105105
import java.util.stream.IntStream;
106106

107+
import static org.labkey.api.exp.api.ExperimentService.asInteger;
108+
107109
public class MccController extends SpringActionController
108110
{
109111
private static final DefaultActionResolver _actionResolver = new DefaultActionResolver(MccController.class);
@@ -356,7 +358,7 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws
356358
User u;
357359
if (map.get("userId") != null)
358360
{
359-
Integer userId = (Integer)map.get("userId");
361+
Integer userId = asInteger(map.get("userId"));
360362
u = UserManager.getUser(userId);
361363
existingUsersGivenAccess.add(u);
362364
}

mcc/src/org/labkey/mcc/query/TriggerHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import java.util.concurrent.atomic.AtomicInteger;
5050
import java.util.stream.Collectors;
5151

52+
import static org.labkey.api.exp.api.ExperimentService.asInteger;
53+
5254
/**
5355
* Created by bimber
5456
*/
@@ -135,7 +137,7 @@ public void ensureReviewRecordsCreated(String objectId, String status, @Nullable
135137
}
136138

137139
Map<String, Object> row = records.get(0);
138-
if (score != (Integer)row.get("preliminaryScore"))
140+
if (score != asInteger(row.get("preliminaryScore")))
139141
{
140142
row.put("preliminaryScore", score);
141143
row.put("modified", new Date());

primeseq/src/org/labkey/primeseq/analysis/MethylationRateComparisonHandler.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import org.jetbrains.annotations.Nullable;
1616
import org.json.JSONArray;
1717
import org.json.JSONObject;
18+
import org.labkey.api.collections.IntHashMap;
19+
import org.labkey.api.collections.StringHashMap;
1820
import org.labkey.api.data.Container;
1921
import org.labkey.api.jbrowse.JBrowseService;
2022
import org.labkey.api.module.Module;
@@ -49,7 +51,6 @@
4951
import java.util.ArrayList;
5052
import java.util.Arrays;
5153
import java.util.Date;
52-
import java.util.HashMap;
5354
import java.util.LinkedHashSet;
5455
import java.util.List;
5556
import java.util.Map;
@@ -188,7 +189,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
188189
ctx.getLogger().info(groupNames.getString(i));
189190
}
190191

191-
Map<Integer, Integer> fileToGroupMap = new HashMap<>();
192+
Map<Integer, Integer> fileToGroupMap = new IntHashMap<>();
192193
JSONObject map = ctx.getParams().getJSONObject("fileToGroupMap");
193194
for (String id : map.keySet())
194195
{
@@ -201,7 +202,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
201202
String statisticalMethod = ctx.getParams().optString("statisticalMethod");
202203

203204
//build map of site rates
204-
Map<String, Map<Integer, Map<Integer, List<Double>>>> rateMap = new HashMap<>();
205+
Map<String, Map<Integer, Map<Integer, List<Double>>>> rateMap = new StringHashMap<>();
205206

206207
int i = 0;
207208
for (SequenceOutputFile o : inputFiles)
@@ -268,12 +269,12 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
268269

269270
if (!rateMap.containsKey(chr))
270271
{
271-
rateMap.put(chr, new HashMap<>());
272+
rateMap.put(chr, new IntHashMap<>());
272273
}
273274

274275
if (!rateMap.get(chr).containsKey(pos))
275276
{
276-
rateMap.get(chr).put(pos, new HashMap<>());
277+
rateMap.get(chr).put(pos, new IntHashMap<>());
277278
}
278279

279280
if (!rateMap.get(chr).get(pos).containsKey(groupNum))

primeseq/src/org/labkey/primeseq/pipeline/BismarkWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ else if (getProvider().getParameterByName("siteReport") != null && getProvider()
511511
@Override
512512
public Output performAnalysisPerSampleLocal(AnalysisModel model, File inputBam, File referenceFasta, File outDir) throws PipelineJobException
513513
{
514-
Integer runId = SequenceAnalysisService.get().getExpRunIdForJob(getPipelineCtx().getJob(), true);
514+
Long runId = SequenceAnalysisService.get().getExpRunIdForJob(getPipelineCtx().getJob(), true);
515515

516516
Set<SequenceOutputFile> toCreate = new HashSet<>();
517517
SequenceOutputTracker sot = ((SequenceOutputTracker)getPipelineCtx().getJob());

0 commit comments

Comments
 (0)