Beispiel #1
0
        /* //Static bits for singulton
         * static FileWritingThread ThreadController; */


        public FileWritingThread(IWindowWithProgress toUpdate)
        {
            ThreadPool.SetMaxThreads(16, 16);
            moreToAdd      = true;
            toWrite        = new List <ThreadWrittenGraph>();
            windowToUpdate = toUpdate;
            ThreadStart controlThreadStart = new ThreadStart(this.writeFilesAsNeeded);

            controlThread              = new Thread(controlThreadStart);
            controlThread.Name         = "File writing control thread";
            controlThread.IsBackground = true;
        }
Beispiel #2
0
        public virtual IGraph ParseFile(string fName, ProvInfo prov, IFileController fileController, IGraph startingGraph, out List <Exception> Errors,
                                        IWindowWithProgress toUpdate, string outputFormat)
        {
            IUriNode provAction = null;

            if (prov != null)
            {
                provAction = addProvenance(ref startingGraph, prov.Aurthor, prov.AurthorIsUri);
            }
            ParseFileDetail(fName, ref startingGraph, provAction, fileController, out Errors, toUpdate, outputFormat);
            return(startingGraph);
        }
Beispiel #3
0
        protected virtual void ParseFileDetail(string fName, ref IGraph targetGraph, IUriNode provAction, IFileController fileController, out List <Exception> Errors, IWindowWithProgress toUpdate, string outputFormat)
        {
            FileWritingThread writer = new FileWritingThread(toUpdate);

            using (MemoryStream memStream = new MemoryStream(File.ReadAllBytes(fName))) //Do the processing in Memory for speedier access
                using (StreamReader sr = new StreamReader(memStream))
                {
                    if (!sr.EndOfStream)
                    {
                        toUpdate.DisplayMessage("Loading in to memory");
                        fileController.ProcessHeader(sr, ref targetGraph, provAction, fName);
                    }
                    toUpdate.DisplayMessage("Converting Items");
                    IEnumerable <IImportedItem> parsedElments = fileController.ConvertItems(sr, out Errors);
                    writer.Start();

                    long nElements             = parsedElments.LongCount();
                    long elmentNumber          = 0;
                    List <IImportedItem> chunk = new List <IImportedItem>();
                    foreach (IImportedItem element in parsedElments)
                    {
                        chunk.Add(element);
                        elmentNumber++;
                        if (elmentNumber % saveFreq == 0)
                        {
                            List <IImportedItem> copied = new List <IImportedItem>();
                            copied.AddRange(chunk);
                            chunk.Clear();
                            lock (fNumberLock)
                            {
                                fNumber++;
                            }
                            //Putting this bit in the critical section makes it way slower *and* doesn't solve the filenumber repeating problem
                            ThreadWrittenGraph toSave = new ThreadWrittenGraph(outputFormat, copied, fNumber);
                            writer.AddFileToWrite(toSave);
                        }
                    }
                    writer.Stop();
                }
        }
Beispiel #4
0
        public virtual IGraph ParseFile(string fName, ProvInfo prov, IFileController fileController, out List <Exception> Errors, IWindowWithProgress toUpdate, string outputFormat)
        {
            IGraph targetGraph = new Graph();

            targetGraph.BaseUri = UriFactory.Create(Properties.Settings.Default.StationGraphBase);
            ontovis.Util.AddNamesSpaces(targetGraph);
            return(ParseFile(fName, prov, fileController, targetGraph, out Errors, toUpdate, outputFormat));
        }