示例#1
0
    static void ReadMoviesDirectors(MoviesDB moviesDB, string path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/movies_directors.csv");

        long msecs1 = Environment.TickCount;

        bool indexCreationTriggered = false;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int directorId = (int)reader.ReadLong();
            reader.Skip(';');
            int movieId = (int)reader.ReadLong();
            reader.SkipLine();

            moviesDB.AddMovieDirector(movieId, directorId);

            if (!indexCreationTriggered)
            {
                moviesDB.DirectorsOf(0);
                indexCreationTriggered = true;
            }
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#2
0
    static void ReadDirectors(MoviesDB moviesDB, string path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/directors.csv");

        long msecs1 = Environment.TickCount;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int id = (int)reader.ReadLong();
            reader.Skip(';');
            string firstName = reader.ReadString();
            reader.Skip(';');
            string lastName = reader.ReadString();
            reader.SkipLine();

            moviesDB.AddDirector(id, firstName, lastName);
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#3
0
    //////////////////////////////////////////////////////////////////////////////

    static void ReadMovies(MoviesDB moviesDB, string path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/movies.csv");

        long msecs1 = Environment.TickCount;

        string[] empty = new string[0];

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int id = (int)reader.ReadLong();
            reader.Skip(';');
            string name = reader.ReadString();
            reader.Skip(';');
            int year = (int)reader.ReadLong();
            reader.Skip(';');
            double rank = reader.ReadDouble();
            reader.SkipLine();

            moviesDB.AddMovie(id, name, year, rank, empty);
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#4
0
    static void ReadRoles(MoviesDB moviesDB, String path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/roles.csv");

        long msecs1 = Environment.TickCount;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int actorId = (int)reader.ReadLong();
            reader.Skip(';');
            int movieId = (int)reader.ReadLong();
            reader.Skip(';');
            String role = reader.ReadString();
            reader.SkipLine();

            moviesDB.AddRole(actorId, movieId, role);
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#5
0
    static void ReadActors(MoviesDB moviesDB, string path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/actors.csv");

        long msecs1 = Environment.TickCount;

        bool indexCreationTriggered = false;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int id = (int)reader.ReadLong();
            reader.Skip(';');
            string firstName = reader.ReadString();
            reader.Skip(';');
            string lastName = reader.ReadString();
            reader.Skip(';');
            string genderStr = reader.ReadString();
            reader.SkipLine();

            string gender;
            if (genderStr.Equals("M"))
            {
                gender = "male";
            }
            else if (genderStr.Equals("F"))
            {
                gender = "female";
            }
            else
            {
                throw new Exception();
            }

            moviesDB.AddActor(id, firstName, lastName, gender);

            if (!indexCreationTriggered)
            {
                moviesDB.ActorsByFirstName("...");
                moviesDB.ActorsByLastName("...");
                indexCreationTriggered = true;
            }
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#6
0
    static void ReadActors(MoviesDB moviesDB, String path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/actors.csv");

        long msecs1 = Environment.TickCount;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int id = (int)reader.ReadLong();
            reader.Skip(';');
            String firstName = reader.ReadString();
            reader.Skip(';');
            String lastName = reader.ReadString();
            reader.Skip(';');
            String genderStr = reader.ReadString();
            reader.SkipLine();

            Actor.Gender gender;
            if (genderStr.Equals("M"))
            {
                gender = Actor.Gender.male;
            }
            else if (genderStr.Equals("F"))
            {
                gender = Actor.Gender.female;
            }
            else
            {
                throw new Exception();
            }

            moviesDB.AddActor(id, firstName, lastName, gender);
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#7
0
    static void ReadRoles(MoviesDB moviesDB, string path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/roles.csv");

        long msecs1 = Environment.TickCount;

        bool indexCreationTriggered = false;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int actorId = (int)reader.ReadLong();
            reader.Skip(';');
            int movieId = (int)reader.ReadLong();
            reader.Skip(';');
            string role = reader.ReadString();
            reader.SkipLine();

            if (role.Length != 0)
            {
                moviesDB.AddMovieActor(movieId, actorId, role);
            }
            else
            {
                moviesDB.AddMovieActor(movieId, actorId);
            }

            if (!indexCreationTriggered)
            {
                moviesDB.Cast(0);
                indexCreationTriggered = true;
            }
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }
示例#8
0
    static void ReadMoviesGenres(MoviesDB moviesDB, string path, bool printSep, int width)
    {
        byte[] content = File.ReadAllBytes(path + "/movies_genres.csv");

        long msecs1 = Environment.TickCount;

        CsvReader reader = new CsvReader(content);

        reader.SkipLine();
        while (!reader.Eof())
        {
            int movieId = (int)reader.ReadLong();
            reader.Skip(';');
            string genre = reader.ReadString();
            reader.SkipLine();

            moviesDB.AddMovieGenre(movieId, genresMap[genre]);
        }

        long msecs2 = Environment.TickCount;

        PrintTime(msecs2 - msecs1, printSep, width);
    }