Authored by wangnan

【图片搜索】 修改实体对应的修改

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.SknImageVectorsMapper" >
<mapper namespace="com.yoho.search.dal.SknImageVectorsMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.SknImageVectors" >
<id column="product_skn" property="productSkn" jdbcType="INTEGER" />
<result column="img_url" property="imgUrl" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="vectors" property="vectors" jdbcType="LONGVARCHAR" />
</resultMap>
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.SknImageVectors">
<id column="product_skn" property="productSkn" jdbcType="INTEGER"/>
<result column="img_url" property="imgUrl" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="vectors_32" property="vectors" jdbcType="LONGVARCHAR"/>
<result column="vectors_128" property="vectors" jdbcType="LONGVARCHAR"/>
</resultMap>
<sql id="Base_Column_List" >
product_skn, img_url, create_time, vectors
<sql id="Base_Column_List">
product_skn, img_url, create_time, vectors_32,vectors_128
</sql>
<insert id="insertBatch" parameterType="java.util.List" timeout="20000">
insert ignore into skn_image_vectors (product_skn, img_url, create_time, vectors)
insert ignore into skn_image_vectors (product_skn, img_url, create_time, vectors_32,vectors_128)
values
<foreach collection="list" item="item" index="index"
separator=",">
(#{item.productSkn, jdbcType=INTEGER},
#{item.imgUrl, jdbcType=VARCHAR},
#{item.createTime, jdbcType=INTEGER},
#{item.vectors, jdbcType=LONGVARCHAR})
#{item.vectors_32, jdbcType=LONGVARCHAR},
#{item.vectors_128, jdbcType=LONGVARCHAR})
</foreach>
</insert>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from skn_image_vectors
where product_skn = #{productSkn,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from skn_image_vectors
where product_skn = #{productSkn,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from skn_image_vectors
where product_skn = #{productSkn,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.SknImageVectors" >
<insert id="insert" parameterType="com.yoho.search.dal.model.SknImageVectors">
insert into skn_image_vectors (product_skn, img_url, create_time,
vectors)
vectors_32,vectors_128)
values (#{productSkn,jdbcType=INTEGER}, #{imgUrl,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER},
#{vectors,jdbcType=LONGVARCHAR})
#{vectors_32,jdbcType=LONGVARCHAR},#{vectors_128,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.SknImageVectors" >
insert into skn_image_vectors
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="productSkn != null" >
product_skn,
</if>
<if test="imgUrl != null" >
img_url,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="vectors != null" >
vectors,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="productSkn != null" >
#{productSkn,jdbcType=INTEGER},
</if>
<if test="imgUrl != null" >
#{imgUrl,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="vectors != null" >
#{vectors,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.SknImageVectors" >
update skn_image_vectors
<set >
<if test="imgUrl != null" >
img_url = #{imgUrl,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="vectors != null" >
vectors = #{vectors,jdbcType=LONGVARCHAR},
</if>
</set>
where product_skn = #{productSkn,jdbcType=INTEGER}
</update>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.SknImageVectors">
insert into skn_image_vectors
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="productSkn != null">
product_skn,
</if>
<if test="imgUrl != null">
img_url,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="vectors_32 != null">
vectors_32,
</if>
<if test="vectors_128 != null">
vectors_128,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="productSkn != null">
#{productSkn,jdbcType=INTEGER},
</if>
<if test="imgUrl != null">
#{imgUrl,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
<if test="vectors_32 != null">
#{vectors_32,jdbcType=LONGVARCHAR},
</if>
<if test="vectors_128 != null">
#{vectors_128,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.yoho.search.dal.model.SknImageVectors" >
update skn_image_vectors
set img_url = #{imgUrl,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
vectors = #{vectors,jdbcType=LONGVARCHAR}
where product_skn = #{productSkn,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.SknImageVectors">
update skn_image_vectors
<set>
<if test="imgUrl != null">
img_url = #{imgUrl,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="vectors_32 != null">
vectors_32 = #{vectors_32,jdbcType=LONGVARCHAR},
</if>
<if test="vectors_128 != null">
vectors_128 = #{vectors_128,jdbcType=LONGVARCHAR},
</if>
</set>
where product_skn = #{productSkn,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.SknImageVectors" >
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.SknImageVectors">
update skn_image_vectors
set img_url = #{imgUrl,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER}
... ...
package com.yoho.search.consumer.index.fullbuild;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.base.SknImageVectorsService;
import com.yoho.search.dal.model.SknImageVectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by wangnan on 2017/7/27.
... ... @@ -30,18 +28,18 @@ public class ImageVectorsIndexBuilder extends IIndexBuilder {
public List<?> getPageLists(int offset, int limit) throws Exception {
List<Map<String,Object>> results = new ArrayList<Map<String,Object>>();
List<SknImageVectors> sknImageVectorsList = sknImageVectorsService.getPageLists(offset,limit);
for (SknImageVectors sknImageVectors : sknImageVectorsList) {
Map<String,Object> result = new HashMap<String, Object>();
result.put("productSkn",sknImageVectors.getProductSkn());
result.put("imgUrl",sknImageVectors.getImgUrl());
result.put("vectors",sknImageVectors.getVectors());
result.put("createTime",sknImageVectors.getCreateTime());
long random = 145770520 + (int)(10000 * Math.random());
result.put("vectors_32",random + ",3064349452,335806560,2181435200,671088930,304636988,286271040,1073741872,78792072,302262276,275415572,2152317976,2501484562,201606178,2477789697,1898189440,2181070873,562179,1143500865,681618177,570429440,419433157,2634376384,33894424,260046852,134754372,1309983506,327765,1114475,4751954,1353801744,139879026,549471617");
result.put("vectors_128",random + ",145770520,3064349452,335806560,2181435200,671088930,304636988,286271040,1073741872,78792072,302262276,275415572,2152317976,2501484562,201606178,2477789697,1898189440,2181070873,562179,1143500865,681618177,570429440,419433157,2634376384,33894424,260046852,134754372,1309983506,327765,1114475,4751954,1353801744,139879026,549471617,2491464322,1216608388,2249850888,536936961,1275183104,1679425556,146802912,17064578,985666161,2693863958,90720896,2315346182,1342769216,1077021157,411044198,1275757661,268634178,28377159,146354724,555754625,9439360,1249378,2517762067,276832513,339969674,67633187,2416766034,705206816,3238108736,3323996166,48255525,67152905,738644232,3355443282,847249547,2151816497,2416551620,3230152256,153315984,945373320,1159730176,17080355,2198110342,55198214,3289513993,1175749760,34213921,583618724,168312976,2165311811,204522048,180390282,1212663092,1351124312,34606016,706806272,100734720,1630732425,1073823908,563384330,536873053,2963308608,1074270241,337646622,3240230912,2875229798,2349404172,552112153,1329152,805963786,2172994050,1153434112,69360641,1412171537,1216881732,34613286,2177368840,2619490304,590464,127026387,847390820,337670664,1380327625,390079202,1535432836,3305349121,723751402,3240178208,2151744513,18874372,1142981696,1487227220,3250944274,262236,2483257479");
results.add(result);
}
return results;
// for (SknImageVectors sknImageVectors : sknImageVectorsList) {
// Map<String,Object> result = new HashMap<String, Object>();
// result.put("productSkn",sknImageVectors.getProductSkn());
// result.put("imgUrl",sknImageVectors.getImgUrl());
// result.put("vectors",sknImageVectors.getVectors());
// result.put("createTime",sknImageVectors.getCreateTime());
// long random = 145770520 + (int)(10000 * Math.random());
// result.put("vectors_32",random + ",3064349452,335806560,2181435200,671088930,304636988,286271040,1073741872,78792072,302262276,275415572,2152317976,2501484562,201606178,2477789697,1898189440,2181070873,562179,1143500865,681618177,570429440,419433157,2634376384,33894424,260046852,134754372,1309983506,327765,1114475,4751954,1353801744,139879026,549471617");
// result.put("vectors_128",random + ",145770520,3064349452,335806560,2181435200,671088930,304636988,286271040,1073741872,78792072,302262276,275415572,2152317976,2501484562,201606178,2477789697,1898189440,2181070873,562179,1143500865,681618177,570429440,419433157,2634376384,33894424,260046852,134754372,1309983506,327765,1114475,4751954,1353801744,139879026,549471617,2491464322,1216608388,2249850888,536936961,1275183104,1679425556,146802912,17064578,985666161,2693863958,90720896,2315346182,1342769216,1077021157,411044198,1275757661,268634178,28377159,146354724,555754625,9439360,1249378,2517762067,276832513,339969674,67633187,2416766034,705206816,3238108736,3323996166,48255525,67152905,738644232,3355443282,847249547,2151816497,2416551620,3230152256,153315984,945373320,1159730176,17080355,2198110342,55198214,3289513993,1175749760,34213921,583618724,168312976,2165311811,204522048,180390282,1212663092,1351124312,34606016,706806272,100734720,1630732425,1073823908,563384330,536873053,2963308608,1074270241,337646622,3240230912,2875229798,2349404172,552112153,1329152,805963786,2172994050,1153434112,69360641,1412171537,1216881732,34613286,2177368840,2619490304,590464,127026387,847390820,337670664,1380327625,390079202,1535432836,3305349121,723751402,3240178208,2151744513,18874372,1142981696,1487227220,3250944274,262236,2483257479");
// results.add(result);
// }
return sknImageVectorsList;
}
@SuppressWarnings("unchecked")
... ...
... ... @@ -14,10 +14,6 @@
"type": "string",
"index": "no"
},
"vectors": {
"type": "string",
"index": "not_analyzed"
},
"vectors_32": {
"type": "string",
"index": "not_analyzed"
... ...
... ... @@ -84,7 +84,7 @@ public class TestApiController {
@ResponseBody
public Map<String, Object> putData() throws UnsupportedEncodingException {
for (int j = 1; j <= 10; j++) {
String fileName = j + "_feat_out_.txt";
String fileName = j + "_feat_out_32_.txt";
String filePath = this.getClass().getResource("/").getPath();
List<String> lines = FileUtils.readFile(filePath + fileName);
System.out.println("lines done " + j);
... ... @@ -98,7 +98,8 @@ public class TestApiController {
SknImageVectors sknImageVectors = new SknImageVectors();
sknImageVectors.setProductSkn(Integer.valueOf(skn));
sknImageVectors.setImgUrl("url");
sknImageVectors.setVectors(factors);
sknImageVectors.setVectors_32(factors);
sknImageVectors.setVectors_128("");
sknImageVectors.setCreateTime(DateUtil.getCurrentTimeSecond());
sknImageVectorsList.add(sknImageVectors);
//updateProductIndexWithDataMap(indexData, skn);
... ...