cs3843p2Fall2015BitMaps (70 pts)

advertisement
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
o read the query file (1 query per text line)
o show the query
o execute the query
o show the resulting bit map (%08X format code)
o 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
111000 Marcus Absent
111111 Bob Wire
111222 Anita Break
111333 Polly Merr
222000 Penn Head
222111 Candy Corn
222222 Jean E Us
222333 Holly Graph
222444 Lenny R Graph
222555 Sonny Street
Ed
HS
BACH
BACH
BACH
HS
BACH
DOC
MAST
BACH
HS
Age
20s
20s
20s
20s
30s
30s
30s
30s
30s
30s
Smoke Gender
YS
M
NS
M
NS
F
NS
F
YS
M
YS
F
NS
F
NS
F
NS
M
NS
M
333000
333111
333222
333333
333444
444000
444111
444222
555000
555111
555222
Pete Moss
Telly Scope
Penny Loafer
Carrie A Tune
Otto Graph
John Boat
Graham Merr
Cal Q Luss
Alan Wrench
Mac A Rownee
Jerry Tall
HS
BACH
NONE
MAST
DOC
HS
MAST
DOC
HS
BACH
HS
40s
40s
40s
40s
40s
50s
50s
50s
60s
60s
60s
YS
NS
NS
NS
NS
YS
NS
NS
YS
NS
YS
M
M
F
F
M
M
M
M
M
M
M
Ed
HS
HS
HS
HS
HS
HS
Age
20s
30s
30s
40s
50s
60s
Smoke Gender
YS
M
YS
M
NS
M
YS
M
YS
M
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
Id
111000
222000
222555
333000
444000
555000
00148611
Name
Marcus Absent
Penn Head
Sonny Street
Pete Moss
John Boat
Alan Wrench
555222 Jerry Tall
FFEB79EE
Name
Bob Wire
Anita Break
Polly Merr
Candy Corn
Jean E Us
Holly Graph
Lenny R Graph
Telly Scope
Penny Loafer
Carrie A Tune
Otto Graph
Graham Merr
Cal Q Luss
Mac A Rownee
NONE
00001000
Id
Name
333222 Penny Loafer
HS & YS
00148411
Id
Name
111000 Marcus Absent
222000 Penn Head
333000 Pete Moss
444000 John Boat
555000 Alan Wrench
555222 Jerry Tall
~ HS & ~ NONE
FFEB69EE
Id
Name
111111 Bob Wire
111222 Anita Break
111333 Polly Merr
222111 Candy Corn
222222 Jean E Us
222333 Holly Graph
222444 Lenny R Graph
333111 Telly Scope
333333 Carrie A Tune
333444 Otto Graph
444111 Graham Merr
444222 Cal Q Luss
555111 Mac A Rownee
HS
60s YS
M
Ed
BACH
BACH
BACH
BACH
DOC
MAST
BACH
BACH
NONE
MAST
DOC
MAST
DOC
BACH
Age
20s
20s
20s
30s
30s
30s
30s
40s
40s
40s
40s
50s
50s
60s
Ed
NONE
Age Smoke Gender
40s NS
F
Ed
HS
HS
HS
HS
HS
HS
Age
20s
30s
40s
50s
60s
60s
Smoke Gender
YS
M
YS
M
YS
M
YS
M
YS
M
YS
M
Ed
BACH
BACH
BACH
BACH
DOC
MAST
BACH
BACH
MAST
DOC
MAST
DOC
BACH
Age
20s
20s
20s
30s
30s
30s
30s
40s
40s
40s
50s
50s
60s
Smoke Gender
NS
M
NS
F
NS
F
YS
F
NS
F
NS
F
NS
M
NS
M
NS
F
NS
M
NS
M
NS
M
NS
M
~ HS
Id
111111
111222
111333
222111
222222
222333
222444
333111
333222
333333
333444
444111
444222
555111
Smoke Gender
NS
M
NS
F
NS
F
YS
F
NS
F
NS
F
NS
M
NS
M
NS
F
NS
F
NS
M
NS
M
NS
M
NS
M
Download