| 826 | } |
| 827 | |
| 828 | void DoDelete(ThreadState* thread, bool seq) { |
| 829 | RandomGenerator gen; |
| 830 | WriteBatch batch; |
| 831 | Status s; |
| 832 | for (int i = 0; i < num_; i += entries_per_batch_) { |
| 833 | batch.Clear(); |
| 834 | for (int j = 0; j < entries_per_batch_; j++) { |
| 835 | const int k = seq ? i + j : (thread->rand.Next() % FLAGS_num); |
| 836 | char key[100]; |
| 837 | snprintf(key, sizeof(key), "%016d", k); |
| 838 | batch.Delete(key); |
| 839 | thread->stats.FinishedSingleOp(); |
| 840 | } |
| 841 | s = db_->Write(write_options_, &batch); |
| 842 | if (!s.ok()) { |
| 843 | fprintf(stderr, "del error: %s\n", s.ToString().c_str()); |
| 844 | exit(1); |
| 845 | } |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | void DeleteSeq(ThreadState* thread) { DoDelete(thread, true); } |
| 850 | |