Write a program to sort back into a single file

Assignment Help Database Management System
Reference no: EM13320876

Parallel Sort

In this assignment you will be subjected to a 100% completely realistic scenario. Somebody borked our database and now the records are all chopped up and out of order. So now it's YOUR job to clean up this mess and write a program to sort these back into a single file. Oh, and we only have a few nanoseconds to do it, so you'd better do it with pthreads!

 

As input, you will receive an arbitrary number of ASCII text files with arbitrary file names. These files will all be located in a directory specified on the command line. You are given a set of sample data with which to test your program.

Your program should obtain a list of the files in a given directory and then use that to go about its business.

Each data file will have a number of records that look like the following:

<username>,<password><blood type>,<domain name>,<database index>
You may read these in with any file manipulation function that you see fit (fgets() works quite nicely). You should split these on commas and use atoi() on the database index before sticking them into a struct.

The end result will be an array of these structs to be sorted.

Parallelism

Each file should be handled in parallel. This means that you will list the supplied directory and then spin up a separate thread for each file contained therein.

All file manipulation functions and sorting will take place in the thread allotted for that file.

Sorting

You can write your own sort if you'd like, but since that's not relevant to the assignment, you can go ahead and use the qsort() function in the standard library. You will be sorting by the last field in each record, the database id. The result should be in ascending order.

Note that this function takes a function pointer as an argument. This is a pointer to another function in memory which is used to compare elements in the array. You will learn more about how this works in class.

Makefile

Your makefile should produce an executable which takes one argument (a directory path) and performs a sort on the files located in that directory. Make sure that you are processing this argument in a fashion that finds the directory relative to the current working directory. (e.g., if you execute ./coolsort "./nested/directory/structure", everything in the subdirectory "structure" should be sorted).

Output

The output should be a single ASCII file called sorted.yay containing all of the records from each individual data file in sorted order.


Attachment:- data.rar

Reference no: EM13320876

Questions Cloud

What is the ph of a buffer : What is the ph of a buffer that results when .40 mol nahco2 is mixed with 100 ml of 2.0 m hcl and diluted with water to 250 ml
Find the total work done by the gas in one cycle : Two moles of an ideal monoatomic gas undergo a cyclic process starting from state A at a vol. of 1L and a pressure of 2 atm. Find the total work done by the gas in one cycle
What is the position of the block : A 2.00 kg. frictionless block is attached to an ideal spring with force constant 300 n/m. At t=0 the block has velocity -4.0 m/s, what is the position of the block when its speed is 2.5 m/s
What is the difference in water levels between reservoirs : A wrought iron water line connecting two reservoirs at 20°C has a length of 1500 m, a diameter of 75 cm, two elbows (90º, long-radius, flanged), a fully open gate valve, and a reentrant pipe entrance.
Write a program to sort back into a single file : Write a program to sort these back into a single file. Oh, and we only have a few nanoseconds to do it, so you'd better do it with pthreads!
Determine the inductance of a solenoid : Calculate the inductance of a solenoid with 275 turns if the length of the solenoid is 30 cm and its radius is 2.5 cm
Find the total axial deformation-strain of the column : A 14-in. square concrete post is 6ft tall and reinforced by nine 3/4" diameter steel rods. Assume that the materials are high-strength concrete and ASTM-A36 structural steel.
Four primary types of local area networks–contention bus, : Discuss the advantages and disadvantages of the four primary types of local area networks–contention bus, token bus, token ring, and wireless.
Find the velocity and acceleration of a particle of fluid : A two-dimensional flow field is given by u=2+xy+3t^2, v=2xy^2+t. Find the velocity and acceleration of a particle of fluid at point (2,3) at t=4. Specify units in terms of L and T.

Reviews

Write a Review

Database Management System Questions & Answers

  Discuss the formula for computing entropy

The paper must discuss the relationship of Entropy to the likelihood that an attack can be successful, the formula for computing Entropy.

  Convert er diagram into relational schema

Suppose we are to design a registrar's database to store information about students, courses, the courses students have taken. Convert the E/R diagram into a relational schema.

  Compose conceptual data modeling techniques

Prepare database design documents using the data definition, data manipulation, and data control language components of the SQL language.

  Describe product characteristics and deliverables

Develop a scope statement for the project and describe product characteristics and deliverables.

  Changes require to make-premiere products database

Point out the changes you require to make to Premiere Products database to support following situation: A customer is not necessarily represented by a single sales rep but can be represented by several reps.

  Data dictionary serves as important data management tool

The data dictionary serves as an important data management tool by? assigning attributes to the data, maintaining data in updated form.

  Diagram and determine the possible iterative steps

Determine the steps in the development of an effective Entity Relationship Model (ERM) Diagram and determine the possible iterative steps / factors that one must consider in this process with consideration of the HR core functions and responsibili..

  Access values through queries to databases

However, the only way you can access values is through queries to the databases. In single query, you can specify value k to one of two databases.

  Design a database for an insurance company

Don't forget to underline key attributes for entity sets and include arrowheads indicating the multiplicity of relationships

  Write problems and issues related with internet databases

Write down some of problems and issues related with internet databases? Consider security, performance, architecture issues.

  The packing list describes the ideal contents

The packing list describes the ideal contents of each package, but it is not always possible to include the ideal number of each item. Therefore, the actual items included in each package should be tracked. A package can contain many different ite..

  What are the main activities that the business undertakes

What are the main activities that the business undertakes and where in the business are the crucial decisions made?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd