Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/org/labkey/targetedms/parser/AbstractChromInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.labkey.api.data.Container;
import org.labkey.api.exp.api.ExpData;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.util.Tuple3;
import org.labkey.api.util.UnexpectedException;
import org.labkey.targetedms.PanoramaBadDataException;
import org.labkey.targetedms.TargetedMSRun;
Expand Down Expand Up @@ -56,10 +55,12 @@ public abstract class AbstractChromInfo extends ChromInfo<PrecursorChromInfoAnno

private static final Logger LOG = LogManager.getLogger(AbstractChromInfo.class);

private static final BlockingCache<Tuple3<Path, Long, Integer>, CachedBytes> ON_DEMAND_CHROM_CACHE = new BlockingCache<>(CacheManager.getCache(100, CacheManager.HOUR, "SKYD chromatogram cache"), (key, argument) -> {
Path path = key.first;
long offset = key.second;
int length = key.third;
private record ChromKey(Path path, long offset, int length) {}

private static final BlockingCache<ChromKey, CachedBytes> ON_DEMAND_CHROM_CACHE = new BlockingCache<>(CacheManager.getCache(ChromKey.class, 100, CacheManager.HOUR, "SKYD chromatogram cache"), (key, argument) -> {
Path path = key.path();
long offset = key.offset();
int length = key.length();

long startTime = System.currentTimeMillis();
LOG.debug("Loading chromatogram from {}, offset {}, length {}", path, offset, length);
Expand Down Expand Up @@ -242,7 +243,7 @@ private CompressedBytesAndStatus getCompressedBytesAndStatus(TargetedMSRun run)
else
{
LOG.debug("Attempting to fetch chromatogram bytes (possibly cached) from {} for {}", skydPath, this);
CachedBytes diskBytes = ON_DEMAND_CHROM_CACHE.get(new Tuple3<>(skydPath, _chromatogramOffset, _chromatogramLength));
CachedBytes diskBytes = ON_DEMAND_CHROM_CACHE.get(new ChromKey(skydPath, _chromatogramOffset, _chromatogramLength));
if (diskBytes == null)
{
status = Chromatogram.SourceStatus.skydMissing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import java.util.List;
import java.util.zip.DataFormatException;

import static org.labkey.targetedms.parser.speclib.LibSpectrum.*;
import static org.labkey.targetedms.parser.speclib.LibSpectrum.SpectrumKey;

/**
* User: vsharma
Expand Down Expand Up @@ -172,14 +172,14 @@ private static String getLibCacheKey(@NotNull Container container, String pathSt
};

private static final BlockingCache<String, String> _libCache =
new BlockingCache<>(CacheManager.getStringKeyCache(LIBCACHE_LIMIT, LIBCACHE_LIFETIME,
new BlockingCache<>(CacheManager.getCache(String.class, LIBCACHE_LIMIT, LIBCACHE_LIFETIME,
"SpeclibCache"), _libCacheLoader)
{
@Override
public void remove(@NotNull String key)
public boolean remove(@NotNull String key)
{
deleteTempFile(key);
super.remove(key);
return super.remove(key);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/targetedms/query/ModificationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
public class ModificationManager
{
private static final int CACHE_SIZE = 10; // Cache results for up to 10 runs.
private static final Cache<String, Map<Long, Set<Pair<Integer, Integer>>>> PEPTIDE_STR_MOD_INDEXES = CacheManager.getCache(CACHE_SIZE, CacheManager.DAY, "Peptide structural modification indexes");
private static final Cache<String, Map<Pair<Long,Long>, Set<Integer>>> PEPTIDE_ISOTOPE_MOD_INDEXES = CacheManager.getCache(CACHE_SIZE, CacheManager.DAY, "Peptide isotope modification indexes");
private static final Cache<String, Map<Long, Set<Pair<Integer, Integer>>>> PEPTIDE_STR_MOD_INDEXES = CacheManager.getCache(String.class, CACHE_SIZE, CacheManager.DAY, "Peptide structural modification indexes");
private static final Cache<String, Map<Pair<Long,Long>, Set<Integer>>> PEPTIDE_ISOTOPE_MOD_INDEXES = CacheManager.getCache(String.class, CACHE_SIZE, CacheManager.DAY, "Peptide isotope modification indexes");

private ModificationManager() {}

Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/targetedms/query/PeptideManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class PeptideManager
{
private static final int CACHE_SIZE = 10;
private static final Cache<String, Set<Long>> PEPTIDE_IDS_WITH_SPECTRA = CacheManager.getCache(CACHE_SIZE, CacheManager.DAY, "Peptide IDs with library spectra");
private static final Cache<String, Set<Long>> PEPTIDE_IDS_WITH_SPECTRA = CacheManager.getCache(String.class, CACHE_SIZE, CacheManager.DAY, "Peptide IDs with library spectra");

private PeptideManager() {}

Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/targetedms/query/PrecursorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
public class PrecursorManager
{
private static final int CACHE_SIZE = 10; // Cache results for up to 10 runs.
private static final Cache<String, Set<Long>> PRECURSOR_IDS_WITH_CHROMATOGRAMS = CacheManager.getCache(CACHE_SIZE, CacheManager.DAY, "Precursors having chromatograms");
private static final Cache<String, Set<Long>> PRECURSOR_IDS_WITH_SPECTRA = CacheManager.getCache(CACHE_SIZE, CacheManager.DAY, "Precursors having library spectra");
private static final Cache<String, Set<Long>> PRECURSOR_IDS_WITH_CHROMATOGRAMS = CacheManager.getCache(String.class, CACHE_SIZE, CacheManager.DAY, "Precursors having chromatograms");
private static final Cache<String, Set<Long>> PRECURSOR_IDS_WITH_SPECTRA = CacheManager.getCache(String.class, CACHE_SIZE, CacheManager.DAY, "Precursors having library spectra");

private PrecursorManager() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static boolean isLargeSpectrumLibrary(Path libPath)
}

private static final BlockingCache<PrecursorKey, List<PeptideIdRtInfo>> _peptideIdRtsCache =
CacheManager.getBlockingCache(CACHE_SIZE, CacheManager.DAY, "TargetedMS peptide ID retention times",
CacheManager.getBlockingCache(PrecursorKey.class, CACHE_SIZE, CacheManager.DAY, "TargetedMS peptide ID retention times",
(precursor, argument) -> {
if (!(argument instanceof Container))
{
Expand Down
Loading