Still getting back into SQL … this is pretty neat:
// update hash in upstream edges
// SQLite does not have xor operator. a^b == (a & ~b) | (~a & b)
_, err = tx.Exec(`UPDATE edges SET hash = (hash & ~?) | (~hash & ?) WHERE down = ?`,
int64(hashUpdate), int64(hashUpdate), id)
In this case, I’m XOR’ing a hash update into the existing value of all upstream edges. This is pretty powerful in that you don’t need to load the data, modify it, and then write it back – SQL can do all that for you.