当前位置: 首页>>代码示例>>Java>>正文


Java AtomicReader.getCoreCacheKey方法代码示例

本文整理汇总了Java中org.apache.lucene.index.AtomicReader.getCoreCacheKey方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicReader.getCoreCacheKey方法的具体用法?Java AtomicReader.getCoreCacheKey怎么用?Java AtomicReader.getCoreCacheKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.AtomicReader的用法示例。


在下文中一共展示了AtomicReader.getCoreCacheKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: put

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
/** Sets the key to the value for the provided reader;
 *  if the key is already set then this doesn't change it. */
public void put(AtomicReader reader, CacheKey key, Accountable value) {
  final Object readerKey = reader.getCoreCacheKey();
  synchronized (readerCache) {
    Map<CacheKey,Accountable> innerCache = readerCache.get(readerKey);
    if (innerCache == null) {
      // First time this reader is using FieldCache
      innerCache = new HashMap<>();
      readerCache.put(readerKey, innerCache);
      wrapper.initReader(reader);
    }
    if (innerCache.get(key) == null) {
      innerCache.put(key, value);
    } else {
      // Another thread beat us to it; leave the current
      // value
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:FieldCacheImpl.java

示例2: put

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
/**
 * Sets the key to the value for the provided reader;
 * if the key is already set then this doesn't change it.
 */
public void put(AtomicReader reader, CacheKey key, Accountable value) {
  final Object readerKey = reader.getCoreCacheKey();
  synchronized (readerCache) {
    Map<CacheKey, Accountable> innerCache = readerCache.get(readerKey);
    if (innerCache == null) {
      // First time this reader is using FieldCache
      innerCache = new HashMap<>();
      readerCache.put(readerKey, innerCache);
      wrapper.initReader(reader);
    }
    if (innerCache.get(key) == null) {
      innerCache.put(key, value);
    } else {
      // Another thread beat us to it; leave the current
      // value
    }
  }
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:23,代码来源:LindenFieldCacheImpl.java

示例3: initReader

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
private void initReader(AtomicReader reader) {
  if (reader instanceof SegmentReader) {
    ((SegmentReader) reader).addCoreClosedListener(purgeCore);
  } else {
    // we have a slow reader of some sort, try to register a purge event
    // rather than relying on gc:
    Object key = reader.getCoreCacheKey();
    if (key instanceof AtomicReader) {
      ((AtomicReader)key).addReaderClosedListener(purgeReader); 
    } else {
      // last chance
      reader.addReaderClosedListener(purgeReader);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:FieldCacheImpl.java

示例4: initReader

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
private void initReader(AtomicReader reader) {
  if (reader instanceof SegmentReader) {
    reader.addCoreClosedListener(purgeCore);
  } else {
    // we have a slow reader of some sort, try to register a purge event
    // rather than relying on gc:
    Object key = reader.getCoreCacheKey();
    if (key instanceof AtomicReader) {
      ((AtomicReader) key).addReaderClosedListener(purgeReader);
    } else {
      // last chance
      reader.addReaderClosedListener(purgeReader);
    }
  }
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:16,代码来源:LindenFieldCacheImpl.java

示例5: get

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public Accountable get(AtomicReader reader, CacheKey key, boolean setDocsWithField) throws IOException {
  Map<CacheKey,Accountable> innerCache;
  Accountable value;
  final Object readerKey = reader.getCoreCacheKey();
  synchronized (readerCache) {
    innerCache = readerCache.get(readerKey);
    if (innerCache == null) {
      // First time this reader is using FieldCache
      innerCache = new HashMap<>();
      readerCache.put(readerKey, innerCache);
      wrapper.initReader(reader);
      value = null;
    } else {
      value = innerCache.get(key);
    }
    if (value == null) {
      value = new CreationPlaceholder();
      innerCache.put(key, value);
    }
  }
  if (value instanceof CreationPlaceholder) {
    synchronized (value) {
      CreationPlaceholder progress = (CreationPlaceholder) value;
      if (progress.value == null) {
        progress.value = createValue(reader, key, setDocsWithField);
        synchronized (readerCache) {
          innerCache.put(key, progress.value);
        }

        // Only check if key.custom (the parser) is
        // non-null; else, we check twice for a single
        // call to FieldCache.getXXX
        if (key.custom != null && wrapper != null) {
          final PrintStream infoStream = wrapper.getInfoStream();
          if (infoStream != null) {
            printNewInsanity(infoStream, progress.value);
          }
        }
      }
      return progress.value;
    }
  }
  return value;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:FieldCacheImpl.java

示例6: get

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public Accountable get(AtomicReader reader, CacheKey key, boolean setDocsWithField) throws IOException {
  Map<CacheKey, Accountable> innerCache;
  Accountable value;
  final Object readerKey = reader.getCoreCacheKey();
  synchronized (readerCache) {
    innerCache = readerCache.get(readerKey);
    if (innerCache == null) {
      // First time this reader is using FieldCache
      innerCache = new HashMap<>();
      readerCache.put(readerKey, innerCache);
      wrapper.initReader(reader);
      value = null;
    } else {
      value = innerCache.get(key);
    }
    if (value == null) {
      value = new CreationPlaceholder();
      innerCache.put(key, value);
    }
  }
  if (value instanceof CreationPlaceholder) {
    synchronized (value) {
      CreationPlaceholder progress = (CreationPlaceholder) value;
      if (progress.value == null) {
        long start = System.currentTimeMillis();
        progress.value = createValue(reader, key, setDocsWithField);
        long end = System.currentTimeMillis();
        LOGGER.info("createValue for {} cache in LindenFieldCacheImpl took {} ms", key.field, (end - start));
        synchronized (readerCache) {
          innerCache.put(key, progress.value);
        }

        // Only check if key.custom (the parser) is
        // non-null; else, we check twice for a single
        // call to FieldCache.getXXX
        if (key.custom != null && wrapper != null) {
          final PrintStream infoStream = wrapper.getInfoStream();
          if (infoStream != null) {
            printNewInsanity(infoStream, progress.value);
          }
        }
      }
      return progress.value;
    }
  }
  return value;
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:48,代码来源:LindenFieldCacheImpl.java


注:本文中的org.apache.lucene.index.AtomicReader.getCoreCacheKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。