private void DisableFullTextIndex() { if (this._dataset is WebDemandDataset) { WebDemandDataset ds = (WebDemandDataset)this._dataset; if (ds.UnderlyingDataset is FullTextIndexedDataset) { this._dataset = ds.UnderlyingDataset; this.DisableFullTextIndex(); this._dataset = new WebDemandDataset(this._dataset); } } else if (this._dataset is FullTextIndexedDataset) { SparqlOptimiser.RemoveOptimiser(this._ftOptimiser); this._ftOptimiser = null; this._ftSearcher.Dispose(); this._ftSearcher = null; this._dataset = ((FullTextIndexedDataset)this._dataset).UnderlyingDataset; this._ftIndexer.Dispose(); this._ftIndexer = null; this._ftIndex.Dispose(); this._ftIndex = null; } this._processor = new LeviathanQueryProcessor(this._dataset); }
private void EnableFullTextIndex() { if (this._dataset is FullTextIndexedDataset) { //Nothing to do } else if (this._dataset is WebDemandDataset) { WebDemandDataset ds = (WebDemandDataset)this._dataset; this._dataset = ds.UnderlyingDataset; this.EnableFullTextIndex(); this._dataset = new WebDemandDataset(this._dataset); } else { //Create and ensure index ready for use this._ftIndex = new RAMDirectory(); var writer = new IndexWriter(this._ftIndex, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), IndexWriter.MaxFieldLength.UNLIMITED); writer.Dispose(); //Create Indexer and wrap dataset this._ftIndexer = new LuceneObjectsIndexer(this._ftIndex, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), new DefaultIndexSchema()); if (this._dataset is WebDemandDataset) { //Web Demand needs to go around Full Text as we want to index on demand loaded content this._dataset = new WebDemandDataset(new FullTextIndexedDataset(((WebDemandDataset)this._dataset).UnderlyingDataset, this._ftIndexer, true)); } else { this._dataset = new FullTextIndexedDataset(this._dataset, this._ftIndexer, true); } //Create and Register Optimizer this._ftSearcher = new LuceneSearchProvider(Lucene.Net.Util.Version.LUCENE_29, this._ftIndex); this._ftOptimiser = new FullTextOptimiser(this._ftSearcher); SparqlOptimiser.AddOptimiser(this._ftOptimiser); } this._processor = new LeviathanQueryProcessor(this._dataset); }
/// <summary> /// Tries to load a SPARQL Dataset based on information from the Configuration Graph /// </summary> /// <param name="g">Configuration Graph</param> /// <param name="objNode">Object Node</param> /// <param name="targetType">Target Type</param> /// <param name="obj">Output Object</param> /// <returns></returns> public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj) { obj = null; bool unionDefGraph = ConfigurationLoader.GetConfigurationBoolean(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyUnionDefaultGraph)), false); INode defaultGraphNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyDefaultGraphUri))); Uri defaultGraph = (defaultGraphNode != null && defaultGraphNode.NodeType == NodeType.Uri ? ((IUriNode)defaultGraphNode).Uri : null); INode storeNode; switch (targetType.FullName) { case InMemoryDataset: storeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyUsingStore))); if (storeNode == null) { obj = new InMemoryDataset(); } else { Object temp = ConfigurationLoader.LoadObject(g, storeNode); if (temp is IInMemoryQueryableStore) { if (unionDefGraph) { obj = new InMemoryDataset((IInMemoryQueryableStore)temp, unionDefGraph); } else if (defaultGraph != null) { obj = new InMemoryDataset((IInMemoryQueryableStore)temp, defaultGraph); } else { obj = new InMemoryDataset((IInMemoryQueryableStore)temp); } } else { throw new DotNetRdfConfigurationException("Unable to load the In-Memory Dataset identified by the Node '" + objNode.ToString() + "' since the Object pointed to by the dnr:usingStore property could not be loaded as an object which implements the IInMemoryQueryableStore interface"); } } break; case InMemoryQuadDataset: storeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyUsingStore))); if (storeNode == null) { obj = new InMemoryQuadDataset(); } else { Object temp = ConfigurationLoader.LoadObject(g, storeNode); if (temp is IInMemoryQueryableStore) { obj = new InMemoryQuadDataset((IInMemoryQueryableStore)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the In-Memory Dataset identified by the Node '" + objNode.ToString() + "' since the Object pointed to by the dnr:usingStore property could not be loaded as an object which implements the IInMemoryQueryableStore interface"); } } break; case WebDemandDataset: storeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyUsingDataset))); if (storeNode == null) { obj = new WebDemandDataset(new InMemoryQuadDataset()); } else { Object temp = ConfigurationLoader.LoadObject(g, storeNode); if (temp is ISparqlDataset) { obj = new WebDemandDataset((ISparqlDataset)temp); } else { throw new DotNetRdfConfigurationException("Unable to load the Web Demand Dataset identified by the Node '" + objNode.ToString() + "' since the Object pointed to by the dnr:usingDataset property could not be loaded as an object which implements the ISparqlDataset interface"); } } break; } return(obj != null); }