}
@Override
public DatasetWriter<E> newWriter() {
final DatasetWriter<E> wrappedWriter = dataset.getDao().newBatch();
final StorageKey partitionStratKey = new StorageKey(dataset.getDescriptor().getPartitionStrategy());
// Return a dataset writer that checks on write that an entity is within the
// range of the view
return new DatasetWriter<E>() {
@Override
public void open() {
wrappedWriter.open();
}
@Override
public void write(E entity) {
StorageKey key = partitionStratKey.reuseFor(entity);
if (!range.contains(key)) {
throw new IllegalArgumentException("View does not contain entity: "
+ entity);
}
wrappedWriter.write(entity);