/// <summary> /// Saves the given Triple Store to the Target Store that this class was instantiated with /// </summary> /// <param name="store">Store to Save</param> /// <param name="parameters">Parameters for the Store</param> public override void Save(ITripleStore store, IStoreParams parameters) { if (parameters is ThreadedSqlIOParams) { //Setup context ThreadedSqlStoreWriterContext context = new ThreadedSqlStoreWriterContext(store, (ThreadedSqlIOParams)parameters); bool transSetting = context.Manager.DisableTransactions; context.Manager.DisableTransactions = true; //Queue Graphs for Writing foreach (IGraph g in store.Graphs) { context.Add(g); } //Start making the async calls List <IAsyncResult> results = new List <IAsyncResult>(); WriteGraphsDelegate d = new WriteGraphsDelegate(this.WriteGraphs); for (int i = 0; i < context.Threads; i++) { results.Add(d.BeginInvoke(context, null, null)); } //Wait for all the async calls to complete WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray()); RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("Folder Store")); foreach (IAsyncResult result in results) { try { d.EndInvoke(result); } catch (Exception ex) { outputEx.AddException(ex); } } //Reset Transactions setting context.Manager.DisableTransactions = transSetting; //If there were any errors we'll throw an RdfThreadedOutputException now if (outputEx.InnerExceptions.Any()) { throw outputEx; } } else { throw new RdfStorageException("Parameters for the ThreadedSQLStoreWriter must be of type ThreadedSQLIOParams"); } }
/// <summary> /// Saves the given Triple Store to an arbitrary store /// </summary> /// <param name="store">Store to Save</param> /// <param name="parameters">Parameters for the Store</param> /// <remarks> /// Parameters must be of type <see cref="GenericIOParams">GenericIOParams</see> /// </remarks> public void Save(ITripleStore store, IStoreParams parameters) { if (parameters is GenericIOParams) { //Create the Writer Context GenericStoreWriterContext context = new GenericStoreWriterContext(store, (GenericIOParams)parameters); //Queue Graphs for Writing foreach (IGraph g in store.Graphs) { context.Add(g.BaseUri); } //Start making the async calls List <IAsyncResult> results = new List <IAsyncResult>(); WriteGraphsDelegate d = new WriteGraphsDelegate(this.WriteGraphs); for (int i = 0; i < context.Threads; i++) { results.Add(d.BeginInvoke(context, null, null)); } //Wait for all the async calls to complete WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray()); RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("TSV")); foreach (IAsyncResult result in results) { try { d.EndInvoke(result); } catch (Exception ex) { outputEx.AddException(ex); } } //If there were any errors we'll throw an RdfThreadedOutputException now if (outputEx.InnerExceptions.Any()) { throw outputEx; } } else { throw new RdfStorageException("Parameters for the GenericStoreWriter must be of type GenericIOParams"); } }
/// <summary> /// Saves the given Triple Store to an arbitrary store /// </summary> /// <param name="store">Store to Save</param> /// <param name="parameters">Parameters for the Store</param> /// <remarks> /// Parameters must be of type <see cref="GenericIOParams">GenericIOParams</see> /// </remarks> public void Save(ITripleStore store, IStoreParams parameters) { if (parameters is GenericIOParams) { //Create the Writer Context GenericStoreWriterContext context = new GenericStoreWriterContext(store, (GenericIOParams)parameters); //Queue Graphs for Writing foreach (IGraph g in store.Graphs) { context.Add(g.BaseUri); } //Start making the async calls List<IAsyncResult> results = new List<IAsyncResult>(); WriteGraphsDelegate d = new WriteGraphsDelegate(this.WriteGraphs); for (int i = 0; i < context.Threads; i++) { results.Add(d.BeginInvoke(context, null, null)); } //Wait for all the async calls to complete WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray()); RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("TSV")); foreach (IAsyncResult result in results) { try { d.EndInvoke(result); } catch (Exception ex) { outputEx.AddException(ex); } } //If there were any errors we'll throw an RdfThreadedOutputException now if (outputEx.InnerExceptions.Any()) throw outputEx; } else { throw new RdfStorageException("Parameters for the GenericStoreWriter must be of type GenericIOParams"); } }
/// <summary> /// Saves the given Triple Store to the Target Store that this class was instantiated with /// </summary> /// <param name="store">Store to Save</param> /// <param name="parameters">Parameters for the Store</param> public override void Save(ITripleStore store, IStoreParams parameters) { if (parameters is ThreadedSqlIOParams) { //Setup context ThreadedSqlStoreWriterContext context = new ThreadedSqlStoreWriterContext(store, (ThreadedSqlIOParams)parameters); bool transSetting = context.Manager.DisableTransactions; context.Manager.DisableTransactions = true; //Queue Graphs for Writing foreach (IGraph g in store.Graphs) { context.Add(g); } //Start making the async calls List<IAsyncResult> results = new List<IAsyncResult>(); WriteGraphsDelegate d = new WriteGraphsDelegate(this.WriteGraphs); for (int i = 0; i < context.Threads; i++) { results.Add(d.BeginInvoke(context, null, null)); } //Wait for all the async calls to complete WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray()); RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("Folder Store")); foreach (IAsyncResult result in results) { try { d.EndInvoke(result); } catch (Exception ex) { outputEx.AddException(ex); } } //Reset Transactions setting context.Manager.DisableTransactions = transSetting; //If there were any errors we'll throw an RdfThreadedOutputException now if (outputEx.InnerExceptions.Any()) throw outputEx; } else { throw new RdfStorageException("Parameters for the ThreadedSQLStoreWriter must be of type ThreadedSQLIOParams"); } }