internal override void Remove(TxDataHolder holder, EntityId entityId, string key, object value) { try { EnsureLuceneDataInstantiated(); long id = entityId.Id(); Document document = FindDocument(id); if (document != null) { Index.type.removeFromDocument(document, key, value); if (LuceneDataSource.DocumentIsEmpty(document)) { _writer.deleteDocuments(Index.type.idTerm(id)); } else { _writer.updateDocument(Index.type.idTerm(id), document); } } InvalidateSearcher(); } catch (IOException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void recoveryForRelationshipCommandsOnly() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RecoveryForRelationshipCommandsOnly() { // shutdown db here DatabaseLayout databaseLayout = Db.databaseLayout(); ShutdownDB(); using (Transaction tx = Db.beginTx()) { Index <Relationship> index = Db.index().forRelationships("myIndex"); Node node = Db.createNode(); Relationship relationship = Db.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS")); index.Add(relationship, "key", "value"); tx.Success(); } Db.shutdown(); Config config = Config.defaults(); IndexConfigStore indexStore = new IndexConfigStore(databaseLayout, FileSystemRule.get()); LuceneDataSource ds = new LuceneDataSource(databaseLayout, config, indexStore, FileSystemRule.get(), OperationalMode.single); ds.Start(); ds.Stop(); }
public PrefetchingResourceIteratorAnonymousInnerClass(LuceneDataSource outerInstance, ICollection <File> files, ICollection <Pair <SnapshotDeletionPolicy, IndexCommit> > snapshots) { this.outerInstance = outerInstance; this._files = files; this._snapshots = snapshots; filesIterator = Files.GetEnumerator(); }
internal CommitContext(LuceneDataSource dataSource, IndexIdentifier identifier, IndexType indexType, bool isRecovery) { this.DataSource = dataSource; this.Identifier = identifier; this.IndexType = indexType; this.Recovery = isRecovery; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleMultipleIdSpaces() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldHandleMultipleIdSpaces() { // GIVEN string indexName = "name"; string key = "key"; DatabaseLayout databaseLayout = _testDirectory.databaseLayout(); IndexConfigStore configStore = new IndexConfigStore(databaseLayout, _fs); configStore.Set(typeof(Node), indexName, EXACT_CONFIG); using (Lifespan lifespan = new Lifespan()) { Config dataSourceConfig = Config.defaults(LuceneDataSource.Configuration.Ephemeral, Settings.TRUE); LuceneDataSource originalDataSource = new LuceneDataSource(databaseLayout, dataSourceConfig, configStore, _fs, OperationalMode.single); LuceneDataSource dataSource = lifespan.Add(spy(originalDataSource)); using (LuceneCommandApplier applier = new LuceneCommandApplier(dataSource, false)) { // WHEN issuing a command where the index name is mapped to a certain id IndexDefineCommand definitions = definitions(ObjectIntHashMap.newWithKeysValues(indexName, 0), ObjectIntHashMap.newWithKeysValues(key, 0)); applier.VisitIndexDefineCommand(definitions); applier.VisitIndexAddNodeCommand(AddNodeToIndex(definitions, indexName, 0L)); // and then later issuing a command for that same index, but in another transaction where // the local index name id is a different one definitions = definitions(ObjectIntHashMap.newWithKeysValues(indexName, 1), ObjectIntHashMap.newWithKeysValues(key, 0)); applier.VisitIndexDefineCommand(definitions); applier.VisitIndexAddNodeCommand(AddNodeToIndex(definitions, indexName, 1L)); } // THEN both those updates should have been directed to the same index verify(dataSource, times(1)).getIndexSearcher(any(typeof(IndexIdentifier))); } }
internal LuceneExplicitIndex(LuceneDataSource dataSource, IndexIdentifier identifier, LuceneTransactionState transaction, IndexType type, IndexCommandFactory commandFactory) { this.DataSource = dataSource; this.IdentifierConflict = identifier; this.Transaction = transaction; this.Type = type; this.CommandFactory = commandFactory; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void prepareIndexesByIdentifiers(IndexIdentifier indexIdentifier) throws Exception private void PrepareIndexesByIdentifiers(IndexIdentifier indexIdentifier) { Config config = Config.defaults(); _dataSource = _life.add(GetLuceneDataSource(config)); _dataSource.getIndexSearcher(indexIdentifier); _dataSource.force(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testShouldReturnIndexWriterFromLRUCache() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestShouldReturnIndexWriterFromLRUCache() { Config config = Config.defaults(); _dataSource = _life.add(GetLuceneDataSource(config)); IndexIdentifier identifier = identifier("foo"); IndexWriter writer = _dataSource.getIndexSearcher(identifier).Writer; assertSame(writer, _dataSource.getIndexSearcher(identifier).Writer); }
internal LuceneBatchInserterIndex(File dbStoreDir, IndexIdentifier identifier, IDictionary <string, string> config, RelationshipLookup relationshipLookup) { File storeDir = GetStoreDir(dbStoreDir); this._createdNow = !LuceneDataSource.GetFileDirectory(storeDir, identifier).exists(); this._identifier = identifier; this._type = IndexType.GetIndexType(config); this._relationshipLookup = relationshipLookup; this._writer = InstantiateWriter(storeDir); this._searcherManager = InstantiateSearcherManager(_writer); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void notAllowIndexDeletionInReadOnlyMode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void NotAllowIndexDeletionInReadOnlyMode() { IndexIdentifier indexIdentifier = Identifier("foo"); PrepareIndexesByIdentifiers(indexIdentifier); StopDataSource(); Config readOnlyConfig = Config.defaults(readOnlyConfig()); _dataSource = _life.add(GetLuceneDataSource(readOnlyConfig, OperationalMode.single)); _expectedException.expect(typeof(System.InvalidOperationException)); _expectedException.expectMessage("Index deletion in read only mode is not supported."); _dataSource.deleteIndex(indexIdentifier, false); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void doNotTryToCommitWritersOnForceInReadOnlyMode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DoNotTryToCommitWritersOnForceInReadOnlyMode() { IndexIdentifier indexIdentifier = Identifier("foo"); PrepareIndexesByIdentifiers(indexIdentifier); StopDataSource(); Config readOnlyConfig = Config.defaults(readOnlyConfig()); LuceneDataSource readOnlyDataSource = _life.add(GetLuceneDataSource(readOnlyConfig)); assertNotNull(readOnlyDataSource.GetIndexSearcher(indexIdentifier)); readOnlyDataSource.Force(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useWritableIndexSearcherInReadOnlyModeForNonSingleInstance() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void UseWritableIndexSearcherInReadOnlyModeForNonSingleInstance() { IndexIdentifier indexIdentifier = Identifier("foo"); PrepareIndexesByIdentifiers(indexIdentifier); StopDataSource(); Config readOnlyConfig = Config.defaults(readOnlyConfig()); _dataSource = _life.add(GetLuceneDataSource(readOnlyConfig, OperationalMode.ha)); IndexReference indexSearcher = _dataSource.getIndexSearcher(indexIdentifier); assertTrue("Writable index reference should be used in read only mode in ha mode.", typeof(WritableIndexReference).IsInstanceOfType(indexSearcher)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testClosesOldestIndexWriterWhenCacheSizeIsExceeded() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestClosesOldestIndexWriterWhenCacheSizeIsExceeded() { AddIndex("bar"); AddIndex("baz"); Config config = Config.defaults(CacheSizeConfig()); _dataSource = _life.add(GetLuceneDataSource(config)); IndexIdentifier fooIdentifier = Identifier("foo"); IndexIdentifier barIdentifier = Identifier("bar"); IndexIdentifier bazIdentifier = Identifier("baz"); IndexWriter fooIndexWriter = _dataSource.getIndexSearcher(fooIdentifier).Writer; _dataSource.getIndexSearcher(barIdentifier); assertTrue(fooIndexWriter.Open); _dataSource.getIndexSearcher(bazIdentifier); assertFalse(fooIndexWriter.Open); }
private IndexWriter InstantiateWriter(File folder) { Directory dir = null; try { dir = LuceneDataSource.GetDirectory(folder, _identifier); IndexWriterConfig writerConfig = new IndexWriterConfig(_type.analyzer); writerConfig.RAMBufferSizeMB = DetermineGoodBufferSize(writerConfig.RAMBufferSizeMB); return(new IndexWriter(dir, writerConfig)); } catch (IOException e) { IOUtils.closeAllSilently(dir); throw new Exception(e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void setupIndexInfrastructure() throws Exception private void SetupIndexInfrastructure() { DatabaseLayout databaseLayout = _testDirectory.databaseLayout(); _indexStore = new IndexConfigStore(databaseLayout, _fileSystemRule.get()); _indexStore.set(typeof(Node), INDEX_NAME, MapUtil.stringMap(Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene", "type", "fulltext")); LuceneDataSource luceneDataSource = new LuceneDataSource(databaseLayout, Config.defaults(), _indexStore, _fileSystemRule.get(), OperationalMode.single); try { luceneDataSource.Init(); luceneDataSource.GetIndexSearcher(_indexIdentifier); } finally { luceneDataSource.Shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testRecreatesWriterWhenRequestedAgainAfterCacheEviction() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestRecreatesWriterWhenRequestedAgainAfterCacheEviction() { AddIndex("bar"); AddIndex("baz"); Config config = Config.defaults(CacheSizeConfig()); _dataSource = _life.add(GetLuceneDataSource(config)); IndexIdentifier fooIdentifier = Identifier("foo"); IndexIdentifier barIdentifier = Identifier("bar"); IndexIdentifier bazIdentifier = Identifier("baz"); IndexWriter oldFooIndexWriter = _dataSource.getIndexSearcher(fooIdentifier).Writer; _dataSource.getIndexSearcher(barIdentifier); _dataSource.getIndexSearcher(bazIdentifier); IndexWriter newFooIndexWriter = _dataSource.getIndexSearcher(fooIdentifier).Writer; assertNotSame(oldFooIndexWriter, newFooIndexWriter); assertTrue(newFooIndexWriter.Open); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void refreshReadOnlyIndexSearcherInReadOnlyMode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RefreshReadOnlyIndexSearcherInReadOnlyMode() { IndexIdentifier indexIdentifier = Identifier("foo"); PrepareIndexesByIdentifiers(indexIdentifier); StopDataSource(); Config readOnlyConfig = Config.defaults(readOnlyConfig()); _dataSource = _life.add(GetLuceneDataSource(readOnlyConfig)); IndexReference indexSearcher = _dataSource.getIndexSearcher(indexIdentifier); IndexReference indexSearcher2 = _dataSource.getIndexSearcher(indexIdentifier); IndexReference indexSearcher3 = _dataSource.getIndexSearcher(indexIdentifier); IndexReference indexSearcher4 = _dataSource.getIndexSearcher(indexIdentifier); assertSame("Refreshed read only searcher should be the same.", indexSearcher, indexSearcher2); assertSame("Refreshed read only searcher should be the same.", indexSearcher2, indexSearcher3); assertSame("Refreshed read only searcher should be the same.", indexSearcher3, indexSearcher4); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void applyDocuments(org.apache.lucene.index.IndexWriter writer, IndexType type, org.eclipse.collections.api.map.primitive.LongObjectMap<DocumentContext> documents) throws java.io.IOException private void ApplyDocuments(IndexWriter writer, IndexType type, LongObjectMap <DocumentContext> documents) { foreach (DocumentContext context in documents) { if (context.Exists) { if (LuceneDataSource.DocumentIsEmpty(context.Document)) { writer.deleteDocuments(type.IdTerm(context.EntityId)); } else { writer.updateDocument(type.IdTerm(context.EntityId), context.Document); } } else { writer.addDocument(context.Document); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testRecreatesSearcherWhenRequestedAgain() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestRecreatesSearcherWhenRequestedAgain() { AddIndex("bar"); AddIndex("baz"); Config config = Config.defaults(CacheSizeConfig()); _dataSource = _life.add(GetLuceneDataSource(config)); IndexIdentifier fooIdentifier = Identifier("foo"); IndexIdentifier barIdentifier = Identifier("bar"); IndexIdentifier bazIdentifier = Identifier("baz"); IndexReference oldFooSearcher = _dataSource.getIndexSearcher(fooIdentifier); IndexReference barSearcher = _dataSource.getIndexSearcher(barIdentifier); IndexReference bazSearcher = _dataSource.getIndexSearcher(bazIdentifier); IndexReference newFooSearcher = _dataSource.getIndexSearcher(bazIdentifier); assertNotSame(oldFooSearcher, newFooSearcher); assertFalse(newFooSearcher.Closed); oldFooSearcher.Close(); barSearcher.Close(); bazSearcher.Close(); newFooSearcher.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexDeleteShouldDeleteDirectory() public virtual void IndexDeleteShouldDeleteDirectory() { string indexName = "index"; string otherIndexName = "other-index"; File indexBaseDir = new File(TestDirectory.databaseDir(), "index"); File pathToLuceneIndex = LuceneDataSource.GetFileDirectory(indexBaseDir, new IndexIdentifier(IndexEntityType.Node, indexName)); File pathToOtherLuceneIndex = LuceneDataSource.GetFileDirectory(indexBaseDir, new IndexIdentifier(IndexEntityType.Node, otherIndexName)); Index <Node> index; using (Transaction tx = _db.beginTx()) { index = _db.index().forNodes(indexName); Index <Node> otherIndex = _db.index().forNodes(otherIndexName); Node node = _db.createNode(); index.Add(node, "someKey", "someValue"); otherIndex.Add(node, "someKey", "someValue"); tx.Success(); } // Here "index" and "other-index" indexes should exist assertTrue(pathToLuceneIndex.exists()); assertTrue(pathToOtherLuceneIndex.exists()); using (Transaction tx = _db.beginTx()) { index.Delete(); assertTrue(pathToLuceneIndex.exists()); assertTrue(pathToOtherLuceneIndex.exists()); tx.Success(); } // Here only "other-index" should exist assertFalse(pathToLuceneIndex.exists()); assertTrue(pathToOtherLuceneIndex.exists()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.apache.lucene.search.TopDocs toTopDocs(org.apache.lucene.search.Query query, org.neo4j.index.lucene.QueryContext context, org.apache.lucene.search.IndexSearcher searcher) throws java.io.IOException private TopDocs ToTopDocs(Query query, QueryContext context, IndexSearcher searcher) { Sort sorting = context != null ? context.Sorting : null; TopDocs topDocs; if (sorting == null && context != null) { topDocs = searcher.search(query, context.Top); } else { if (context == null || !context.TradeCorrectnessForSpeed) { TopFieldCollector collector = LuceneDataSource.ScoringCollector(sorting, context.Top); searcher.search(query, collector); topDocs = collector.topDocs(); } else { topDocs = searcher.search(query, null, context.Top, sorting); } } return(topDocs); }
internal virtual DocumentContext GetDocument(EntityId entityId, bool allowCreate) { long id = entityId.Id(); DocumentContext context = Documents.get(id); if (context != null) { return(context); } Document document = LuceneDataSource.FindDocument(IndexType, Searcher.Searcher, id); if (document != null) { context = new DocumentContext(document, true, id); Documents.put(id, context); } else if (allowCreate) { context = new DocumentContext(IndexType.NewDocument(entityId), false, id); Documents.put(id, context); } return(context); }
public LuceneCommandApplier(LuceneDataSource dataSource, bool recovery) { this._dataSource = dataSource; this._recovery = recovery; }
public LuceneExplicitIndexTransaction(LuceneDataSource dataSource, IndexCommandFactory commandFactory) { this._dataSource = dataSource; this._commandFactory = commandFactory; this._luceneTransaction = new LuceneTransactionState(); }
internal RelationshipExplicitIndex(LuceneDataSource dataSource, IndexIdentifier identifier, LuceneTransactionState transaction, IndexType type, IndexCommandFactory commandFactory) : base(dataSource, identifier, transaction, type, commandFactory) { }
public override void Init() { this._dataSource = new LuceneDataSource(_databaseLayout, _config, _indexStore.get(), _fileSystemAbstraction, _operationalMode); this._dataSource.init(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void shutdown() throws Throwable public override void Shutdown() { this._dataSource.shutdown(); this._dataSource = null; }
public override File GetIndexImplementationDirectory(DatabaseLayout directoryLayout) { return(LuceneDataSource.GetLuceneIndexStoreDirectory(directoryLayout)); }