本文整理汇总了Java中org.apache.lucene.store.NoLockFactory类的典型用法代码示例。如果您正苦于以下问题:Java NoLockFactory类的具体用法?Java NoLockFactory怎么用?Java NoLockFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoLockFactory类属于org.apache.lucene.store包,在下文中一共展示了NoLockFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: MixedDirectory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public MixedDirectory(FileSystem readFs, Path readPath, FileSystem writeFs,
Path writePath, Configuration conf) throws IOException {
try {
readDir = new FileSystemDirectory(readFs, readPath, false, conf);
// check writeFS is a local FS?
writeDir = FSDirectory.getDirectory(writePath.toString());
} catch (IOException e) {
try {
close();
} catch (IOException e1) {
// ignore this one, throw the original one
}
throw e;
}
lockFactory = new NoLockFactory();
}
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:20,代码来源:MixedDirectory.java
示例2: initIndex
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private IndexWriter initIndex(Random random, MockDirectoryWrapper dir, boolean initialCommit) throws IOException {
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random))
.setMaxBufferedDocs(10).setMergeScheduler(new ConcurrentMergeScheduler()));
((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions();
if (initialCommit) {
writer.commit();
}
Document doc = new Document();
doc.add(newTextField("content", "aaa", Field.Store.NO));
doc.add(newTextField("id", "0", Field.Store.NO));
for(int i=0;i<157;i++)
writer.addDocument(doc);
return writer;
}
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestCrash.java
示例3: initIndex
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private IndexWriter initIndex(Random random, MockDirectoryWrapper dir, boolean initialCommit) throws IOException {
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))
.setMaxBufferedDocs(10).setMergeScheduler(new ConcurrentMergeScheduler()));
((ConcurrentMergeScheduler) writer.getConfig().getMergeScheduler()).setSuppressExceptions();
if (initialCommit) {
writer.commit();
}
Document doc = new Document();
doc.add(newTextField("content", "aaa", Field.Store.NO));
doc.add(newTextField("id", "0", Field.Store.NO));
for(int i=0;i<157;i++)
writer.addDocument(doc);
return writer;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:TestCrash.java
示例4: testNoSegmentFile
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public void testNoSegmentFile() throws IOException {
Directory dir = newDirectory();
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2));
Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.setStoreTermVectors(true);
customType.setStoreTermVectorPositions(true);
customType.setStoreTermVectorOffsets(true);
doc.add(newField("c", "val", customType));
w.addDocument(doc);
w.addDocument(doc);
IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2)
.setOpenMode(OpenMode.CREATE));
w2.close();
// If we don't do that, the test fails on Windows
w.rollback();
dir.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:TestIndexWriter.java
示例5: FileSystemDirectory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public FileSystemDirectory(final Path root, final int bufferSize,
Configuration conf, File tmpdir) throws IOException {
this.bufferSize = bufferSize;
this.fs = root.getFileSystem(conf);
this.root = root;
log.debug("initializing fsdir at " + root);
fs.mkdirs(root);
this.writes = Collections.synchronizedSet(new TreeSet<String>());
this.setLockFactory(NoLockFactory.getNoLockFactory());
this.blockCache = CacheBuilder.newBuilder().maximumSize(1024)
.removalListener(BLOCK_CACHE_REMOVAL)
.expireAfterAccess(1, TimeUnit.HOURS).build();
this.lengthCache = new ConcurrentHashMap<String, Long>();
File cacheRoot = new File(tmpdir, "leaf-cache");
tmp = new File(cacheRoot, this.getLockID());
tmp.mkdirs();
log.debug("initialized fsdir at " + root);
}
开发者ID:omc,项目名称:indoop,代码行数:19,代码来源:FileSystemDirectory.java
示例6: doTestStoreDirectory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private void doTestStoreDirectory(Index index, Path tempDir, String typeSettingValue, IndexModule.Type type) throws IOException {
Settings.Builder settingsBuilder = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT);
if (typeSettingValue != null) {
settingsBuilder.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), typeSettingValue);
}
Settings settings = settingsBuilder.build();
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings);
FsDirectoryService service = new FsDirectoryService(indexSettings, null, new ShardPath(false, tempDir, tempDir, new ShardId(index, 0)));
try (Directory directory = service.newFSDirectory(tempDir, NoLockFactory.INSTANCE)) {
switch (type) {
case NIOFS:
assertTrue(type + " " + directory.toString(), directory instanceof NIOFSDirectory);
break;
case MMAPFS:
assertTrue(type + " " + directory.toString(), directory instanceof MMapDirectory);
break;
case SIMPLEFS:
assertTrue(type + " " + directory.toString(), directory instanceof SimpleFSDirectory);
break;
case FS:
if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
assertTrue(directory.toString(), directory instanceof MMapDirectory);
} else if (Constants.WINDOWS) {
assertTrue(directory.toString(), directory instanceof SimpleFSDirectory);
} else {
assertTrue(directory.toString(), directory instanceof NIOFSDirectory);
}
break;
default:
fail();
}
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:IndexStoreTests.java
示例7: reloadIndex
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private void reloadIndex() {
Directory diskDir;
try {
synchronized (getLock()) {
initializedIndex = false;
if(!diskIndex) {
resetIndex();
return;
}
index = new MMapDirectory(directorySnapshot, NoLockFactory.getNoLockFactory());
IndexWriterConfig iwc = new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_36,
analyzer).setOpenMode(OpenMode.CREATE_OR_APPEND);
if (diskIndexRunning) {
iwc.setRAMBufferSizeMB(INDEX_RAM_BUFFER_SIZE)
.setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES) // TESTING
.setMergeScheduler(NoMergeScheduler.INSTANCE); // TETING
}
writer = new IndexWriter(index, iwc);
initializedIndex = (writer.numDocs() > 0) ? true : false;
reader = IndexReader.open(getWriter(), true); /* true: apply all deletes (perfhit) */
searcher = new IndexSearcher(reader);
needsReset = false;
}
} catch (IOException e) {
System.out.println("Execption reloading index from disk; assuming corrupt. e = " + e);
e.printStackTrace();
resetIndex();
}
}
开发者ID:google,项目名称:sagetv,代码行数:30,代码来源:Wizard.java
示例8: testEmptyFSDirWithNoLock
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public void testEmptyFSDirWithNoLock() throws Exception {
// Tests that if FSDir is opened w/ a NoLockFactory (or SingleInstanceLF),
// then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
// when listAll() was called in IndexFileDeleter.
Directory dir = newFSDirectory(createTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))).close();
dir.close();
}
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TestIndexWriter.java
示例9: testNoSegmentFile
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public void testNoSegmentFile() throws IOException {
BaseDirectoryWrapper dir = newDirectory();
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
.setMaxBufferedDocs(2));
Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.setStoreTermVectors(true);
customType.setStoreTermVectorPositions(true);
customType.setStoreTermVectorOffsets(true);
doc.add(newField("c", "val", customType));
w.addDocument(doc);
w.addDocument(doc);
IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
.setMaxBufferedDocs(2)
.setOpenMode(OpenMode.CREATE));
w2.close();
// If we don't do that, the test fails on Windows
w.rollback();
// This test leaves only segments.gen, which causes
// DirectoryReader.indexExists to return true:
dir.setCheckIndexOnClose(false);
dir.close();
}
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:TestIndexWriter.java
示例10: setUp
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
super.setUp();
beginTransaction();
//directory = new ExodusDirectory(env);
//directory = new RAMDirectory();
directory = new DebugExodusDirectory((ContextualEnvironment) getEnvironment(), getContentsConfig(), NoLockFactory.getNoLockFactory());
createAnalyzer();
createIndexWriter();
}
开发者ID:JetBrains,项目名称:xodus,代码行数:12,代码来源:ExodusLuceneTestsBase.java
示例11: SourceUriArray
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
/**
* Creates instance of the collection.
* @throws IOException if creating instance fails
*/
public SourceUriArray(String [] names) throws IOException {
this.names = names!=null? names: new String[]{};
// get new UUID
String name = UuidUtil.makeUuid();
// construct full path to the Lucene directory
String path = System.getProperty("java.io.tmpdir") + File.separator + SUBFOLDER + File.separator + name;
// create folder
folder = new File(path);
folder.mkdirs();
folder.deleteOnExit();
// create Lucene directory within the folder; it has to be no locking directory
directory = FSDirectory.open(folder,NoLockFactory.getNoLockFactory());
openForWriting();
}
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:19,代码来源:SourceUriArray.java
示例12: testEmptyFSDirWithNoLock
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public void testEmptyFSDirWithNoLock() throws Exception {
// Tests that if FSDir is opened w/ a NoLockFactory (or SingleInstanceLF),
// then IndexWriter ctor succeeds. Previously (LUCENE-2386) it failed
// when listAll() was called in IndexFileDeleter.
Directory dir = newFSDirectory(_TestUtil.getTempDir("emptyFSDirNoLock"), NoLockFactory.getNoLockFactory());
new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close();
dir.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:TestIndexWriter.java
示例13: injectLockFactory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private static Directory injectLockFactory(Directory dir, String lockPath,
String rawLockType) throws IOException {
if (null == rawLockType) {
// we default to "simple" for backwards compatibility
log.warn("No lockType configured for " + dir + " assuming 'simple'");
rawLockType = "simple";
}
final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
if ("simple".equals(lockType)) {
// multiple SimpleFSLockFactory instances should be OK
dir.setLockFactory(new SimpleFSLockFactory(lockPath));
} else if ("native".equals(lockType)) {
dir.setLockFactory(new NativeFSLockFactory(lockPath));
} else if ("single".equals(lockType)) {
if (!(dir.getLockFactory() instanceof SingleInstanceLockFactory)) dir
.setLockFactory(new SingleInstanceLockFactory());
} else if ("none".equals(lockType)) {
// Recipe for disaster
log.error("CONFIGURATION WARNING: locks are disabled on " + dir);
dir.setLockFactory(NoLockFactory.getNoLockFactory());
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unrecognized lockType: " + rawLockType);
}
return dir;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:CachingDirectoryFactory.java
示例14: FastHdfsKeyValueDirectory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public FastHdfsKeyValueDirectory(boolean readOnly, Timer hdfsKeyValueTimer, Configuration configuration, Path path,
long maxAmountAllowedPerFile, long maxOpenForWriting) throws IOException {
_path = path;
_readOnly = readOnly;
_store = new HdfsKeyValueStore(readOnly, hdfsKeyValueTimer, configuration, path, maxAmountAllowedPerFile,
maxOpenForWriting);
MemoryLeakDetector.record(_store, "HdfsKeyValueStore", path.toString());
BytesRef value = new BytesRef();
if (_store.get(FILES, value)) {
String filesString = value.utf8ToString();
// System.out.println("Open Files String [" + filesString + "]");
if (!filesString.isEmpty()) {
String[] files = filesString.split("\\" + SEP);
for (String file : files) {
if (file.isEmpty()) {
throw new IOException("Empty file names should not occur [" + filesString + "]");
}
BytesRef key = new BytesRef(file + LENGTH);
if (_store.get(key, value)) {
_files.put(file, Long.parseLong(value.utf8ToString()));
} else {
LOG.warn(MISSING_METADATA_MESSAGE, file);
}
}
}
}
setLockFactory(NoLockFactory.getNoLockFactory());
if (!_readOnly) {
writeFileNamesAndSync();
gc();
}
}
开发者ID:apache,项目名称:incubator-blur,代码行数:33,代码来源:FastHdfsKeyValueDirectory.java
示例15: HdfsDirectory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public HdfsDirectory(Configuration configuration, Path path, SequentialReadControl sequentialReadControl,
boolean resourceTracking) throws IOException {
_resourceTracking = resourceTracking;
if (sequentialReadControl == null) {
_sequentialReadControl = new SequentialReadControl(new BlurConfiguration());
} else {
_sequentialReadControl = sequentialReadControl;
}
_fileSystem = path.getFileSystem(configuration);
_path = _fileSystem.makeQualified(path);
if (_path.toUri().getScheme().equals(HDFS_SCHEMA)) {
_asyncClosing = true;
} else {
_asyncClosing = false;
}
_fileSystem.mkdirs(path);
setLockFactory(NoLockFactory.getNoLockFactory());
synchronized (_metricsGroupMap) {
URI uri = _fileSystem.getUri();
MetricsGroup metricsGroup = _metricsGroupMap.get(uri);
if (metricsGroup == null) {
String scope = uri.toString();
metricsGroup = createNewMetricsGroup(scope);
_metricsGroupMap.put(uri, metricsGroup);
}
_metricsGroup = metricsGroup;
}
if (_useCache) {
_fileStatusCache = new FStatusCache(_fileSystem, _path);
if (!_fileStatusCache.loadCacheFromManifest()) {
FileStatus[] listStatus = _fileSystem.listStatus(_path);
addToCache(listStatus);
}
} else {
_fileStatusCache = null;
}
}
开发者ID:apache,项目名称:incubator-blur,代码行数:40,代码来源:HdfsDirectory.java
示例16: copyAndOptimizeInFlightDir
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private void copyAndOptimizeInFlightDir() throws IOException {
CopyRateDirectory copyRateDirectory = new CopyRateDirectory(_finalDir, _copyRateCounter);
copyRateDirectory.setLockFactory(NoLockFactory.getNoLockFactory());
DirectoryReader reader = DirectoryReader.open(_localDir);
IndexWriter writer = new IndexWriter(copyRateDirectory, _conf.clone());
writer.addIndexes(reader);
writer.setCommitData(getInternalMarker());
writer.close();
rm(_localPath);
}
开发者ID:apache,项目名称:incubator-blur,代码行数:11,代码来源:GenericBlurRecordWriter.java
示例17: ObjectStorageDirectory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public ObjectStorageDirectory(HttpDownloader httpDownloader,
SwiftToken token, String container) throws SearchLibException {
this.httpDownloader = httpDownloader;
this.swiftToken = token;
this.container = container;
this.lockFactory = NoLockFactory.getNoLockFactory();
this.inputCache = new ByteCache(100);
this.listAllCache = null;
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:10,代码来源:ObjectStorageDirectory.java
示例18: testNoSegmentFile
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
public void testNoSegmentFile() throws IOException {
BaseDirectoryWrapper dir = newDirectory();
dir.setLockFactory(NoLockFactory.getNoLockFactory());
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2));
Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.setStoreTermVectors(true);
customType.setStoreTermVectorPositions(true);
customType.setStoreTermVectorOffsets(true);
doc.add(newField("c", "val", customType));
w.addDocument(doc);
w.addDocument(doc);
IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2)
.setOpenMode(OpenMode.CREATE));
w2.close();
// If we don't do that, the test fails on Windows
w.rollback();
// This test leaves only segments.gen, which causes
// DirectoryReader.indexExists to return true:
dir.setCheckIndexOnClose(false);
dir.close();
}
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:28,代码来源:TestIndexWriter.java
示例19: SourceUriArray
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
/**
* Creates instance of the collection.
* @throws IOException if creating instance fails
*/
public SourceUriArray(String [] names) throws IOException {
this.names = names!=null? names: new String[]{};
// get new UUID
String name = UuidUtil.makeUuid();
// construct full path to the Lucene directory
String path = System.getProperty("java.io.tmpdir") + File.separator + SUBFOLDER + File.separator + name;
// create folder
File folder = new File(path);
folder.mkdirs();
// create Lucene directory within the folder; it has to be no locking directory
directory = FSDirectory.open(folder,NoLockFactory.getNoLockFactory());
openForWriting();
}
开发者ID:usgin,项目名称:usgin-geoportal,代码行数:18,代码来源:SourceUriArray.java
示例20: injectLockFactory
import org.apache.lucene.store.NoLockFactory; //导入依赖的package包/类
private static Directory injectLockFactory(Directory dir, String lockPath,
String rawLockType) throws IOException {
if (null == rawLockType) {
// we default to "simple" for backwards compatibility
log.warn("No lockType configured for " + dir + " assuming 'simple'");
rawLockType = "simple";
}
final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
if ("simple".equals(lockType)) {
// multiple SimpleFSLockFactory instances should be OK
dir.setLockFactory(new SimpleFSLockFactory(lockPath));
} else if ("native".equals(lockType)) {
dir.setLockFactory(new NativeFSLockFactory(lockPath));
} else if ("single".equals(lockType)) {
if (!(dir.getLockFactory() instanceof SingleInstanceLockFactory)) dir
.setLockFactory(new SingleInstanceLockFactory());
} else if ("hdfs".equals(lockType)) {
Directory del = dir;
if (dir instanceof NRTCachingDirectory) {
del = ((NRTCachingDirectory) del).getDelegate();
}
if (del instanceof BlockDirectory) {
del = ((BlockDirectory) del).getDirectory();
}
if (!(del instanceof HdfsDirectory)) {
throw new SolrException(ErrorCode.FORBIDDEN, "Directory: "
+ del.getClass().getName()
+ ", but hdfs lock factory can only be used with HdfsDirectory");
}
dir.setLockFactory(new HdfsLockFactory(((HdfsDirectory)del).getHdfsDirPath(), ((HdfsDirectory)del).getConfiguration()));
} else if ("none".equals(lockType)) {
// Recipe for disaster
log.error("CONFIGURATION WARNING: locks are disabled on " + dir);
dir.setLockFactory(NoLockFactory.getNoLockFactory());
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unrecognized lockType: " + rawLockType);
}
return dir;
}
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:CachingDirectoryFactory.java
注:本文中的org.apache.lucene.store.NoLockFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论