cs3843p2Fall2015BitMaps (70 pts)

You will use C to populate customer bit maps and execute queries that use those bit maps. Please see cs3843p2.h.

Input Data

p2Customer.txt - contains customer data and is read by getCustomerData which I have provided.

p2Query.txt - contains queries (one query per text line). Each token is separated by a space. You will need to read this.

Driver

I have provided a program driver, cs3843p2Driver.c, to help reduce your coding effort. It provides the following functions:

  • main - calls many of the other functions
  • processCommandSwitches - interprets the "-q" and "-c" command switches and returns the file names
  • newCustomerData - allocates a new CustomerDataImp structure and initializes it, returning CustomerData which is a pointer to a CustomerDataImp.
  • getCustomerData - reads the customer file (specified by the -c command argument switch) and populates the customer array within CustomerData
  • showAllCustomers - prints the list of customers from CustomerData
  • findNamedBitMap- finds a named bit map in the bitMapM array from CustomerData
  • getSimpleToken - gets a token and should be used by your executeQueries
  • exitError - exits the program
  • exitUage - prints usage information and exits the program

Macros

I also provided two macros (in the include file) - setBit and getBit

You must code

You will construct the following list of functions. Note that you will probably add additional functions to aid in modularity.

  • populateBitMaps - based on the data already in the customer array, this populates the bit maps
  • showBitMaps - shows the bit maps (%08X format code) that are in the bitMapM array
  • executeQueries- executes each of the queries and shows the results

Bit Maps

You will have 14 bit maps:

Education: NONE, HS, BACH, MAST, DOC

Age Group: 20S, 30S, 40S, 50S, 60s

Smoking: SY, SN

Gender: M, F

Queries

  • Within the executeQueries function, you must
  • read the query file (1 query per text line)
  • show the query
  • execute the query
  • show the resulting bit map (%08X format code)
  • show customers (each customer attribute) who are in that resulting bit map.
  • Note that the queries will contain at most one & or |, but each of the operands can be bit-wise not (~). This means you don't have to use a more complicated stack-based approach. Some examples:

HS

~ HS

NONE

HS & YS

~ HS & ~ NONE

40s & F

~ 40s & F

M & 50s

M & ~ 50s

Notes

  1. Your code must be written according to my programming standards.
  2. I have provided input files, an include file, and a driver.
  3. Turn in all your C code and the generated output.

Some Sample Output

Customers

Id Name Ed Age Smoke Gender

111000 Marcus Absent HS 20s YS M

111111 Bob Wire BACH 20s NS M

111222 Anita Break BACH 20s NS F

111333 Polly Merr BACH 20s NS F

222000 Penn Head HS 30s YS M

222111 Candy Corn BACH 30s YS F

222222 Jean E Us DOC 30s NS F

222333 Holly Graph MAST 30s NS F

222444 Lenny R Graph BACH 30s NS M

222555 Sonny Street HS 30s NS M

333000 Pete Moss HS 40s YS M

333111 Telly Scope BACH 40s NS M

333222 Penny Loafer NONE 40s NS F

333333 Carrie A Tune MAST 40s NS F

333444 Otto Graph DOC 40s NS M

444000 John Boat HS 50s YS M

444111 Graham Merr MAST 50s NS M

444222 Cal Q Luss DOC 50s NS M

555000 Alan Wrench HS 60s YS M

555111 Mac A Rownee BACH 60s NS M

555222 Jerry Tall HS 60s YS M

Education Bit Maps

NON 00001000

HS 00148611

BAC 0008092E

MAS 00012080

DOC 00024040

Age Group Bit Maps

20s 0000000F

30s 000003F0

40s 00007C00

50s 00038000

60s 001C0000

Smoking Bit Maps

NS 000B7BCE

YS 00148431

Gender Bit Maps

M 001FCF13

F 000030EC

Queries:

HS 00148611

Id Name Ed Age Smoke Gender

111000 Marcus Absent HS 20s YS M

222000 Penn Head HS 30s YS M

222555 Sonny Street HS 30s NS M

333000 Pete Moss HS 40s YS M

444000 John Boat HS 50s YS M

555000 Alan Wrench HS 60s YS M

555222 Jerry Tall HS 60s YS M

~ HS FFEB79EE

Id Name Ed Age Smoke Gender

111111 Bob Wire BACH 20s NS M

111222 Anita Break BACH 20s NS F

111333 Polly Merr BACH 20s NS F

222111 Candy Corn BACH 30s YS F

222222 Jean E Us DOC 30s NS F

222333 Holly Graph MAST 30s NS F

222444 Lenny R Graph BACH 30s NS M

333111 Telly Scope BACH 40s NS M

333222 Penny Loafer NONE 40s NS F

333333 Carrie A Tune MAST 40s NS F

333444 Otto Graph DOC 40s NS M

444111 Graham Merr MAST 50s NS M

444222 Cal Q Luss DOC 50s NS M

555111 Mac A Rownee BACH 60s NS M

NONE 00001000

Id Name Ed Age Smoke Gender

333222 Penny Loafer NONE 40s NS F

HS & YS 00148411

Id Name Ed Age Smoke Gender

111000 Marcus Absent HS 20s YS M

222000 Penn Head HS 30s YS M

333000 Pete Moss HS 40s YS M

444000 John Boat HS 50s YS M

555000 Alan Wrench HS 60s YS M

555222 Jerry Tall HS 60s YS M

~ HS & ~ NONE FFEB69EE

Id Name Ed Age Smoke Gender

111111 Bob Wire BACH 20s NS M

111222 Anita Break BACH 20s NS F

111333 Polly Merr BACH 20s NS F

222111 Candy Corn BACH 30s YS F

222222 Jean E Us DOC 30s NS F

222333 Holly Graph MAST 30s NS F

222444 Lenny R Graph BACH 30s NS M

333111 Telly Scope BACH 40s NS M

333333 Carrie A Tune MAST 40s NS F

333444 Otto Graph DOC 40s NS M

444111 Graham Merr MAST 50s NS M

444222 Cal Q Luss DOC 50s NS M

555111 Mac A Rownee BACH 60s NS M