コード例 #1
0
    @Override
    public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
      byte[] key = HTableFactory.getByteArray(parameters[1], inputKeyOI);

      if (key != null) {
        DeleteBuffer kvBuff = (DeleteBuffer) agg;
        kvBuff.addKey(key);
        if (kvBuff.deleteList.size() >= batchSize) {
          batchUpdate(kvBuff, false);
        }
      } else {
        getReporter().getCounter(BatchDeleteUDAFCounter.NULL_KEY_DELETE_FAILURE).increment(1);
      }
    }
コード例 #2
0
    @Override
    public void merge(AggregationBuffer agg, Object partial) throws HiveException {
      DeleteBuffer myagg = (DeleteBuffer) agg;
      List<Object> partialResult = (List<Object>) this.listKVOI.getList(partial);
      ListObjectInspector subListOI =
          (ListObjectInspector) listKVOI.getListElementObjectInspector();

      List first = subListOI.getList(partialResult.get(0));
      String tableName =
          ((StringObjectInspector) (subListOI.getListElementObjectInspector()))
              .getPrimitiveJavaObject(first.get(0));
      configMap.put(HTableFactory.TABLE_NAME_TAG, tableName);
      String zookeeper =
          ((StringObjectInspector) (subListOI.getListElementObjectInspector()))
              .getPrimitiveJavaObject(first.get(1));
      configMap.put(HTableFactory.ZOOKEEPER_QUORUM_TAG, zookeeper);

      //// Include arbitrary configurations, by adding strings of the form k=v
      for (int j = 4; j < first.size(); ++j) {
        String kvStr =
            ((StringObjectInspector) (subListOI.getListElementObjectInspector()))
                .getPrimitiveJavaObject(first.get(j));
        String[] kvArr = kvStr.split("=");
        if (kvArr.length == 2) {
          configMap.put(kvArr[0], kvArr[1]);
        }
      }

      for (int i = 1; i < partialResult.size(); ++i) {

        List kvList = subListOI.getList(partialResult.get(i));
        String key =
            ((StringObjectInspector) (subListOI.getListElementObjectInspector()))
                .getPrimitiveJavaObject(kvList.get(0));

        myagg.addKey(key.getBytes());
      }

      if (myagg.deleteList.size() >= batchSize) {
        batchUpdate(myagg, false);
      }
    }
コード例 #3
0
 @Override
 public void reset(AggregationBuffer buff) throws HiveException {
   DeleteBuffer deleteBuffer = (DeleteBuffer) buff;
   deleteBuffer.reset();
 }