for (ColumnRoutePair colPair : colRoutePairSet) { if (colPair.colValue != null) { Integer nodeIndex = algorithm.calculate(colPair.colValue); if (nodeIndex == null) { throw new IllegalArgumentException("can't find datanode for sharding column:" + col + " val:" + colPair.colValue);
Integer nodeIndex; try { nodeIndex = algorithm.calculate(pair.colValue); } catch (Exception e) { return false;
return; Integer nodeIndex = algorithm.calculate(pair.colValue); if (nodeIndex == null) { String msg = "can't find any valid data node :" + tableConfig.getName() +
Integer nodeIndex = algorithm.calculate(shardingValue);
String shardingValue = shardingValueToSting(expr); checkDefaultValues(shardingValue, tableConfig, schemaInfo.getSchema(), partitionColumn); Integer nodeIndex = algorithm.calculate(shardingValue);
/** * insert single record * * @param schemaInfo SchemaInfo * @param rrs RouteResultset * @param partitionColumn partitionColumn * @param replaceStatement SQLReplaceStatement * @throws SQLNonTransientException if not find a valid data node */ private void parserSingleInsert(SchemaInfo schemaInfo, RouteResultset rrs, String partitionColumn, SQLReplaceStatement replaceStatement) throws SQLNonTransientException { int shardingColIndex = tryGetShardingColIndex(schemaInfo, replaceStatement, partitionColumn); SQLExpr valueExpr = replaceStatement.getValuesList().get(0).getValues().get(shardingColIndex); String shardingValue = shardingValueToSting(valueExpr); TableConfig tableConfig = schemaInfo.getSchemaConfig().getTables().get(schemaInfo.getTable()); AbstractPartitionAlgorithm algorithm = tableConfig.getRule().getRuleAlgorithm(); Integer nodeIndex = algorithm.calculate(shardingValue); if (nodeIndex == null) { String msg = "can't find any valid data node :" + schemaInfo.getTable() + " -> " + partitionColumn + " -> " + shardingValue; LOGGER.info(msg); throw new SQLNonTransientException(msg); } RouteResultsetNode[] nodes = new RouteResultsetNode[1]; nodes[0] = new RouteResultsetNode(tableConfig.getDataNodes().get(nodeIndex), rrs.getSqlType(), RouterUtil.removeSchema(statementToString(replaceStatement), schemaInfo.getSchema())); rrs.setNodes(nodes); rrs.setFinishedRoute(true); } }
AbstractPartitionAlgorithm algorithm = tableConfig.getRule().getRuleAlgorithm(); checkDefaultValues(shardingValue, tableConfig, schemaInfo.getSchema(), partitionColumn); Integer nodeIndex = algorithm.calculate(shardingValue); if (nodeIndex == null || nodeIndex >= tableConfig.getDataNodes().size()) { String msg = "can't find any valid data node :" + schemaInfo.getTable() + " -> " + partitionColumn + " -> " + shardingValue;