1 8 9 package com.sleepycat.collections.test; 10 11 import com.sleepycat.bind.RecordNumberBinding; 12 import com.sleepycat.collections.PrimaryKeyAssigner; 13 import com.sleepycat.je.DatabaseEntry; 14 import com.sleepycat.je.DatabaseException; 15 16 19 class TestKeyAssigner implements PrimaryKeyAssigner { 20 21 private byte next = 1; 22 private boolean isRecNum; 23 24 TestKeyAssigner(boolean isRecNum) { 25 26 this.isRecNum = isRecNum; 27 } 28 29 public void assignKey(DatabaseEntry keyData) 30 throws DatabaseException { 31 32 if (isRecNum) { 33 RecordNumberBinding.recordNumberToEntry(next, keyData); 34 } else { 35 keyData.setData(new byte[] { next }, 0, 1); 36 } 37 next += 1; 38 } 39 40 void reset() { 41 42 next = 1; 43 } 44 } 45 | Popular Tags |