@SuppressWarnings("deprecation")
 @Override
 public MapJoinKey putRow(
     MapJoinObjectSerDeContext keyContext,
     Writable currentKey,
     MapJoinObjectSerDeContext valueContext,
     Writable currentValue)
     throws SerDeException {
   SerDe keySerde = keyContext.getSerDe(), valSerde = valueContext.getSerDe();
   if (writeHelper == null) {
     LOG.info(
         "Initializing container with "
             + keySerde.getClass().getName()
             + " and "
             + valSerde.getClass().getName());
     if (keySerde instanceof BinarySortableSerDe && valSerde instanceof LazyBinarySerDe) {
       LazyBinaryStructObjectInspector valSoi =
           (LazyBinaryStructObjectInspector) valSerde.getObjectInspector();
       writeHelper = new LazyBinaryKvWriter(keySerde, valSoi, valueContext.hasFilterTag());
       internalValueOi = valSoi;
       sortableSortOrders = ((BinarySortableSerDe) keySerde).getSortOrders();
     } else {
       writeHelper = new KeyValueWriter(keySerde, valSerde, valueContext.hasFilterTag());
       internalValueOi = createInternalOi(valueContext);
       sortableSortOrders = null;
     }
   }
   writeHelper.setKeyValue(currentKey, currentValue);
   hashMap.put(writeHelper, -1);
   return null; // there's no key to return
 }
示例#2
0
  @Test
  public void getPutCount() {
    String bucket = "bucket";
    HashMapCacheClient cache = new HashMapCacheClient();
    cache.addBucket(bucket);
    KeyValueHelper keyValueHelper = new KeyValueHelper();
    keyValueHelper.setKeyGenerator(new DefaultKeyGenerator());
    String[] keys = keyValueHelper.makeKeys(10, 64);
    List<byte[]> values = keyValueHelper.makeValues(keys, 1024);

    List<Double> ratios = Arrays.asList(1.0d, 5.0d);
    CacheWorker worker =
        new CacheWorker(cache, "gpc1", "getPutCount", bucket, 600, keys, values, ratios);
    worker.run();
    CacheStats stats = worker.getStats();

    assertTrue("puts", ChooserTest.withinPercent(stats.getNumPuts(), 100, 0.10));
    assertTrue("gets", ChooserTest.withinPercent(stats.getNumGets(), 500, .10));
    assertEquals("sum", 600, stats.getNumPuts() + stats.getNumGets());
  }