Add a 'Contains(key)' to the API for the Txn and DB objects

To facilitate better answering of questions, if you have a question, please fill in the following info. Otherwise, please delete the template.

What I want to do

I’d like to see if there’s already a patch / branch that does this. In our case, we have to use ‘Get’ on the Txn object to determine if a key value is present. Then, if it isn’t, we serialize an object to a byte array, and then call ‘Set()’ to add it to the datastore. Calling ‘Set()’ right away might lead to serializing (a cpu-intensive task) for no reason.

I’d like to: 1) use an existing patch with this type of feature, or 2) create a branch to do this.

I have millions of records to insert, so doing a lookup twice for each key is very intensive: first the ‘Get()’ and then the ‘Set()’. Rather, I’d like to either use something like ‘Contains()’ instead of ‘Get()’, or make a function that executes a callback to do the serialization if the key doesn’t exist already.

Ideally, the batchSet() operation makes the most sense, for performance, so that would definitely be considered.

What I did

I’ve searched to see if anyone already did this, but I don’t see it anywhere.

Dgraph metadata

dgraph version

We’re using ‘v2’