如何高效使用长尾词进行表格存储优化?
- 内容介绍
- 文章标签
- 相关推荐
本文共计3954个文字,预计阅读时间需要16分钟。
表格式存储客户端创建,导入包:javaimport com.alicloud.openservices.tablestore.ClientConfiguration;import com.alicloud.openservices.tablestore.SyncClient;import com.alicloud.openservices.tablestore.model.Always;
package com.mimidai.common.utils.table; import com.alicloud.openservices.tablestore.ClientConfiguration; import com.alicloud.openservices.tablestore.SyncClient; import com.alicloud.openservices.tablestore.model.AlwaysRetryStrategy; import com.mimidai.common.utils.PropertiesUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * 创建表格存储client Created by EVE on 2017-06-22. */ @Configuration //@PropertySource("classpath:application-develop.properties") public class TableClientConfig { private static Logger logger = LoggerFactory.getLogger("log.hbase.TableClientConfig"); // @Value("${TableClientConfig.endPoint}") // private String endPoint; // @Value("${TableClientConfig.accessId}") // private String accessId; // @Value("${TableClientConfig.accessKey}") // private String accessKey; // @Value("${TableClientConfig.instanceName}") // private String instanceName; //生产配置 start //内网地址 // private String endPoint = "192.168.3.17:80/"; // private String accessId = "XXXX"; // private String accessKey = "XXXXXXXXXXXXXXX"; // private String instanceName = "xxx"; //生产配置 end //测试 环境 start //内网地址 // private String endPoint = "xxxxxxxxx/"; //外网地址 // private static final String endPoint = "xxx-test.cn-beijing.ots.aliyuncs.com"; // private String accessId = "XXXXXXXXXXXX"; // private String accessKey = "XXXXXXXXXXXXXXXXXXX"; // private String instanceName = "test"; private static final String endPoint = PropertiesUtils.getProperties().getProperty("table_client_end_point"); private static final String accessId = PropertiesUtils.getProperties().getProperty("table_client_access_id"); private static final String accessKey = PropertiesUtils.getProperties().getProperty("table_client_access_key"); private static final String instanceName = PropertiesUtils.getProperties().getProperty ("table_client_instance_name"); //测试 换将 end @Bean public SyncClient createClient() { logger.info("开始调用createClient方法"); // ClientConfiguration提供了很多配置项,以下只列举部分。 ClientConfiguration clientConfiguration = new ClientConfiguration(); // 设置建立连接的超时时间。 clientConfiguration.setConnectionTimeoutInMillisecond(5000); // 设置socket超时时间。 clientConfiguration.setSocketTimeoutInMillisecond(5000); // 设置重试策略,若不设置,采用默认的重试策略。 clientConfiguration.setRetryStrategy(new AlwaysRetryStrategy()); logger.info("返回创建表格存储cleint"); return new SyncClient(endPoint, accessId, accessKey, instanceName, clientConfiguration); } } 表格存储 接口
package com.mimidai.common.dao.table;
import com.alicloud.openservices.tablestore.model.PrimaryKey;
import com.mimidai.common.dto.SolrSmsDetails;
import com.mimidai.common.utils.persistence.Page;
import java.util.List;
/**
* Created by EVE on 2017-06-22.
*/
public interface TableSolrSmsDetailsDao {
void add(List
package com.mimidai.common.utils.table;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.alicloud.openservices.tablestore.SyncClient;
import com.alicloud.openservices.tablestore.model.BatchWriteRowRequest;
import com.alicloud.openservices.tablestore.model.Column;
import com.alicloud.openservices.tablestore.model.ColumnValue;
import com.alicloud.openservices.tablestore.model.GetRowRequest;
import com.alicloud.openservices.tablestore.model.GetRowResponse;
import com.alicloud.openservices.tablestore.model.PrimaryKey;
import com.alicloud.openservices.tablestore.model.PrimaryKeyBuilder;
import com.alicloud.openservices.tablestore.model.PrimaryKeyValue;
import com.alicloud.openservices.tablestore.model.Row;
import com.alicloud.openservices.tablestore.model.RowPutChange;
import com.alicloud.openservices.tablestore.model.RowUpdateChange;
import com.alicloud.openservices.tablestore.model.SingleRowQueryCriteria;
import com.alicloud.openservices.tablestore.model.UpdateRowRequest;
import com.mimidai.common.dao.table.TableSolrSmsDetailsDao;
import com.mimidai.common.dao.user.UserPhoneCheckDao;
import com.mimidai.common.dao.user.UserPhoneCheckHistoryDao;
import com.mimidai.common.dto.SolrSmsDetails;
import com.mimidai.common.pay.MD5Util;
import com.mimidai.common.utils.persistence.Page;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* core1 短信接口 表结构如下 主键 details_queryTime1 details_queryTime …. userId phone json(最多2M) json
* (最多2M) ... userId phone
* json(最多2M) json(最多2M) ... ...
*
* Created by EVE on 2017-06-22.
*/
@Repository
public class TableSolrSmsDetailsDaoImpl implements TableSolrSmsDetailsDao {
@Autowired
@Qualifier("createClient")
private SyncClient client;
private final String TABLENAME = "smsDetails";
@Autowired
private UserPhoneCheckDao userPhoneCheckDao;
@Autowired
private UserPhoneCheckHistoryDao userPhoneCheckHistoryDao;
//日志
private static final Logger logger = LoggerFactory.getLogger("log.tableStore.TableSolrSmsDetailsDaoImpl");
/**
* 逻辑变更 暂时注释 请勿删除
*
* 添加非空用户到表格存储 每次只查一个用户 一个电话 相当于(user+phone唯一)
* 添加逻辑 需要判断
* 1.该条信息是否在表格存储中已经存在,如果存在,新传入的solrSmsDetailses 只包含增量数据,需要做增量操作(先查再将两处结果集合并)
* 2.该条信息之前没有,直接添加即可
*/
// @Override
// public void add(List
>() {}.getType()); resultList.addAll(columnList); } } long endTime = System.currentTimeMillis(); float excTime = (float) (endTime - startTime) / 1000; logger.info("tableStore(core1)查询方法query填装List成功,resultList={}是否为空,query方法体执行时间excTime:", CollectionUtils .isEmpty(resultList), excTime, getUserIdAndPhone(solrSmsDetails)); return resultList; } /** * 更新通用方法 */ // @Override // public Boolean updateRow(List
package com.mimidai.common.dto; import com.google.gson.annotations.Expose; import org.apache.solr.client.solrj.beans.Field; /** * 短信详单 * * @author liang */ public class SolrSmsDetails { @Field @Expose(serialize = false) private String id; @Field @Expose private Long userId; @Field @Expose private String phone; @Field @Expose private String otherPhone; @Field @Expose private Integer smsType; @Field @Expose private String date; @Field @Expose private Integer fee; public String getId() { return id; } public void setId(String id) { this.id = id; } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getOtherPhone() { return otherPhone; } public void setOtherPhone(String otherPhone) { this.otherPhone = otherPhone; } public Integer getSmsType() { return smsType; } public void setSmsType(Integer smsType) { this.smsType = smsType; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public Integer getFee() { return fee; } public void setFee(Integer fee) { this.fee = fee; } //重写equals方法 //判断只需要该条 的 userId、phone、otherPhone、smsType相同即可判定此为相同 @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } SolrSmsDetails solrSmsDetails = (SolrSmsDetails) obj; if (userId != solrSmsDetails.userId) { return false; } if (phone != null ? !phone.equals(solrSmsDetails.phone) : solrSmsDetails.phone != null) { return false; } if (otherPhone != null ? !otherPhone.equals(solrSmsDetails.otherPhone) : solrSmsDetails.otherPhone != null) { return false; } if (smsType != null ? !smsType.equals(solrSmsDetails.smsType) : solrSmsDetails.smsType != null) { return false; } if (date != null ? !date.equals(solrSmsDetails.date) : solrSmsDetails.date != null) { return false; } if (fee != null ? !fee.equals(solrSmsDetails.fee) : solrSmsDetails.fee != null) { return false; } return true; } }
本文共计3954个文字,预计阅读时间需要16分钟。
表格式存储客户端创建,导入包:javaimport com.alicloud.openservices.tablestore.ClientConfiguration;import com.alicloud.openservices.tablestore.SyncClient;import com.alicloud.openservices.tablestore.model.Always;
package com.mimidai.common.utils.table; import com.alicloud.openservices.tablestore.ClientConfiguration; import com.alicloud.openservices.tablestore.SyncClient; import com.alicloud.openservices.tablestore.model.AlwaysRetryStrategy; import com.mimidai.common.utils.PropertiesUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * 创建表格存储client Created by EVE on 2017-06-22. */ @Configuration //@PropertySource("classpath:application-develop.properties") public class TableClientConfig { private static Logger logger = LoggerFactory.getLogger("log.hbase.TableClientConfig"); // @Value("${TableClientConfig.endPoint}") // private String endPoint; // @Value("${TableClientConfig.accessId}") // private String accessId; // @Value("${TableClientConfig.accessKey}") // private String accessKey; // @Value("${TableClientConfig.instanceName}") // private String instanceName; //生产配置 start //内网地址 // private String endPoint = "192.168.3.17:80/"; // private String accessId = "XXXX"; // private String accessKey = "XXXXXXXXXXXXXXX"; // private String instanceName = "xxx"; //生产配置 end //测试 环境 start //内网地址 // private String endPoint = "xxxxxxxxx/"; //外网地址 // private static final String endPoint = "xxx-test.cn-beijing.ots.aliyuncs.com"; // private String accessId = "XXXXXXXXXXXX"; // private String accessKey = "XXXXXXXXXXXXXXXXXXX"; // private String instanceName = "test"; private static final String endPoint = PropertiesUtils.getProperties().getProperty("table_client_end_point"); private static final String accessId = PropertiesUtils.getProperties().getProperty("table_client_access_id"); private static final String accessKey = PropertiesUtils.getProperties().getProperty("table_client_access_key"); private static final String instanceName = PropertiesUtils.getProperties().getProperty ("table_client_instance_name"); //测试 换将 end @Bean public SyncClient createClient() { logger.info("开始调用createClient方法"); // ClientConfiguration提供了很多配置项,以下只列举部分。 ClientConfiguration clientConfiguration = new ClientConfiguration(); // 设置建立连接的超时时间。 clientConfiguration.setConnectionTimeoutInMillisecond(5000); // 设置socket超时时间。 clientConfiguration.setSocketTimeoutInMillisecond(5000); // 设置重试策略,若不设置,采用默认的重试策略。 clientConfiguration.setRetryStrategy(new AlwaysRetryStrategy()); logger.info("返回创建表格存储cleint"); return new SyncClient(endPoint, accessId, accessKey, instanceName, clientConfiguration); } } 表格存储 接口
package com.mimidai.common.dao.table;
import com.alicloud.openservices.tablestore.model.PrimaryKey;
import com.mimidai.common.dto.SolrSmsDetails;
import com.mimidai.common.utils.persistence.Page;
import java.util.List;
/**
* Created by EVE on 2017-06-22.
*/
public interface TableSolrSmsDetailsDao {
void add(List
package com.mimidai.common.utils.table;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.alicloud.openservices.tablestore.SyncClient;
import com.alicloud.openservices.tablestore.model.BatchWriteRowRequest;
import com.alicloud.openservices.tablestore.model.Column;
import com.alicloud.openservices.tablestore.model.ColumnValue;
import com.alicloud.openservices.tablestore.model.GetRowRequest;
import com.alicloud.openservices.tablestore.model.GetRowResponse;
import com.alicloud.openservices.tablestore.model.PrimaryKey;
import com.alicloud.openservices.tablestore.model.PrimaryKeyBuilder;
import com.alicloud.openservices.tablestore.model.PrimaryKeyValue;
import com.alicloud.openservices.tablestore.model.Row;
import com.alicloud.openservices.tablestore.model.RowPutChange;
import com.alicloud.openservices.tablestore.model.RowUpdateChange;
import com.alicloud.openservices.tablestore.model.SingleRowQueryCriteria;
import com.alicloud.openservices.tablestore.model.UpdateRowRequest;
import com.mimidai.common.dao.table.TableSolrSmsDetailsDao;
import com.mimidai.common.dao.user.UserPhoneCheckDao;
import com.mimidai.common.dao.user.UserPhoneCheckHistoryDao;
import com.mimidai.common.dto.SolrSmsDetails;
import com.mimidai.common.pay.MD5Util;
import com.mimidai.common.utils.persistence.Page;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* core1 短信接口 表结构如下 主键 details_queryTime1 details_queryTime …. userId phone json(最多2M) json
* (最多2M) ... userId phone
* json(最多2M) json(最多2M) ... ...
*
* Created by EVE on 2017-06-22.
*/
@Repository
public class TableSolrSmsDetailsDaoImpl implements TableSolrSmsDetailsDao {
@Autowired
@Qualifier("createClient")
private SyncClient client;
private final String TABLENAME = "smsDetails";
@Autowired
private UserPhoneCheckDao userPhoneCheckDao;
@Autowired
private UserPhoneCheckHistoryDao userPhoneCheckHistoryDao;
//日志
private static final Logger logger = LoggerFactory.getLogger("log.tableStore.TableSolrSmsDetailsDaoImpl");
/**
* 逻辑变更 暂时注释 请勿删除
*
* 添加非空用户到表格存储 每次只查一个用户 一个电话 相当于(user+phone唯一)
* 添加逻辑 需要判断
* 1.该条信息是否在表格存储中已经存在,如果存在,新传入的solrSmsDetailses 只包含增量数据,需要做增量操作(先查再将两处结果集合并)
* 2.该条信息之前没有,直接添加即可
*/
// @Override
// public void add(List
>() {}.getType()); resultList.addAll(columnList); } } long endTime = System.currentTimeMillis(); float excTime = (float) (endTime - startTime) / 1000; logger.info("tableStore(core1)查询方法query填装List成功,resultList={}是否为空,query方法体执行时间excTime:", CollectionUtils .isEmpty(resultList), excTime, getUserIdAndPhone(solrSmsDetails)); return resultList; } /** * 更新通用方法 */ // @Override // public Boolean updateRow(List
package com.mimidai.common.dto; import com.google.gson.annotations.Expose; import org.apache.solr.client.solrj.beans.Field; /** * 短信详单 * * @author liang */ public class SolrSmsDetails { @Field @Expose(serialize = false) private String id; @Field @Expose private Long userId; @Field @Expose private String phone; @Field @Expose private String otherPhone; @Field @Expose private Integer smsType; @Field @Expose private String date; @Field @Expose private Integer fee; public String getId() { return id; } public void setId(String id) { this.id = id; } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getOtherPhone() { return otherPhone; } public void setOtherPhone(String otherPhone) { this.otherPhone = otherPhone; } public Integer getSmsType() { return smsType; } public void setSmsType(Integer smsType) { this.smsType = smsType; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public Integer getFee() { return fee; } public void setFee(Integer fee) { this.fee = fee; } //重写equals方法 //判断只需要该条 的 userId、phone、otherPhone、smsType相同即可判定此为相同 @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } SolrSmsDetails solrSmsDetails = (SolrSmsDetails) obj; if (userId != solrSmsDetails.userId) { return false; } if (phone != null ? !phone.equals(solrSmsDetails.phone) : solrSmsDetails.phone != null) { return false; } if (otherPhone != null ? !otherPhone.equals(solrSmsDetails.otherPhone) : solrSmsDetails.otherPhone != null) { return false; } if (smsType != null ? !smsType.equals(solrSmsDetails.smsType) : solrSmsDetails.smsType != null) { return false; } if (date != null ? !date.equals(solrSmsDetails.date) : solrSmsDetails.date != null) { return false; } if (fee != null ? !fee.equals(solrSmsDetails.fee) : solrSmsDetails.fee != null) { return false; } return true; } }

