Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Processing a huge text file (lots of strings)

Discussion in 'Entity Component System' started by AnthonyReddan, Jul 11, 2020.

  1. AnthonyReddan

    AnthonyReddan

    Joined:
    Feb 27, 2018
    Posts:
    39
    I have some existing C# code that imports a word list text file (via ScriptedImporter) and does a huge amount of processing on each word (line by line) and converts the whole list into a tightly packed Gaddag.

    I was jobifying the runtime side of this project, and decided I'd like to make this import faster (can take up to 30s for larger lists, currently).

    I'm trying to figure out the best way to convert the initial string data from the file into data for the jobs (I'd have parallel jobs processing each word).

    I was thinking a NativeArray<FixedString32> from the string[] File.ReadLines - but this is somewhat cumbersome to populate (can't just memcpy, have to iterate) to do this.

    Another way might be to read the file contents into several Words 4096 characters at a time? Each job would have to process whole words only so I'm not sure how I'd ensure I'm not cutting a word off in the middle.

    Any other way to get a massive string (File.ReadAllText) or string[] (File.ReadLines) into a job friendly format?
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    944
    Blob asset rerefence with a bolb string ?
    I assume you don't change the file content just read it and populate your Gaddag?
     
    MNNoxMortem likes this.
  3. AnthonyReddan

    AnthonyReddan

    Joined:
    Feb 27, 2018
    Posts:
    39
    Exactly this! Thank you, I was only looking in the
    Unity.Collections
    namespace and didn't realise this existed. I'll give that a go