Limit the size of batched operations.

Clear and putAll are using a Writebatch. These will overflow on very
large collections.

Inserted an arbitrary limit (1000) on the batch size to preserve memory
and keep the application running even on very large sets.

Change-Id: Iaffb9a29e99a545d84ea34274543bf3c602a9a5d