コード例 #1
0
 @Override
 public void init(
     ExecMapperContext context,
     MapredContext mrContext,
     Configuration hconf,
     MapJoinOperator joinOp) {
   this.tezContext = (TezContext) mrContext;
   this.hconf = hconf;
   this.desc = joinOp.getConf();
 }
コード例 #2
0
ファイル: MapJoinObjectKey.java プロジェクト: uclaabs/absHive
  @Override
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    try {
      // get the tableDesc from the map stored in the mapjoin operator
      HashTableSinkObjectCtx ctx = MapJoinOperator.getMetadata().get(Integer.valueOf(metadataTag));

      Writable val = ctx.getSerDe().getSerializedClass().newInstance();
      val.readFields(in);
      ArrayList<Object> list =
          (ArrayList<Object>)
              ObjectInspectorUtils.copyToStandardObject(
                  ctx.getSerDe().deserialize(val),
                  ctx.getSerDe().getObjectInspector(),
                  ObjectInspectorCopyOption.WRITABLE);
      if (list == null) {
        obj = new ArrayList(0).toArray();
      } else {
        obj = list.toArray();
      }

    } catch (Exception e) {
      throw new IOException(e);
    }
  }
コード例 #3
0
  private void output(Serializable work) {

    if (work == null) return;

    // Check if work has an explain annotation
    Annotation note = work.getClass().getAnnotation(Explain.class);
    // if (note == null) return;

    if (note instanceof Explain) {
      Explain xpl_note = (Explain) note;
      out.println(xpl_note.displayName());
    }

    out.println(work.getClass());
    // If this is an operator then we need to call the plan generation on conf and then the children
    if (work instanceof Operator) {

      /** explain only in Driver #execute optimize(generate alias map) in Driver #compile */
      if (work instanceof MapJoinOperator) {
        // map join tables
        MapJoinOperator c = (MapJoinOperator) work;
        // out.println("Join" + (c.getColumnExprMap()));
        // out.println(c.get);

        // desc not contains useful infos

        MapJoinDesc desc = c.getConf();
        // out.println(desc.getKeyTableDesc());

        // out.println(desc.getKeys()); //0 1
        // out.println(desc.getRetainList());
        out.println(desc.getExprs());
        // out.println(desc.getAliasBucketFileNameMapping()); null
        // out.println(desc.getBigTableBucketNumMapping());  {}
        // out.println(desc.getBigTablePartSpecToFileMapping()); null

        // List<TableDesc> descs = desc.getValueTblDescs();
        // for (TableDesc d : descs) {
        // out.println(d.getJobProperties());
        // }
        // + " alias map " + ((CommonJoinOperator)work).getPosToAliasMap());
      }

      // conf is the table info
      Operator<? extends OperatorDesc> operator = (Operator<? extends OperatorDesc>) work;
      if (operator.getConf() != null) {
        String appender = " (" + operator.getOperatorId() + ")";
        out.println(appender);
      }

      if (!visitedOps.contains(operator)) {
        visitedOps.add(operator);
        if (operator.getChildOperators() != null) {
          for (Operator<? extends OperatorDesc> op : operator.getChildOperators()) {
            output(op);
          }
        }
      }
      return;
    }

    // We look at all methods that generate values for explain
    Method[] methods = work.getClass().getMethods();

    for (Method m : methods) {
      note = m.getAnnotation(Explain.class);

      if (note instanceof Explain) {
        Explain xpl_note = (Explain) note;

        if (xpl_note.normalExplain()) {

          Object val = null;

          try {
            val = m.invoke(work);
          } catch (Exception e) {
            // TODO Auto-generated catch block
            val = null;
          }

          if (val == null) {
            continue;
          }

          String header = null;
          boolean skipHeader = xpl_note.skipHeader();
          // boolean emptyHeader = false;

          // Try the output as a primitive object
          if (isPrintable(val)) {
            if (out != null && shouldPrint(xpl_note, val)) {
              if (!skipHeader) {
                out.printf("%s ", header);
              }
              out.println(val);
            }
            continue;
          }

          // Try this as a map
          try {
            // Go through the map and print out the stuff
            Map<?, ?> mp = (Map<?, ?>) val;

            if (out != null && !skipHeader && mp != null && !mp.isEmpty()) {
              out.print(header);
            }

            continue;
          } catch (ClassCastException ce) {
            // Ignore - all this means is that this is not a map
          }

          // Try this as a list
          try {
            List<?> l = (List<?>) val;

            if (out != null && !skipHeader && l != null && !l.isEmpty()) {
              out.print(header);
            }

            continue;
          } catch (ClassCastException ce) {
            // Ignore
          }

          // Finally check if it is serializable
          try {
            Serializable s = (Serializable) val;

            if (!skipHeader && out != null) {
              out.println(header);
            }
            continue;
          } catch (ClassCastException ce) {
            // Ignore
          }
        }
      }
    }
  }