MCPcopy
hub / github.com/OpenTSDB/opentsdb / setupValues

Method setupValues

test/core/TestSaltScanner.java:490–555  ·  view source on GitHub ↗

This method sets up some row keys and values to pass to the scanners. The values aren't exactly what would normally be passed to a salt scanner in that we have the same series salted across separate buckets. That would only happen if you add the timestamp to the salt calculation, which we may do in

()

Source from the content-addressed store, hash-verified

488 * may do in the future. We're testing now for future proofing.
489 */
490 protected void setupValues() throws Exception {
491 setDataPointStorage();
492 kvs_a = new ArrayList<ArrayList<ArrayList<KeyValue>>>(3);
493 kvs_b = new ArrayList<ArrayList<ArrayList<KeyValue>>>(2);
494
495 final String note = "{\"tsuid\":\"000001000001000001\","
496 + "\"startTime\":1356998490,\"endTime\":0,\"description\":"
497 + "\"The Great A'Tuin!\",\"notes\":\"Millenium hand and shrimp\","
498 + "\"custom\":null}";
499
500 for (int i = 0; i < 5; i++) {
501 final ArrayList<ArrayList<KeyValue>> rows =
502 new ArrayList<ArrayList<KeyValue>>(1);
503 final ArrayList<KeyValue> row = new ArrayList<KeyValue>(2);
504 rows.add(row);
505 byte[] key = null;
506
507 switch (i) {
508 case 0:
509 row.add(new KeyValue(KEY_A, FAMILY, QUALIFIER_A, 0, VALUE));
510 kvs_a.add(rows);
511 break;
512 case 1:
513 row.add(new KeyValue(KEY_B, FAMILY, QUALIFIER_A, 0, VALUE));
514 kvs_a.add(rows);
515 break;
516 case 2:
517 row.add(new KeyValue(KEY_C, FAMILY, QUALIFIER_A, 0, VALUE));
518 kvs_a.add(rows);
519 break;
520 case 3:
521 key = Arrays.copyOf(KEY_A, KEY_A.length);
522 row.add(new KeyValue(key, FAMILY, QUALIFIER_B, 0, VALUE));
523 row.add(new KeyValue(key, FAMILY, new byte[] { 1, 0, 0 }, 0,
524 note.getBytes(Charset.forName("UTF8"))));
525 kvs_b.add(rows);
526 break;
527 case 4:
528 key = Arrays.copyOf(KEY_C, KEY_C.length);
529 row.add(new KeyValue(key, FAMILY, QUALIFIER_B, 0, VALUE));
530 kvs_b.add(rows);
531 break;
532 }
533 }
534
535 if (Const.SALT_WIDTH() > 0) {
536 when(scanner_a.nextRows())
537 .thenReturn(Deferred.fromResult(kvs_a.get(0)))
538 .thenReturn(Deferred.fromResult(kvs_a.get(1)))
539 .thenReturn(Deferred.fromResult(kvs_a.get(2)))
540 .thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(null));
541
542 when(scanner_b.nextRows())
543 .thenReturn(Deferred.fromResult(kvs_b.get(0)))
544 .thenReturn(Deferred.fromResult(kvs_b.get(1)))
545 .thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(null));
546 } else {
547 when(scanner_a.nextRows())

Callers 1

setupMockScannersMethod · 0.95

Calls 5

SALT_WIDTHMethod · 0.95
setDataPointStorageMethod · 0.80
addMethod · 0.45
getBytesMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected