Пример #1
0
 public void checkKeys(Set<Integer> removed) {
   for (int i = 0; i < numKeys; i++) {
     if (removed.contains(i)) {
       assertFalse(store.containsKey(KeyValueStoreUtil.getBuffer(i), tx));
     } else {
       assertTrue(store.containsKey(KeyValueStoreUtil.getBuffer(i), tx));
     }
   }
 }
Пример #2
0
 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);
   }
 }
Пример #3
0
 public void checkValues(String[][] values, Set<KeyColumn> removed) {
   for (int i = 0; i < numKeys; i++) {
     for (int j = 0; j < numColumns; j++) {
       ByteBuffer result =
           store.get(KeyValueStoreUtil.getBuffer(i), KeyValueStoreUtil.getBuffer(j), tx);
       if (removed.contains(new KeyColumn(i, j))) {
         assertNull(result);
       } else {
         Assert.assertEquals(values[i][j], KeyValueStoreUtil.getString(result));
       }
     }
   }
 }
Пример #4
0
 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;
 }
Пример #5
0
 public void checkValueExistence(String[][] values, Set<KeyColumn> removed) {
   for (int i = 0; i < numKeys; i++) {
     for (int j = 0; j < numColumns; j++) {
       boolean result =
           store.containsKeyColumn(
               KeyValueStoreUtil.getBuffer(i), KeyValueStoreUtil.getBuffer(j), tx);
       if (removed.contains(new KeyColumn(i, j))) {
         assertFalse(result);
       } else {
         assertTrue(result);
       }
     }
   }
 }
Пример #6
0
 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;
 }
Пример #7
0
  public void checkSlice(
      String[][] values, Set<KeyColumn> removed, int key, int start, int end, int limit) {
    List<Entry> entries;
    if (limit <= 0)
      entries =
          store.getSlice(
              KeyValueStoreUtil.getBuffer(key),
              KeyValueStoreUtil.getBuffer(start),
              KeyValueStoreUtil.getBuffer(end),
              tx);
    else
      entries =
          store.getSlice(
              KeyValueStoreUtil.getBuffer(key),
              KeyValueStoreUtil.getBuffer(start),
              KeyValueStoreUtil.getBuffer(end),
              limit,
              tx);

    int pos = 0;
    for (int i = start; i < end; i++) {
      if (removed.contains(new KeyColumn(key, i))) continue;
      if (limit <= 0 || pos < limit) {
        Entry entry = entries.get(pos);
        int col = KeyValueStoreUtil.getID(entry.getColumn());
        String str = KeyValueStoreUtil.getString(entry.getValue());
        assertEquals(i, col);
        assertEquals(values[key][i], str);
      }
      pos++;
    }
    assertNotNull(entries);
    if (limit > 0 && pos > limit) assertEquals(limit, entries.size());
    else assertEquals(pos, entries.size());
  }