@Test public void testNoIndexHint() { String sql = "select * from tab"; GroupIndex index = GroupHintParser.convertHint2Index(sql); Assert.assertNull(index); }
public static GroupIndex convertHint2Index(String sql) { String groupIndexHint = extractTDDLGroupHint(sql); if (null != groupIndexHint && !groupIndexHint.equals("")) { String[] hintWithRetry = groupIndexHint.split(","); if (hintWithRetry.length == 1) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); return new GroupIndex(index, false); } else if (hintWithRetry.length == 2) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); boolean retry = GroupHintParser.getFailRetryFromHintPiece(hintWithRetry[1]); return new GroupIndex(index, retry); } else { throw new IllegalArgumentException("the standard group hint is:'groupIndex:12[,failRetry:true]'" + ",current hint is:" + groupIndexHint); } } else { return null; } }
GroupHintParser { public static GroupIndex convertHint2Index(String sql) { String groupIndexHint = extractTDDLGroupHint(sql); if (null != groupIndexHint && !groupIndexHint.equals("")) { String[] hintWithRetry = groupIndexHint.split(","); if (hintWithRetry.length == 1) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); return new GroupIndex(index, false); } else if (hintWithRetry.length == 2) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); boolean retry = GroupHintParser.getFailRetryFromHintPiece(hintWithRetry[1]); return new GroupIndex(index, retry); } else { throw new IllegalArgumentException("the standard group hint is:'groupIndex:12[,failRetry:true]'" + ",current hint is:" + groupIndexHint); } } else { return null; } } }
GroupHintParser { public static GroupIndex convertHint2Index(String sql) { String groupIndexHint = extractTDDLGroupHint(sql); if (null != groupIndexHint && !groupIndexHint.equals("")) { String[] hintWithRetry = groupIndexHint.split(","); if (hintWithRetry.length == 1) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); return new GroupIndex(index, false); } else if (hintWithRetry.length == 2) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); boolean retry = GroupHintParser.getFailRetryFromHintPiece(hintWithRetry[1]); return new GroupIndex(index, retry); } else { throw new IllegalArgumentException("the standard group hint is:'groupIndex:12[,failRetry:true]'" + ",current hint is:" + groupIndexHint); } } else { return null; } }  }
GroupHintParser { public static GroupIndex convertHint2Index(String sql) { String groupIndexHint = extractTDDLGroupHint(sql); if (null != groupIndexHint && !groupIndexHint.equals("")) { String[] hintWithRetry = groupIndexHint.split(","); if (hintWithRetry.length == 1) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); return new GroupIndex(index, false); } else if (hintWithRetry.length == 2) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); boolean retry = GroupHintParser.getFailRetryFromHintPiece(hintWithRetry[1]); return new GroupIndex(index, retry); } else { throw new IllegalArgumentException("the standard group hint is:'groupIndex:12[,failRetry:true]'" + ",current hint is:" + groupIndexHint); } } else { return null; } }  static GroupIndex convertHint2Index(String sql); static String extractTDDLGroupHint(String sql); static String removeTddlGroupHint(String sql); static String buildTddlGroupHint(String groupHint); static void main(String[] args); }
GroupHintParser { public static GroupIndex convertHint2Index(String sql) { String groupIndexHint = extractTDDLGroupHint(sql); if (null != groupIndexHint && !groupIndexHint.equals("")) { String[] hintWithRetry = groupIndexHint.split(","); if (hintWithRetry.length == 1) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); return new GroupIndex(index, false); } else if (hintWithRetry.length == 2) { int index = GroupHintParser.getIndexFromHintPiece(hintWithRetry[0]); boolean retry = GroupHintParser.getFailRetryFromHintPiece(hintWithRetry[1]); return new GroupIndex(index, retry); } else { throw new IllegalArgumentException("the standard group hint is:'groupIndex:12[,failRetry:true]'" + ",current hint is:" + groupIndexHint); } } else { return null; } }  static GroupIndex convertHint2Index(String sql); static String extractTDDLGroupHint(String sql); static String removeTddlGroupHint(String sql); static String buildTddlGroupHint(String groupHint); static void main(String[] args); static Logger log; }