/* public static String getFieldNames(List<byte[]> fields){ String str=""; for (byte[] field :fields) { FieldPacket fieldPacket = new FieldPacket(); fieldPacket.read(field); str+=ByteUtil.getString(fieldPacket.name)+","; } return str; } public static String getFieldName(byte[] field){ FieldPacket fieldPacket = new FieldPacket(); fieldPacket.read(field); return ByteUtil.getString(fieldPacket.name); } */ @Override public boolean onRowData(String dataNode, byte[] rowData) { int fid = this.ctx.getFieldIndex(fields, joinkey); String id = ResultSetUtil.getColumnValAsString(rowData, fields, 0); // 主键,默认id String nid = ResultSetUtil.getColumnValAsString(rowData, fields, fid); // 放入结果集 // rows.put(id, rowData); ctx.putDBRow(id, nid, rowData, fid); return false; }
@Override public boolean onRowData(String dataNode, byte[] rowData) { RowDataPacket rowDataPkgold = ResultSetUtil.parseRowData(rowData, bfields); // 获取Id字段, String id = ByteUtil.getString(rowDataPkgold.fieldValues.get(joinR)); // 查找ID对应的A表的记录 byte[] arow = getRow(id, joinL); // arows.remove(id); while (arow != null) { RowDataPacket rowDataPkg = ResultSetUtil.parseRowData(arow, afields); // ctx.getAllFields()); for (int i = 1; i < rowDataPkgold.fieldCount; i++) { // 设置b.name 字段 byte[] bname = rowDataPkgold.fieldValues.get(i); rowDataPkg.add(bname); rowDataPkg.addFieldCount(1); } // RowData(rowDataPkg); ctx.writeRow(rowDataPkg); arow = getRow(id, joinL); } return false; }
@Override public void onHeader(String dataNode, byte[] header, List<byte[]> bfields) { this.bfields = bfields; joinR = this.ctx.getFieldIndex(bfields, joinRkey); ctx.writeHeader(dataNode, afields, bfields); }
@Override public void finished(String dataNode, boolean failed) { ctx.endJobInput(dataNode, failed); }
@Override public void onHeader(String dataNode, byte[] header, List<byte[]> fields) { this.fields = fields; ctx.putDBFields(fields); }