Skip to content

Instantly share code, notes, and snippets.

@mbarker
mbarker / dedupe.java
Last active August 29, 2015 14:15
Aerospike Dedupe
public boolean isDuplicate(String id) {
Key key = new Key(namespace, set, id);
LOG.debug("Checking if seen: " + id);
// Check the record/bin a few times incase there is some write contention
int count = 0;
Boolean duplicate;
do {
duplicate = checkDuplicate(key);
} while (duplicate == null && count++ < RETRY_COUNT);
%macro calculateTotalCost(uninsuredAgeGroup1, uninsuredAgeGroup2, uninsuredAgeGroup3, uninsuredAgeGroup4, uninsuredAgeGroup5, uninsuredAgeGroup6, elec, blglu, renal, cbc, urin, pg, IV, stcx);
/*age grouping variable*/
if age < 18 then age_grp=1;
else if 18<=age<25 then age_grp=2;
else if 25<=age<35 then age_grp=3;
else if 35<=age<45 then age_grp=4;
else if 45<=age<=64 then age_grp=5;
else if age ge 65 then age_grp=6;