Java 类com.intellij.util.containers.SLRUMap 实例源码

项目:tools-idea    文件:PersistentStringEnumerator.java   
private PersistentStringEnumerator(@NotNull final File file,
                                   final int initialSize,
                                   boolean cacheLastMappings,
                                   @Nullable PagedFileStorage.StorageLockContext lockContext) throws IOException {
  super(file, new EnumeratorStringDescriptor(), initialSize, lockContext);
  if (cacheLastMappings) {
    myIdToStringCache = new SLRUMap[STRIPE_COUNT];
    myHashcodeToIdCache = new SLRUMap[STRIPE_COUNT];
    myStripeLocks = new Lock[STRIPE_COUNT];
    int protectedSize = 8192;
    int probationalSize = 8192;

    for(int i = 0; i < STRIPE_COUNT; ++i) {
      myHashcodeToIdCache[i] = new SLRUMap<Integer, Integer>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT);
      myIdToStringCache[i] = new SLRUMap<Integer, String>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT);
      myStripeLocks[i] = new SequenceLock();
    }
  } else {
    myIdToStringCache = null;
    myHashcodeToIdCache = null;
    myStripeLocks = null;
  }
}
项目:intellij-ce-playground    文件:ContainingBranchesGetter.java   
public Task(VirtualFile root,
            Hash hash,
            SLRUMap<Hash, List<String>> cache,
            @Nullable PermanentGraph<Integer> graph,
            @Nullable VcsLogRefs refs) {
  this.root = root;
  this.hash = hash;
  this.cache = cache;
  this.graph = graph;
  this.refs = refs;
}
项目:intellij-ce-playground    文件:CachingEnumerator.java   
public CachingEnumerator(DataEnumerator<Data> base, KeyDescriptor<Data> dataDescriptor) {
  myBase = base;
  myDataDescriptor = dataDescriptor;
  int protectedSize = 8192;
  int probationalSize = 8192;

  for(int i = 0; i < STRIPE_COUNT; ++i) {
    myHashcodeToIdCache[i] = new SLRUMap<Integer, Integer>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT);
    myIdToStringCache[i] = new SLRUMap<Integer, Data>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT);
    myStripeLocks[i] = new SequenceLock();
  }

}
项目:intellij-ce-playground    文件:ContentRevisionCache.java   
public ContentRevisionCache() {
  myLock = new Object();
  myCache = new SLRUMap<Key, SoftReference<byte[]>>(100, 50);
  myCurrentRevisionsCache = new SLRUMap<CurrentKey, VcsRevisionNumber>(200, 50);
  myCustom = new SLRUMap<Pair<FilePath, VcsRevisionNumber>, Object>(30,30);
  myCounter = 0;
}
项目:intellij-ce-playground    文件:ShortDiffDetails.java   
public ShortDiffDetails(Project project, Getter<Change[]> master, final VcsChangeDetailsManager vcsChangeDetailsManager) {
  myMaster = master;
  myProject = project;
  myVcsChangeDetailsManager = vcsChangeDetailsManager;

  myDetailsCache = new SLRUMap<FilePath, RefreshablePanel>(10, 10) {
    @Override
    protected void onDropFromCache(FilePath key, RefreshablePanel value) {
      if (value != null) {
        Disposer.dispose(value);
      }
    }
  };
}
项目:tools-idea    文件:CachedPersistentHashMap.java   
public CachedPersistentHashMap(File file, KeyDescriptor<Key> keyDescriptor, DataExternalizer<Value> valDescriptor, final int cacheSize) throws IOException {
  super(file, keyDescriptor, valDescriptor);
  myCache = new SLRUMap<Key,Value>(cacheSize * 2, cacheSize) {
    protected void onDropFromCache(Key key, Value value) {
      if (isValueDirty(value)) {
        try {
          CachedPersistentHashMap.super.put(key, value);
        }
        catch (IOException e) {
          LOG.info(e);
        }
      }
    }
  };
}
项目:tools-idea    文件:ContentRevisionCache.java   
public ContentRevisionCache() {
  myLock = new Object();
  myCache = new SLRUMap<Key, SoftReference<byte[]>>(100, 50);
  myCurrentRevisionsCache = new SLRUMap<CurrentKey, VcsRevisionNumber>(200, 50);
  myCustom = new SLRUMap<Pair<FilePath, VcsRevisionNumber>, Object>(30,30);
  myCounter = 0;
}
项目:tools-idea    文件:ShortDiffDetails.java   
public ShortDiffDetails(Project project, Getter<Change[]> master, final VcsChangeDetailsManager vcsChangeDetailsManager) {
  myMaster = master;
  myProject = project;
  myVcsChangeDetailsManager = vcsChangeDetailsManager;

  myDetailsCache = new SLRUMap<FilePath, RefreshablePanel>(10, 10) {
    @Override
    protected void onDropFromCache(FilePath key, RefreshablePanel value) {
      if (value != null) {
        Disposer.dispose(value);
      }
    }
  };
}
项目:tools-idea    文件:DetailsCache.java   
public DetailsCache(final Project project,
                    final UIRefresh uiRefresh,
                    final DetailsLoaderImpl detailsLoader,
                    final BackgroundTaskQueue queue) {
  myProject = project;
  myDetailsLoader = detailsLoader;
  myQueue = queue;
  myStash = new HashMap<VirtualFile, Map<AbstractHash,String>>();
  myRefresh = uiRefresh;
  myLock = new Object();
  myCache = new SLRUMap<Pair<VirtualFile, AbstractHash>, GitHeavyCommit>(ourSize, 150);
  myBranches = new SLRUMap<Pair<VirtualFile, AbstractHash>, List<String>>(20, 20);
}
项目:tools-idea    文件:GitCommitsSequentialIndex.java   
public GitCommitsSequentialIndex() {
  myLock = new Object();
  final File vcsFile = new File(PathManager.getSystemPath(), "vcs");
  myDir = new File(vcsFile, "git_line");
  myDir.mkdirs();
  // will contain list of roots mapped to
  myListFile = new File(myDir, "repository_index");
  myCache = new SLRUMap<Pair<Long, VirtualFile>, List<Pair<AbstractHash, Long>>>(10,10);
  myPacks = new SLRUMap<VirtualFile, List<Long>>(10,10);
}
项目:consulo    文件:ContainingBranchesGetter.java   
public Task(VirtualFile root,
            Hash hash,
            SLRUMap<CommitId, List<String>> cache,
            @Nullable PermanentGraph<Integer> graph,
            @Nullable RefsModel refs) {
  this.root = root;
  this.hash = hash;
  this.cache = cache;
  this.graph = graph;
  this.refs = refs;
}
项目:consulo    文件:CachingEnumerator.java   
public CachingEnumerator(DataEnumerator<Data> base, KeyDescriptor<Data> dataDescriptor) {
  myBase = base;
  myDataDescriptor = dataDescriptor;
  int protectedSize = 8192;
  int probationalSize = 8192;

  for(int i = 0; i < STRIPE_COUNT; ++i) {
    myHashcodeToIdCache[i] = new SLRUMap<Integer, Integer>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT);
    myIdToStringCache[i] = new SLRUMap<Integer, Data>(protectedSize / STRIPE_COUNT, probationalSize / STRIPE_COUNT);
    myStripeLocks[i] = new ReentrantLock();
  }

}
项目:consulo    文件:FileAccessorCache.java   
public FileAccessorCache(int protectedQueueSize, int probationalQueueSize) {
  myCache = new SLRUMap<K, Handle<T>>(protectedQueueSize, probationalQueueSize, this) {
    @Override
    protected final void onDropFromCache(K key, Handle<T> value) {
      value.release();
    }
  };
}
项目:consulo    文件:ContentRevisionCache.java   
public ContentRevisionCache() {
  myLock = new Object();
  myCache = new SLRUMap<>(100, 50);
  myCurrentRevisionsCache = new SLRUMap<>(200, 50);
  myCustom = new SLRUMap<>(30, 30);
  myCounter = 0;
}
项目:consulo-java    文件:CachedPersistentHashMap.java   
public CachedPersistentHashMap(File file, KeyDescriptor<Key> keyDescriptor, DataExternalizer<Value> valDescriptor, final int cacheSize) throws IOException {
  super(file, keyDescriptor, valDescriptor);
  myCache = new SLRUMap<Key,Value>(cacheSize * 2, cacheSize) {
    protected void onDropFromCache(Key key, Value value) {
      if (isValueDirty(value)) {
        try {
          CachedPersistentHashMap.super.put(key, value);
        }
        catch (IOException e) {
          LOG.info(e);
        }
      }
    }
  };
}
项目:intellij-ce-playground    文件:SoftHardCacheMap.java   
public SoftHardCacheMap(final int protectedQueueSize, final int probationalQueueSize) {
  mySLRUMap = new SLRUMap<K, V>(protectedQueueSize, probationalQueueSize);
  mySoftLinkMap = new SoftValueHashMap<K, V>();
}
项目:intellij-ce-playground    文件:ContainingBranchesGetter.java   
@NotNull
private static SLRUMap<Hash, List<String>> createCache() {
  return new SLRUMap<Hash, List<String>>(1000, 1000);
}
项目:intellij-ce-playground    文件:RareLogger.java   
private RareLogger(final Logger logger, final boolean fairSynch) {
  myLogger = logger;

  final Object lock = new Object();
  myCache = new SLRUMap<Object, Long>(64, 32) {
    @Override
    public Long get(Object key) {
      if (fairSynch) {
        synchronized (lock) {
          return super.get(key);
        }
      }
      return super.get(key);
    }

    @Override
    public void put(Object key, @NotNull Long value) {
      if (fairSynch) {
        synchronized (lock) {
          super.put(key, value);
          return;
        }
      }
      super.put(key, value);
    }

    @Override
    public boolean remove(Object key) {
      if (fairSynch) {
        synchronized (lock) {
          return super.remove(key);
        }
      }
      return super.remove(key);
    }
  };
  myConvertors = new LinkedList<LogFilter>();

  // just passes to parent logger
  myProxy = new LogFilter() {
    @Override
    @NotNull
    public Integer getAllowedLoggingInterval(Level level, String message, Throwable t, String[] details) {
      return -1;
    }
    @Override
    public Object getKey(@NotNull Level level,
                         @NonNls String message,
                         @Nullable Throwable t,
                         @NonNls String... details) {
      if (Level.DEBUG.equals(level)) {
        logger.debug(message, t);
      } else if (Level.INFO.equals(level)) {
        logger.info(message, t);
      } else if (Level.WARN.equals(level)) {
        logger.warn(message, t);
      } else if (Level.ERROR.equals(level)) {
        logger.error(message, t, details);
      }
      return null;
    }
  };
}
项目:intellij-ce-playground    文件:ContentAnnotationCacheImpl.java   
public ContentAnnotationCacheImpl() {
  myLock = new Object();
  myCache = new SLRUMap<HistoryCacheWithRevisionKey, TreeMap<Integer, Long>>(50, 50);
}
项目:intellij-ce-playground    文件:VcsHistoryCache.java   
public VcsHistoryCache() {
  myLock = new Object();
  myHistoryCache = new SLRUMap<HistoryCacheBaseKey, CachedHistory>(10, 10);
  myAnnotationCache = new SLRUMap<HistoryCacheWithRevisionKey, VcsAnnotation>(10, 5);
  //myContentCache = new SLRUMap<HistoryCacheWithRevisionKey, String>(20, 20);
}
项目:intellij-ce-playground    文件:FragmentedDiffRequestFromChange.java   
public FragmentedDiffRequestFromChange(Project project) {
  myProject = project;
  myRangesCache = new SLRUMap<Pair<Long, String>, List<BeforeAfter<TextRange>>>(10, 10);
}
项目:tools-idea    文件:RareLogger.java   
private RareLogger(final Logger logger, final boolean fairSynch) {
  myLogger = logger;

  final Object lock = new Object();
  myCache = new SLRUMap<Object, Long>(64, 32) {
    @Override
    public Long get(Object key) {
      if (fairSynch) {
        synchronized (lock) {
          return super.get(key);
        }
      }
      return super.get(key);
    }

    @Override
    public void put(Object key, @NotNull Long value) {
      if (fairSynch) {
        synchronized (lock) {
          super.put(key, value);
          return;
        }
      }
      super.put(key, value);
    }

    @Override
    public boolean remove(Object key) {
      if (fairSynch) {
        synchronized (lock) {
          return super.remove(key);
        }
      }
      return super.remove(key);
    }
  };
  myConvertors = new LinkedList<LogFilter>();

  // just passes to parent logger
  myProxy = new LogFilter() {
    @Override
    @NotNull
    public Integer getAllowedLoggingInterval(Level level, String message, Throwable t, String[] details) {
      return -1;
    }
    @Override
    public Object getKey(@NotNull Level level,
                         @NonNls String message,
                         @Nullable Throwable t,
                         @NonNls String... details) {
      if (Level.DEBUG.equals(level)) {
        logger.debug(message, t);
      } else if (Level.INFO.equals(level)) {
        logger.info(message, t);
      } else if (Level.WARN.equals(level)) {
        logger.warn(message, t);
      } else if (Level.ERROR.equals(level)) {
        logger.error(message, t, details);
      }
      return null;
    }
  };
}
项目:tools-idea    文件:ContentAnnotationCacheImpl.java   
public ContentAnnotationCacheImpl() {
  myLock = new Object();
  myCache = new SLRUMap<HistoryCacheWithRevisionKey, TreeMap<Integer, Long>>(50, 50);
}
项目:tools-idea    文件:VcsHistoryCache.java   
public VcsHistoryCache() {
  myLock = new Object();
  myHistoryCache = new SLRUMap<HistoryCacheBaseKey, CachedHistory>(10, 10);
  myAnnotationCache = new SLRUMap<HistoryCacheWithRevisionKey, VcsAnnotation>(10, 5);
  //myContentCache = new SLRUMap<HistoryCacheWithRevisionKey, String>(20, 20);
}
项目:tools-idea    文件:FragmentedDiffRequestFromChange.java   
public FragmentedDiffRequestFromChange(Project project) {
  myProject = project;
  myRangesCache = new SLRUMap<Pair<Long, String>, List<BeforeAfter<TextRange>>>(10, 10);
}
项目:tools-idea    文件:LinesCache.java   
public LinesCache() {
  myCache = new SLRUMap<String, GitHeavyCommit>(ourSize, 50);
}
项目:consulo    文件:SoftHardCacheMap.java   
public SoftHardCacheMap(final int protectedQueueSize, final int probationalQueueSize) {
  mySLRUMap = new SLRUMap<K, V>(protectedQueueSize, probationalQueueSize);
  mySoftLinkMap = new SoftValueHashMap<K, V>();
}
项目:consulo    文件:ContainingBranchesGetter.java   
@Nonnull
private static SLRUMap<CommitId, List<String>> createCache() {
  return new SLRUMap<>(1000, 1000);
}
项目:consulo    文件:RareLogger.java   
private RareLogger(final Logger logger, final boolean fairSynch) {
  myLogger = logger;

  final Object lock = new Object();
  myCache = new SLRUMap<Object, Long>(64, 32) {
    @Override
    public Long get(Object key) {
      if (fairSynch) {
        synchronized (lock) {
          return super.get(key);
        }
      }
      return super.get(key);
    }

    @Override
    public void put(Object key, @Nonnull Long value) {
      if (fairSynch) {
        synchronized (lock) {
          super.put(key, value);
          return;
        }
      }
      super.put(key, value);
    }

    @Override
    public boolean remove(Object key) {
      if (fairSynch) {
        synchronized (lock) {
          return super.remove(key);
        }
      }
      return super.remove(key);
    }
  };
  myConvertors = new LinkedList<LogFilter>();

  // just passes to parent logger
  myProxy = new LogFilter() {
    @Override
    @Nonnull
    public Integer getAllowedLoggingInterval(Level level, String message, Throwable t, String[] details) {
      return -1;
    }

    @Override
    public Object getKey(@Nonnull Level level, @NonNls String message, @Nullable Throwable t, @NonNls String... details) {
      if (Level.DEBUG.equals(level)) {
        logger.debug(message, t);
      }
      else if (Level.INFO.equals(level)) {
        logger.info(message, t);
      }
      else if (Level.WARN.equals(level)) {
        logger.warn(message, t);
      }
      else if (Level.ERROR.equals(level)) {
        logger.error(message, t, details);
      }
      return null;
    }
  };
}
项目:consulo    文件:ContentAnnotationCacheImpl.java   
public ContentAnnotationCacheImpl() {
  myLock = new Object();
  myCache = new SLRUMap<HistoryCacheWithRevisionKey, TreeMap<Integer, Long>>(50, 50);
}
项目:consulo    文件:VcsHistoryCache.java   
public VcsHistoryCache() {
  myLock = new Object();
  myHistoryCache = new SLRUMap<HistoryCacheBaseKey, CachedHistory>(10, 10);
  myAnnotationCache = new SLRUMap<HistoryCacheWithRevisionKey, VcsAnnotation>(10, 5);
  //myContentCache = new SLRUMap<HistoryCacheWithRevisionKey, String>(20, 20);
}