Deletions of Kiji table cells can be performed both within a MapReduce job and from non-distributed java programs. Both types of programs use KijiTableWriters to delete data.

Point Deletions

You realize one of your frenemies, Renuka Apte (any resemblance to real persons, living or dead, is purely coincidental), has somehow made it to your contact list. To remedy this we will perform a point deletion on the row with Renuka's contact information. To permit deletions from the phonebook, we will create a tool that will let us specify contacts that we want to delete.

DeleteEntry.java

DeleteEntry uses a KijiTableWriter to perform point deletions on a kiji table:

// Connect to the Kiji table and open a writer.
kiji = Kiji.Factory.open(KijiURI.newBuilder(mKijiUri).build(), getConf());
table = kiji.openTable(TABLE_NAME);
writer = table.openTableWriter();

The deletion is then performed by specifying the row ID for the entry, in this case a string of the format firstname,lastname:

// Create a row ID with the first and last name.
EntityId user = table.getEntityId(first + "," + last);

// Delete the row for the specified user.
writer.deleteRow(user);

Running the Example

This example interactively queries the user for the first and last names of the contact to delete. First, verify that the contact entry for Renuka Apte exists in your phonebook table:

$KIJI_HOME/bin/kiji get ${KIJI}/phonebook --entity-id="['Renuka,Apte']"
Looking up entity: ['Renuka,Apte'] from kiji table: kiji://localhost:2181/default/phonebook/
entity-id=['Renuka,Apte'] [1384235579766] info:firstname
                                 Renuka
entity-id=['Renuka,Apte'] [1384235579766] info:lastname
                                 Apte
entity-id=['Renuka,Apte'] [1384235579766] info:email
                                 ra@wibidata.com
entity-id=['Renuka,Apte'] [1384235579766] info:telephone
                                 415-111-2222
entity-id=['Renuka,Apte'] [1384235579766] info:address
                                 {"addr1": "375 Alabama St", "apt": null, "addr2": null, "city": "SF", "state": "CA", "zip": 94110}

Next, to perform the deletion of this contact using DeleteEntry:

$KIJI_HOME/bin/kiji jar \
    $KIJI_HOME/examples/phonebook/lib/kiji-phonebook-1.1.7.jar \
    org.kiji.examples.phonebook.DeleteEntry
First name: Renuka
Last name: Apte

Verify

To verify that the row has been deleted, run the following command ensuring that the phonebook entry for Renuka does not get printed:

$KIJI_HOME/bin/kiji get ${KIJI}/phonebook --entity-id="['Renuka,Apte']"
Looking up entity: ['Renuka,Apte'] from kiji table: kiji://localhost:2181/default/phonebook/

Wrapping up

If you started your BentoBox to do this tutorial, now would be a good time to stop it.

bento stop

To learn more about Kiji, check out these other resources: - User Guide - API Docs - Source Code

For information about the Kiji Project and user-to-user support: Sign up for user@kiji.org

Hungry for more? To learn about KijiMR, Kiji's MapReduce integration library, check out the Music recommendation tutorial.