# This file simply merges DB.all.count with DB.all.meta

## DB.all.count is the aggregation DT produced from counting_i, or a similar file. 
##  I saved it to disk because the Query takes a long time to run on the DB. 
##  Thus we only rerun as needed
##
## DB.all.meta is the output of `getGenresForAllupcs`


## Ensure proper key for merging
setkeyIfNot(DB.all.meta, upc, verbose=FALSE)
setkeyIfNot(DB.all.count, upc, verbose=FALSE)

## Merge the two, then delete the originals
DB.all.countmeta <- merge(DB.all.count, DB.all.meta, all.x=TRUE)

# Back up
jesusForData(DB.all.countmeta, RDS=TRUE)


##  rm the original tables, we do not need them anymore
if (removeTablesAfterMerge)
	rm(DB.all.count, DB.all.meta)

