@Test
  public void getSliceRespectsAllBoundsInclusionArguments() throws Exception {
    // Test case where endColumn=startColumn+1
    ByteBuffer key = KeyColumnValueStoreUtil.longToByteBuffer(0);
    ByteBuffer columnBeforeStart = KeyColumnValueStoreUtil.longToByteBuffer(776);
    ByteBuffer columnStart = KeyColumnValueStoreUtil.longToByteBuffer(777);
    ByteBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(778);
    ByteBuffer columnAfterEnd = KeyColumnValueStoreUtil.longToByteBuffer(779);

    // First insert four test Entries
    TransactionHandle txn = manager.beginTransaction();
    List<Entry> entries =
        Arrays.asList(
            new Entry(columnBeforeStart, columnBeforeStart),
            new Entry(columnStart, columnStart),
            new Entry(columnEnd, columnEnd),
            new Entry(columnAfterEnd, columnAfterEnd));
    store.mutate(key, entries, null, txn);
    txn.commit();

    // getSlice() with only start inclusive
    txn = manager.beginTransaction();
    List<Entry> result = store.getSlice(key, columnStart, columnEnd, txn);
    assertEquals(1, result.size());
    assertEquals(777, result.get(0).getColumn().getLong());
    txn.commit();
  }
 public void loadValues(String[][] values) {
   for (int i = 0; i < numKeys; i++) {
     List<Entry> entries = new ArrayList<Entry>();
     for (int j = 0; j < numColumns; j++) {
       entries.add(
           new Entry(KeyValueStoreUtil.getBuffer(j), KeyValueStoreUtil.getBuffer(values[i][j])));
     }
     store.mutate(KeyValueStoreUtil.getBuffer(i), entries, null, tx);
   }
 }
 public Set<Integer> deleteKeys(int every) {
   Set<Integer> removed = new HashSet<Integer>();
   for (int i = 0; i < numKeys; i++) {
     if (i % every == 0) {
       removed.add(i);
       List<ByteBuffer> deletions = new ArrayList<ByteBuffer>();
       for (int j = 0; j < numColumns; j++) {
         deletions.add(KeyValueStoreUtil.getBuffer(j));
       }
       store.mutate(KeyValueStoreUtil.getBuffer(i), null, deletions, tx);
     }
   }
   return removed;
 }
 public Set<KeyColumn> deleteValues(int every) {
   Set<KeyColumn> removed = new HashSet<KeyColumn>();
   int counter = 0;
   for (int i = 0; i < numKeys; i++) {
     List<ByteBuffer> deletions = new ArrayList<ByteBuffer>();
     for (int j = 0; j < numColumns; j++) {
       counter++;
       if (counter % every == 0) {
         // remove
         removed.add(new KeyColumn(i, j));
         deletions.add(KeyValueStoreUtil.getBuffer(j));
       }
     }
     store.mutate(KeyValueStoreUtil.getBuffer(i), null, deletions, tx);
   }
   return removed;
 }
  @Test
  public void getSliceRespectsColumnLimit() throws Exception {
    TransactionHandle txn = manager.beginTransaction();
    ByteBuffer key = KeyColumnValueStoreUtil.longToByteBuffer(0);

    final int cols = 1024;

    List<Entry> entries = new LinkedList<Entry>();
    for (int i = 0; i < cols; i++) {
      ByteBuffer col = KeyColumnValueStoreUtil.longToByteBuffer(i);
      entries.add(new Entry(col, col));
    }
    store.mutate(key, entries, null, txn);
    txn.commit();

    txn = manager.beginTransaction();
    ByteBuffer columnStart = KeyColumnValueStoreUtil.longToByteBuffer(0);
    ByteBuffer columnEnd = KeyColumnValueStoreUtil.longToByteBuffer(cols);
    /*
     * When limit is greater than or equal to the matching column count,
     * all matching columns must be returned.
     */
    List<Entry> result = store.getSlice(key, columnStart, columnEnd, cols, txn);
    assertEquals(cols, result.size());
    assertEquals(entries, result);
    result = store.getSlice(key, columnStart, columnEnd, cols + 10, txn);
    assertEquals(cols, result.size());
    assertEquals(entries, result);

    /*
     * When limit is less the matching column count, the columns up to the
     * limit (ordered bytewise) must be returned.
     */
    result = store.getSlice(key, columnStart, columnEnd, cols - 1, txn);
    assertEquals(cols - 1, result.size());
    entries.remove(entries.size() - 1);
    assertEquals(entries, result);
    result = store.getSlice(key, columnStart, columnEnd, 1, txn);
    assertEquals(1, result.size());
    List<Entry> firstEntrySingleton = Arrays.asList(entries.get(0));
    assertEquals(firstEntrySingleton, result);
    txn.commit();
  }