Source:
<code>public SuccessResponse truncateTable( @ApiParam(value = "Name of the table to update", required = true) @PathParam("tableName") String tableName, <START> @ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr) throws Exception { <END> TableType tableType = Constants.validateTableType(tableTypeStr); if (tableType == null) { throw new ControllerApplicationException(LOGGER, "Table type must not be null", Response.Status.BAD_REQUEST); } if (tableType != TableType.REALTIME && _pinotHelixResourceManager.hasOfflineTable(tableName)) { String tableNameWithType = TableNameBuilder.OFFLINE.tableNameWithType(tableName); _pinotHelixResourceManager.toggleTableState(tableNameWithType, StateType.DISABLE); } if (tableType != TableType.OFFLINE && _pinotHelixResourceManager.hasOfflineTable(tableName)) { String tableNameWithType = TableNameBuilder.REALTIME.tableNameWithType(tableName); _pinotHelixResourceManager.toggleTableState(tableNameWithType, StateType.DISABLE); } String tableNameWithType = getExistingTableNamesWithType(tableName, tableType).get(0); List<String> segmentNames = _pinotHelixResourceManager.getSegmentsFor(tableNameWithType); PinotResourceManagerResponse response = _pinotHelixResourceManager.deleteSegments(tableNameWithType, segmentNames); if (!response.isSuccessful()) { throw new ControllerApplicationException(LOGGER, "Failed to delete segments from table: " + tableNameWithType + ", error message: " + response.getMessage(), Response.Status.INTERNAL_SERVER_ERROR); } return new SuccessResponse("Table " + tableName + " successfully truncated"); }</code><technical_language>define truncate means for realtime. Typically, create a realtime table, immediately starts consumption. truncate, dropping segments, restart consumption based configured offset. happen changes. Consumption restarted next run of RealtimeSegmentValidationManager. I is acceptable flow</technical_language>

Target:
public SuccessResponse truncateTable( @ApiParam(value = "Name of the table to update", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr) throws Exception { TableType tableType = Constants.validateTableType(tableTypeStr); if (tableType == null) { throw new ControllerApplicationException(LOGGER, "Table type must not be null", Response.Status.BAD_REQUEST); } toggleTableState(tableName, tableType, StateType.DISABLE); String tableNameWithType = getExistingTableNamesWithType(tableName, tableType).get(0); List<String> segmentNames = _pinotHelixResourceManager.getSegmentsFor(tableNameWithType); PinotResourceManagerResponse response = _pinotHelixResourceManager.deleteSegments(tableNameWithType, segmentNames); toggleTableState(tableName, tableType, StateType.ENABLE); if (tableType != TableType.OFFLINE && _pinotHelixResourceManager.hasRealtimeTable(tableName)) { String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName); TableConfig realtimeTableConfig = _pinotHelixResourceManager.getTableConfig(realtimeTableName); _pinotHelixResourceManager.ensureRealtimeClusterIsSetUp(realtimeTableConfig); } if (!response.isSuccessful()) { throw new ControllerApplicationException(LOGGER, "Failed to delete segments from table: " + tableNameWithType + ", error message: " + response.getMessage(), Response.Status.INTERNAL_SERVER_ERROR); } return new SuccessResponse("Table " + tableName + " successfully truncated"); }