public override void Map(ByteSlice row, MapOutput output) { if (JoinType.X == type) { ftools = new DbFunctionTools(); string QlLeftTableName = DSpace_ExecArgs[0]; LeftTableName = Qa.QlArgsUnescape(QlLeftTableName); string stype = DSpace_ExecArgs[1]; string QlRightTableName = DSpace_ExecArgs[2]; RightTableName = Qa.QlArgsUnescape(QlRightTableName); string QlOn = DSpace_ExecArgs[3]; On = Qa.QlArgsUnescape(QlOn); { string LeftColInfo = Qa.QlArgsUnescape(DSpace_ExecArgs[4]); int ileq = LeftColInfo.LastIndexOf('='); string sLeftType = LeftColInfo.Substring(ileq + 1); LeftType = DbType.Prepare(sLeftType); LeftConv = NeedConv(LeftType, RightType); string[] st = LeftColInfo.Substring(0, ileq).Split(','); LeftOffset = int.Parse(st[0]); LeftSize = int.Parse(st[1]); } { string RightColInfo = Qa.QlArgsUnescape(DSpace_ExecArgs[5]); int ileq = RightColInfo.LastIndexOf('='); string sRightType = RightColInfo.Substring(ileq + 1); RightType = DbType.Prepare(sRightType); RightConv = NeedConv(RightType, LeftType); string[] st = RightColInfo.Substring(0, ileq).Split(','); RightOffset = int.Parse(st[0]); RightSize = int.Parse(st[1]); } if (0 == string.Compare("INNER", stype, true)) { type = JoinType.INNER_JOIN; } else if (0 == string.Compare("LEFT_OUTER", stype, true)) { type = JoinType.LEFT_OUTER_JOIN; } else if (0 == string.Compare("RIGHT_OUTER", stype, true)) { type = JoinType.RIGHT_OUTER_JOIN; } else { throw new NotSupportedException("DEBUG: JOIN type not supported: " + stype); } string DfsTableFilesInput = DSpace_ExecArgs[6]; /* * TableFileNames = DfsTableFilesInput.Split(';'); * if (2 != TableFileNames.Length) * { * throw new Exception("DEBUG: Invalid number of tables"); * } * for (int it = 0; it < TableFileNames.Length; it++) * { * if (TableFileNames[it].StartsWith("dfs://", StringComparison.OrdinalIgnoreCase)) * { * TableFileNames[it] = TableFileNames[it].Substring(6); * } * int iat = TableFileNames[it].IndexOf('@'); * if (-1 != iat) * { * TableFileNames[it] = TableFileNames[it].Substring(0, iat); * } * } * */ } int tableid = GetTableID(row); ByteSlice key; if (0 == tableid) { key = ByteSlice.Prepare(row, LeftOffset, LeftSize); if (null != LeftConv) { key = LeftConv(key, DSpace_KeyLength, ftools); } } else if (1 == tableid) { key = ByteSlice.Prepare(row, RightOffset, RightSize); if (null != RightConv) { key = RightConv(key, DSpace_KeyLength, ftools); } } else { throw new Exception("Map: Unexpected TableID: " + tableid); } List <byte> valuebuf = ftools.AllocBuffer(1 + 4 + row.Length); { DbValue tableiddbvalue = ftools.AllocValue(tableid); tableiddbvalue.Eval().AppendTo(valuebuf); } row.AppendTo(valuebuf); output.Add(key, ByteSlice.Prepare(valuebuf)); ftools.ResetBuffers(); }
public override void Map(ByteSlice row, MapOutput output) { if (JoinType.X == type) { ftools = new DbFunctionTools(); string QlLeftTableName = DSpace_ExecArgs[0]; LeftTableName = Qa.QlArgsUnescape(QlLeftTableName); string stype = DSpace_ExecArgs[1]; string QlRightTableName = DSpace_ExecArgs[2]; RightTableName = Qa.QlArgsUnescape(QlRightTableName); string QlOn = DSpace_ExecArgs[3]; On = Qa.QlArgsUnescape(QlOn); { string LeftColInfo = Qa.QlArgsUnescape(DSpace_ExecArgs[4]); int ileq = LeftColInfo.LastIndexOf('='); string sLeftType = LeftColInfo.Substring(ileq + 1); LeftType = DbType.Prepare(sLeftType); LeftConv = NeedConv(LeftType, RightType); string[] st = LeftColInfo.Substring(0, ileq).Split(','); LeftOffset = int.Parse(st[0]); LeftSize = int.Parse(st[1]); } { string RightColInfo = Qa.QlArgsUnescape(DSpace_ExecArgs[5]); int ileq = RightColInfo.LastIndexOf('='); string sRightType = RightColInfo.Substring(ileq + 1); RightType = DbType.Prepare(sRightType); RightConv = NeedConv(RightType, LeftType); string[] st = RightColInfo.Substring(0, ileq).Split(','); RightOffset = int.Parse(st[0]); RightSize = int.Parse(st[1]); } if (0 == string.Compare("INNER", stype, true)) { type = JoinType.INNER_JOIN; } else if (0 == string.Compare("LEFT_OUTER", stype, true)) { type = JoinType.LEFT_OUTER_JOIN; } else if (0 == string.Compare("RIGHT_OUTER", stype, true)) { type = JoinType.RIGHT_OUTER_JOIN; } else { throw new NotSupportedException("DEBUG: JOIN type not supported: " + stype); } string DfsTableFilesInput = DSpace_ExecArgs[6]; /* TableFileNames = DfsTableFilesInput.Split(';'); if (2 != TableFileNames.Length) { throw new Exception("DEBUG: Invalid number of tables"); } for (int it = 0; it < TableFileNames.Length; it++) { if (TableFileNames[it].StartsWith("dfs://", StringComparison.OrdinalIgnoreCase)) { TableFileNames[it] = TableFileNames[it].Substring(6); } int iat = TableFileNames[it].IndexOf('@'); if (-1 != iat) { TableFileNames[it] = TableFileNames[it].Substring(0, iat); } } * */ } int tableid = GetTableID(row); ByteSlice key; if (0 == tableid) { key = ByteSlice.Prepare(row, LeftOffset, LeftSize); if (null != LeftConv) { key = LeftConv(key, DSpace_KeyLength, ftools); } } else if (1 == tableid) { key = ByteSlice.Prepare(row, RightOffset, RightSize); if (null != RightConv) { key = RightConv(key, DSpace_KeyLength, ftools); } } else { throw new Exception("Map: Unexpected TableID: " + tableid); } List<byte> valuebuf = ftools.AllocBuffer(1 + 4 + row.Length); { DbValue tableiddbvalue = ftools.AllocValue(tableid); tableiddbvalue.Eval().AppendTo(valuebuf); } row.AppendTo(valuebuf); output.Add(key, ByteSlice.Prepare(valuebuf)); ftools.ResetBuffers(); }