<commit_before><?xml version="1.0" encoding="UTF-8" ?>
<!--
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->

<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.aurora.scheduler.storage.db.TaskMapper">
  <cache size="10000" readOnly="true" />
  <insert id="insertScheduledTask" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
    INSERT INTO tasks (
      task_id,
      slave_row_id,
      instance_id,
      status,
      failure_count,
      ancestor_task_id,
      task_config_row_id,
    ) VALUES (
      #{task.assignedTask.taskId},
      (
        SELECT ID
        FROM host_attributes
        WHERE slave_id = #{task.assignedTask.slaveId}
          AND host = #{task.assignedTask.slaveHost}
      ),
      #{task.assignedTask.instanceId},
      #{task.status, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler},
      #{task.failureCount},
      #{task.ancestorId},
      #{configId}
    )
  </insert>

  <resultMap id="taskEventMap" type="org.apache.aurora.gen.TaskEvent">
    <id column="id"/>
    <result property="status"
            column="status"
            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler" />
  </resultMap>

  <select id="selectTaskEvents" resultMap="taskEventMap">
    SELECT
      e.id AS id,
      e.timestamp_ms AS timestamp,
      e.status AS status,
      e.message AS message,
      e.scheduler_host AS scheduler
    FROM task_events AS e
    WHERE e.task_row_id = (SELECT id FROM tasks WHERE task_id = #{task_id})
    ORDER BY e.timestamp_ms ASC
  </select>

  <resultMap id="scheduledTaskMap" type="org.apache.aurora.scheduler.storage.db.views.DbScheduledTask">
    <id column="row_id"/>
    <result column="c_id" property="taskConfigRowId"/>
    <result property="status"
            column="status"
            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler" />
    <result column="task_id" property="assignedTask.taskId"/>
    <result column="slave_id" property="assignedTask.slaveId"/>
    <result column="slave_host" property="assignedTask.slaveHost"/>
    <result column="instance_id" property="assignedTask.instanceId"/>
    <association
        property="assignedTask.task"
        select="org.apache.aurora.scheduler.storage.db.TaskConfigMapper.selectConfig"
        column="task_config_row_id"
        foreignColumn="row_id"/>
    <collection
        property="assignedTask.assignedPorts"
        select="selectPorts"
        column="task_id"<commit_msg>Remove unused <result> entry in TaskMapper.<commit_after><?xml version="1.0" encoding="UTF-8" ?>
<!--
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->

<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.aurora.scheduler.storage.db.TaskMapper">
  <cache size="10000" readOnly="true" />
  <insert id="insertScheduledTask" useGeneratedKeys="true" keyColumn="id" keyProperty="result.id">
    INSERT INTO tasks (
      task_id,
      slave_row_id,
      instance_id,
      status,
      failure_count,
      ancestor_task_id,
      task_config_row_id,
    ) VALUES (
      #{task.assignedTask.taskId},
      (
        SELECT ID
        FROM host_attributes
        WHERE slave_id = #{task.assignedTask.slaveId}
          AND host = #{task.assignedTask.slaveHost}
      ),
      #{task.assignedTask.instanceId},
      #{task.status, typeHandler=org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler},
      #{task.failureCount},
      #{task.ancestorId},
      #{configId}
    )
  </insert>

  <resultMap id="taskEventMap" type="org.apache.aurora.gen.TaskEvent">
    <id column="id"/>
    <result property="status"
            column="status"
            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler" />
  </resultMap>

  <select id="selectTaskEvents" resultMap="taskEventMap">
    SELECT
      e.id AS id,
      e.timestamp_ms AS timestamp,
      e.status AS status,
      e.message AS message,
      e.scheduler_host AS scheduler
    FROM task_events AS e
    WHERE e.task_row_id = (SELECT id FROM tasks WHERE task_id = #{task_id})
    ORDER BY e.timestamp_ms ASC
  </select>

  <resultMap id="scheduledTaskMap" type="org.apache.aurora.scheduler.storage.db.views.DbScheduledTask">
    <id column="row_id"/>
    <result property="status"
            column="status"
            typeHandler="org.apache.aurora.scheduler.storage.db.typehandlers.ScheduleStatusTypeHandler" />
    <result column="task_id" property="assignedTask.taskId"/>
    <result column="slave_id" property="assignedTask.slaveId"/>
    <result column="slave_host" property="assignedTask.slaveHost"/>
    <result column="instance_id" property="assignedTask.instanceId"/>
    <association
        property="assignedTask.task"
        select="org.apache.aurora.scheduler.storage.db.TaskConfigMapper.selectConfig"
        column="task_config_row_id"
        foreignColumn="row_id"/>
    <collection
        property="assignedTask.assignedPorts"
        select="selectPorts"
        column="task_id"
{'fraction_non_alphanumeric': 0.11621578357611653, 'fraction_numerical': 0.004802305106451097, 'mean_word_length': 3.36617749825297, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 2, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4046483', 'n_tokens_mistral': 1898, 'n_tokens_neox': 1861, 'n_words': 415}