Просмотр исходного кода

视频匹配长文,增加实验ID

wangyunpeng 20 часов назад
Родитель
Сommit
f1a18ff8e2

+ 11 - 3
core/src/main/java/com/tzld/videoVector/job/VideoArticleMatchJob.java

@@ -587,11 +587,17 @@ public class VideoArticleMatchJob {
                              Map<Long, String> videoTitleMap,
                              Map<Long, Map<String, ArticleMatchItem>> finalPairs) {
 
-        // 构建 "videoId|channelLevel3" → (channelLevel3, account) 映射
+        // 构建 "videoId|channelLevel3" → record 映射(取 matchRov 最高的那条)
         Map<String, ChannelDemandMatchResult> videoChannelRecordMap = new LinkedHashMap<>();
+        Map<String, Double> videoChannelBestRov = new LinkedHashMap<>();
         for (ChannelDemandMatchResult r : records) {
             String key = r.getMatchVideoId() + "|" + r.getChannelLevel3();
-            videoChannelRecordMap.putIfAbsent(key, r);
+            Double currentRov = videoChannelBestRov.get(key);
+            Double thisRov = r.getMatchRov() != null ? r.getMatchRov() : 0.0;
+            if (currentRov == null || thisRov > currentRov) {
+                videoChannelBestRov.put(key, thisRov);
+                videoChannelRecordMap.put(key, r);
+            }
         }
 
         // 序列化排名参数(所有行共享)
@@ -613,7 +619,7 @@ public class VideoArticleMatchJob {
                 }
 
                 resultList.add(buildResultRow(dt, videoId, videoTitle, article,
-                        channelLevel3, record.getAccount(),
+                        channelLevel3, record.getAccount(), record.getExperimentId(),
                         rankingJson, configCodesStr));
             }
         }
@@ -650,6 +656,7 @@ public class VideoArticleMatchJob {
                                                    ArticleMatchItem article,
                                                    String channelLevel3,
                                                    String account,
+                                                   String experimentId,
                                                    String rankingJson,
                                                    String configCodesStr) {
         VideoArticleMatchResult row = new VideoArticleMatchResult();
@@ -666,6 +673,7 @@ public class VideoArticleMatchJob {
         row.setQueryText(videoTitle);
         row.setConfigCodes(configCodesStr);
         row.setRankingParams(rankingJson);
+        row.setExperimentId(experimentId);
         return row;
     }
 

+ 36 - 0
core/src/main/java/com/tzld/videoVector/model/po/pgVector/VideoArticleMatchResult.java

@@ -171,6 +171,17 @@ public class VideoArticleMatchResult {
      */
     private Date createTime;
 
+    /**
+     * Database Column Remarks:
+     *   匹配实验ID
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column video_article_match_result.experiment_id
+     *
+     * @mbg.generated
+     */
+    private String experimentId;
+
     /**
      * This method was generated by MyBatis Generator.
      * This method returns the value of the database column video_article_match_result.id
@@ -531,6 +542,30 @@ public class VideoArticleMatchResult {
         this.createTime = createTime;
     }
 
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column video_article_match_result.experiment_id
+     *
+     * @return the value of video_article_match_result.experiment_id
+     *
+     * @mbg.generated
+     */
+    public String getExperimentId() {
+        return experimentId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column video_article_match_result.experiment_id
+     *
+     * @param experimentId the value for video_article_match_result.experiment_id
+     *
+     * @mbg.generated
+     */
+    public void setExperimentId(String experimentId) {
+        this.experimentId = experimentId;
+    }
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table video_article_match_result
@@ -558,6 +593,7 @@ public class VideoArticleMatchResult {
         sb.append(", configCodes=").append(configCodes);
         sb.append(", rankingParams=").append(rankingParams);
         sb.append(", createTime=").append(createTime);
+        sb.append(", experimentId=").append(experimentId);
         sb.append("]");
         return sb.toString();
     }

+ 70 - 0
core/src/main/java/com/tzld/videoVector/model/po/pgVector/VideoArticleMatchResultExample.java

@@ -1204,6 +1204,76 @@ public class VideoArticleMatchResultExample {
             addCriterion("create_time not between", value1, value2, "createTime");
             return (Criteria) this;
         }
+
+        public Criteria andExperimentIdIsNull() {
+            addCriterion("experiment_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdIsNotNull() {
+            addCriterion("experiment_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdEqualTo(String value) {
+            addCriterion("experiment_id =", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotEqualTo(String value) {
+            addCriterion("experiment_id <>", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdGreaterThan(String value) {
+            addCriterion("experiment_id >", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdGreaterThanOrEqualTo(String value) {
+            addCriterion("experiment_id >=", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdLessThan(String value) {
+            addCriterion("experiment_id <", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdLessThanOrEqualTo(String value) {
+            addCriterion("experiment_id <=", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdLike(String value) {
+            addCriterion("experiment_id like", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotLike(String value) {
+            addCriterion("experiment_id not like", value, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdIn(List<String> values) {
+            addCriterion("experiment_id in", values, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotIn(List<String> values) {
+            addCriterion("experiment_id not in", values, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdBetween(String value1, String value2) {
+            addCriterion("experiment_id between", value1, value2, "experimentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andExperimentIdNotBetween(String value1, String value2) {
+            addCriterion("experiment_id not between", value1, value2, "experimentId");
+            return (Criteria) this;
+        }
     }
 
     /**

+ 22 - 7
core/src/main/resources/mapper/pgVector/VideoArticleMatchResultMapper.xml

@@ -21,6 +21,7 @@
     <result column="config_codes" jdbcType="VARCHAR" property="configCodes" />
     <result column="ranking_params" jdbcType="VARCHAR" property="rankingParams" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="experiment_id" jdbcType="VARCHAR" property="experimentId" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -95,7 +96,7 @@
     -->
     id, dt, channel_name, channel_level3, account, match_video_id, video_title, matched_article_id, 
     matched_article_title, match_score, match_config_code, query_text, config_codes, 
-    ranking_params, create_time
+    ranking_params, create_time, experiment_id
   </sql>
   <select id="selectByExample" parameterType="com.tzld.videoVector.model.po.pgVector.VideoArticleMatchResultExample" resultMap="BaseResultMap">
     <!--
@@ -152,14 +153,14 @@
       account, match_video_id, video_title, 
       matched_article_id, matched_article_title, 
       match_score, match_config_code, query_text, 
-      config_codes, ranking_params, create_time
-      )
+      config_codes, ranking_params, create_time, 
+      experiment_id)
     values (#{dt,jdbcType=VARCHAR}, #{channelName,jdbcType=VARCHAR}, #{channelLevel3,jdbcType=VARCHAR}, 
       #{account,jdbcType=VARCHAR}, #{matchVideoId,jdbcType=BIGINT}, #{videoTitle,jdbcType=VARCHAR}, 
       #{matchedArticleId,jdbcType=VARCHAR}, #{matchedArticleTitle,jdbcType=VARCHAR}, 
       #{matchScore,jdbcType=DOUBLE}, #{matchConfigCode,jdbcType=VARCHAR}, #{queryText,jdbcType=VARCHAR}, 
-      #{configCodes,jdbcType=VARCHAR}, #{rankingParams,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
-      )
+      #{configCodes,jdbcType=VARCHAR}, #{rankingParams,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{experimentId,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.tzld.videoVector.model.po.pgVector.VideoArticleMatchResult" useGeneratedKeys="true">
     <!--
@@ -210,6 +211,9 @@
       <if test="createTime != null">
         create_time,
       </if>
+      <if test="experimentId != null">
+        experiment_id,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="dt != null">
@@ -254,6 +258,9 @@
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="experimentId != null">
+        #{experimentId,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.tzld.videoVector.model.po.pgVector.VideoArticleMatchResultExample" resultType="java.lang.Long">
@@ -318,6 +325,9 @@
       <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="record.experimentId != null">
+        experiment_id = #{record.experimentId,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -343,7 +353,8 @@
       query_text = #{record.queryText,jdbcType=VARCHAR},
       config_codes = #{record.configCodes,jdbcType=VARCHAR},
       ranking_params = #{record.rankingParams,jdbcType=VARCHAR},
-      create_time = #{record.createTime,jdbcType=TIMESTAMP}
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      experiment_id = #{record.experimentId,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -397,6 +408,9 @@
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="experimentId != null">
+        experiment_id = #{experimentId,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -419,7 +433,8 @@
       query_text = #{queryText,jdbcType=VARCHAR},
       config_codes = #{configCodes,jdbcType=VARCHAR},
       ranking_params = #{rankingParams,jdbcType=VARCHAR},
-      create_time = #{createTime,jdbcType=TIMESTAMP}
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      experiment_id = #{experimentId,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>

+ 3 - 2
core/src/main/resources/mapper/pgVector/ext/VideoArticleMatchResultMapperExt.xml

@@ -7,14 +7,15 @@
       account, match_video_id, video_title,
       matched_article_id, matched_article_title,
       match_score, match_config_code,
-      query_text, config_codes, ranking_params)
+      query_text, config_codes, ranking_params, experiment_id)
     values
     <foreach collection="list" item="item" separator=",">
       (#{item.dt,jdbcType=VARCHAR}, #{item.channelName,jdbcType=VARCHAR}, #{item.channelLevel3,jdbcType=VARCHAR},
       #{item.account,jdbcType=VARCHAR}, #{item.matchVideoId,jdbcType=BIGINT}, #{item.videoTitle,jdbcType=VARCHAR},
       #{item.matchedArticleId,jdbcType=VARCHAR}, #{item.matchedArticleTitle,jdbcType=VARCHAR},
       #{item.matchScore,jdbcType=DOUBLE}, #{item.matchConfigCode,jdbcType=VARCHAR},
-      #{item.queryText,jdbcType=VARCHAR}, #{item.configCodes,jdbcType=VARCHAR}, #{item.rankingParams,jdbcType=VARCHAR})
+      #{item.queryText,jdbcType=VARCHAR}, #{item.configCodes,jdbcType=VARCHAR}, #{item.rankingParams,jdbcType=VARCHAR},
+      #{item.experimentId,jdbcType=VARCHAR})
     </foreach>
   </insert>