Solr 检索结果集List<SolrDocument> 转换为指定业务对象总结

2023-11-03

前提说明:从solr结果集中取数据,取到了结果集,但是结果集是一个map,而我想要得到的是一个对象,怎么处理呢? 我总计如下三种方法:

第一种:solrDocument中提供了一个获取每个field对应值的方法,使用此方法获取所有的field对应的值,set到类中:

功能代码如下:

private List<Product> setProductData(SolrDocumentList list) {
        List<Product> datas = new ArrayList<Product>();
        String jsonStr = "";
        Product item = null;
        for (SolrDocument solrDocument : list) {
            item = new Product();
            item.setId((Long)solrDocument.getFieldValue("id"));
            item.setProduct(solrDocument.getFieldValue("product").toString());
            item.setOrderDate((Date)solrDocument.getFieldValue("orderDate"));
            ...
            
            datas.add(item);
        }
        return datas;
    }

第二种:使用了BeanUtils工具+反射,通过反射,获取solrDocument中的所有key和value,然后利用BeanUtils.setProperty(bean, name, value);方法,给Product设置属性,这样也有缺点,就是反射过程中容易出现异常,另外更严重的是此方法对Date类型的属性不能处理,而Product中有Date类型的属性,如果非要使用这种方案,就要写date类型的转换类,无疑增加了代码量。

private List<Product> setProductData(SolrDocumentList list) {
        List<Product> datas = new ArrayList<Product>();
        String jsonStr = "";
        Product item = null;
        for (SolrDocument solrDocument : list) {
            item = new Product();
            Long id =SimpleTypeConverterUtil.convertIfNecessary(solrDocument.getFieldValue("id",Lon.class)
            BeanUtils.setProperty(item, "id", id);
            String product = SimpleTypeConverterUtil.convertIfNecessary(solrDocument.getFieldValue("product",String.class)
            BeanUtils.setProperty(item, "product", product);
            Date orderDate = SimpleTypeConverterUtil.convertIfNecessary(solrDocument.getFieldValue("orderDate,Date.class)
            BeanUtils.setProperty(item, "orderDate", orderDate);
            ...
            
            datas.add(item);
        }
        return datas;
    }
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.SimpleTypeConverter;

import com.zzg.common.convert.DateEditor;

/**
 * spring type converter 
 * @author Administrator
 *
 */
public class SimpleTypeConverterUtil {
	public static final Logger log = LoggerFactory.getLogger(SimpleTypeConverterUtil.class);
	
	private static final SimpleTypeConverter typeConverterDelegate = new SimpleTypeConverter();
	static{
		typeConverterDelegate.registerCustomEditor(Date.class, new DateEditor());
	}
	
	/**
	 * @param <T>
	 * @param value  待转换值,一般字符串
	 * @param requiredType 转后类型类对象
	 * @return
	 */
	public static <T> T convertIfNecessary(Object value, Class<T> requiredType) {
		T rs = null;
		try {
			rs = typeConverterDelegate.convertIfNecessary(value, requiredType);
		} catch (Exception e) {
			log.info(e.getMessage());
			if(requiredType == int.class || requiredType == Integer.class){
				rs = (T)Integer.valueOf(0);
			}
		}
		return rs;
	}
	
}
package com.zzg.common.convert;

import java.beans.PropertyEditorSupport;

import com.zzg.common.util.DateUtils;

public class DateEditor extends PropertyEditorSupport {
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		setValue(DateUtils.formatDateStr(text));
	}
}
package com.zzg.common.util;

import java.lang.management.ManagementFactory;
import java.text.DateFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 */
public class DateUtils {
	
	public static final Logger log = LoggerFactory.getLogger(DateUtils.class);
	
	public static final String YYYY = "yyyy" ;

    public static final String YYYY_MM = "yyyy-MM" ;

    public static final String YYYY_MM_DD = "yyyy-MM-dd" ;

    public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss" ;

    public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss" ;

    private static String[] parsePatterns = {
            YYYY_MM_DD , YYYY_MM_DD_HH_MM_SS , "yyyy-MM-dd HH:mm" , YYYY_MM ,
            "yyyy/MM/dd" , "yyyy/MM/dd HH:mm:ss" , "yyyy/MM/dd HH:mm" , "yyyy/MM" ,
            "yyyy.MM.dd" , "yyyy.MM.dd HH:mm:ss" , "yyyy.MM.dd HH:mm" , "yyyy.MM"};

    /**
     * 获取当前Date型日期
     *
     * @return Date() 当前日期
     */
    public static Date getNowDate() {
        return new Date();
    }

    /**
     * 获取当前日期, 默认格式为yyyy-MM-dd
     *
     * @return String
     */
    public static String getDate() {
        return dateTimeNow(YYYY_MM_DD);
    }

    public static final String getTime() {
        return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
    }

    public static final String dateTimeNow() {
        return dateTimeNow(YYYYMMDDHHMMSS);
    }

    public static final String dateTimeNow(final String format) {
        return parseDateToStr(format, new Date());
    }

    public static final String dateTime(final Date date) {
        return parseDateToStr(YYYY_MM_DD, date);
    }

    public static final String parseDateToStr(final String format, final Date date) {
    	if (date == null) {
            return null;
        }

        Format formatter = new SimpleDateFormat(format);
        return formatter.format(date);
    }

    /**
     * 获取服务器启动时间
     */
    public static Date getServerStartDate() {
        long time = ManagementFactory.getRuntimeMXBean().getStartTime();
        return new Date(time);
    }
    
    private static final List<DateFormat> formarts = new ArrayList<>(5);
	static {
		formarts.add(new SimpleDateFormat("yyyy-MM"));
		formarts.add(new SimpleDateFormat("yyyy-MM-dd"));
		formarts.add(new SimpleDateFormat("yyyy-MM-dd hh:mm"));
		formarts.add(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"));
		formarts.add(new SimpleDateFormat("yyyy.MM.dd"));
	}

	public static Date formatDateStr(String source) {
		String value = source.trim();
		if ("".equals(value)) {
			return null;
		}
		try {
			if (source.matches("^\\d{4}-\\d{1,2}$")) {
				return formarts.get(0).parse(source);
			} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) {
				return formarts.get(1).parse(source);
			} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) {
				return formarts.get(2).parse(source);
			} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) {
				return formarts.get(3).parse(source);
			} else if (source.matches("^\\d{4}.\\d{1,2}.\\d{1,2}$")) {
				return formarts.get(4).parse(source);
			} else {
				throw new IllegalArgumentException("Invalid boolean value '" + source + "'");
			}
		} catch (Exception e) {
			log.warn("DateUtils.formatDateStr error", e);
			return null;
		}
	}

    /**
     * 计算两个时间差
     */
    public static String getDatePoor(Date endDate, Date nowDate) {
        long nd = (long)1000 * 24 * 60 * 60;
        long nh = (long)1000 * 60 * 60;
        long nm = (long)1000 * 60;
        // 获得两个时间的毫秒时间差异
        long diff = endDate.getTime() - nowDate.getTime();
        // 计算差多少天
        long day = diff / nd;
        // 计算差多少小时
        long hour = diff % nd / nh;
        // 计算差多少分钟
        long min = diff % nd % nh / nm;
        // 计算差多少秒//输出结果
        return day + "天" + hour + "小时" + min + "分钟" ;
    }
    
    /**
     * 增加日期
     *
     * @param date
     * @param field  Calendar.MONTH,Calendar.DAY_OF_YEAR
     * @param amount 正数为将来时间, 负数为过去时间
     * @return
     */
    public static Date getAddDate(Date date, int field, int amount) {
        Calendar cl = Calendar.getInstance();
        cl.setTime(date);
        cl.add(field, amount);
        Date dateFrom = cl.getTime();
        return dateFrom;
    }
    
    /**
     * 获取前几周
     *
     * @param date
     * @return
     */
    public static Date getBeforeWeek(Date date, int week) {
        return getAddDate(date, Calendar.WEEK_OF_YEAR, week);
    }
 
    /**
     * 获取前几天
     *
     * @param date
     * @return
     */
    public static Date getBeforeDay(Date date, int day) {
        return getAddDate(date, Calendar.DAY_OF_YEAR, day);
    }
 
    /**
     * 获取前几月
     *
     * @param date
     * @return
     */
    public static Date getBeforeMouth(Date date, int mouth) {
        return getAddDate(date, Calendar.MONTH, mouth);
    }
 
    /**
     * 获取前几年
     *
     * @param date
     * @return
     */
    public static Date getBeforeYear(Date date, int year) {
        return getAddDate(date, Calendar.YEAR, year);
    }
 
 
    /**
     * 获取后几周
     *
     * @param date
     * @return
     */
    public static Date getAfterWeek(Date date,int week) {
        return getAddDate(date, Calendar.WEEK_OF_YEAR, week);
    }
 
    /**
     * 获取后几天
     *
     * @param date
     * @return
     */
    public static Date getAfterDay(Date date, int day) {
        return getAddDate(date, Calendar.DAY_OF_YEAR, day);
    }
 
    /**
     * 获取后几月
     *
     * @param date
     * @return
     */
    public static Date getAfterMouth(Date date, int month) {
        return getAddDate(date, Calendar.MONTH, month);
    }
 
    /**
     * 获取后几年
     *
     * @param date
     * @return
     */
    public static Date getAfterYear(Date date, int year) {
        return getAddDate(date, Calendar.YEAR, year);
    }


}

第三种:先将solrDocument类转换为json,然后再将此json转换为我要的业务对象类

/**
	 * 
	 * @Title: getCommonsHttpSolrServer @Description: HttpSolrClient
	 *         初始化 @param: @return @param: @throws
	 *         MalformedURLException @return: HttpSolrClient @throws
	 */
	protected HttpSolrServer  getHttpSolrServer(HttpServletRequest request, String solrCoreName) {
		String solruri = "http://" + request.getServerName() + ":" + request.getServerPort() + "/solr-webapp/";
		solruri = ApplicationPropertiesHolder.getProperty("request.solr.uri", solruri);
		solruri = solruri + solrCoreName + "/";
		HttpSolrServer server =new HttpSolrServer(solruri);
		server.setParser(new XMLResponseParser()); // binary parser is used by
		// 设置重试次数
    	server.setMaxRetries(2);
    	// 设置超时时间
    	server.setConnectionTimeout(5000);
		return server;
	}
	
	// 设置查询条件
	public String getQueryCondition(String text) {
			if(StringUtils.isNotEmpty(text)){
				StringBuilder builder = new StringBuilder();
				List<String> filterStr = Arrays.asList(text.split("\\s+"));
				List<String> list = filterStr.stream().map(item ->{
					return "text:" + "*".concat(item).concat("*");
				}).collect(Collectors.toList());
			
				for (int i = 0; i < list.size(); i++) {
					builder.append(list.get(i));
					if (i < list.size() - 1) {
						builder.append(" and ");
					}
				}
				return builder.toString();
			}
			return StringUtils.EMPTY;
			
		}
	
	@RequestMapping(value = "/querySolr", method = { RequestMethod.POST })
	@ResponseBody
	@ApiOperation(value = "工程档案检索")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "text", value = "检索关键字", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "type", value = "检索类型", required = true, dataType = "String", paramType = "query"),
			@ApiImplicitParam(name = "page", value = "页码", required = false, dataType = "Integer", paramType = "query"),
			@ApiImplicitParam(name = "limit", value = "页次", required = false, dataType = "Integer", paramType = "query")
			
	})
	public Result querySolr(HttpServletRequest request,
			@RequestBody(required = false) HashMap<String, Object> entity) {
		
				String type = SimpleTypeConverterUtil.convertIfNecessary(entity.get("type"), String.class);
				entity.remove("type");
				if(StringUtils.isEmpty(type)){
					return Result.error("检索必须指定类型");
				}
				// 构建查询条件
				SolrQuery query = new SolrQuery();
				
				// 分页参数
				PageParam rb = super.initPageBounds(entity);
				query.setStart((rb.getPageNo() - 1) * rb.getLimit() > 0
						? (rb.getPageNo() - 1) * rb.getLimit() : 0);
				query.setRows(rb.getLimit());
				
				// 设置查询条件
				String condition = this.getQueryCondition(SimpleTypeConverterUtil.convertIfNecessary(entity.get("text"), String.class));
				if (StringUtils.isNotEmpty(condition)) {
					logger.error("query 条件:" + condition);
					query.setQuery(condition);
				}
		 
				// solr 查询
				QueryResponse queryResponse = null;
				try {
					HttpSolrServer httpSolrServer = this.getHttpSolrServer(request, type);
					queryResponse = httpSolrServer.query(query);
		 
				} catch (SolrServerException e) {
					// TODO Auto-generated catch block
					logger.error("solr 检索异常:{}", e.getMessage(), e);
					return Result.error("档案检索异常");
				}
		 
				// solr 查询结果分页
				
				List<SolrDocument> list = queryResponse.getResults();
				if(CollectionUtils.isEmpty(list)){
					return Result.error("档案未检索到相关数据");
				}
				PageData<Object> page = getSolrResult(rb, queryResponse, list, type);
				return Result.ok().setData(page);
			
	}

	/**
	 * 转换solr 检索结果对象
	 * @param rb
	 * @param queryResponse
	 * @param list
	 * @param type
	 * @return
	 */
	private PageData<Object> getSolrResult(PageParam rb, QueryResponse queryResponse, List<SolrDocument> list, String type) {
		List<Object> maps =  list.stream().map(item->{
				
				String json = JSON.toJSONString(item);
				if(SolrIndexEnum.ArchInfo.getIndex().equalsIgnoreCase(type)){
					return JSON.parseObject(json, ArchInfo.class);	
				} else if(SolrIndexEnum.ContractUnitInfo.getIndex().equalsIgnoreCase(type)){
					return JSON.parseObject(json, ContractUnitInfo.class);
				} else if(SolrIndexEnum.EngBaseInfo.getIndex().equalsIgnoreCase(type)){
					return JSON.parseObject(json, EngBaseInfo.class);
				} else {
					return JSON.parseObject(json, IndividualInfo.class);
				}				
		}).collect(Collectors.toList());
		
		PageData<Object> page = new PageData<Object>();
		page.setData(maps);
		page.setTotalCount(queryResponse.getResults().getNumFound() != 0 ? queryResponse.getResults().getNumFound() : 0);
		page.setPageSize(rb.getLimit());
		page.setPageNum(rb.getPageNo());
		return page;
	}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Solr 检索结果集List<SolrDocument> 转换为指定业务对象总结 的相关文章

  • 如何从 Solr 查询中获取 tf 和 idf 分数?

    以下 Solr 文档 https cwiki apache org confluence display solr Function Queries https cwiki apache org confluence display sol
  • 使用多个字段对 solr 搜索结果进行排序 (solrj)

    我需要根据两个因素对从 apache solr 返回的结果进行排序 我们的系统中有三个实体由 solr 索引 组 项目和数据集 在结果中我希望首先显示数据集 然后是项目 然后是组 但我仍然希望它尊重每种类型的评分值 因此 例如 结果将是 得
  • 仅根据lucene中term出现次数较多的文档来计算分数

    我开始研究基于 lucene net 引擎的简历检索 文档 组件 它工作得很好 它会获取文档并根据 VSM 背后的理念是 查询词出现在 a 中的次数 文档相对于数量 该术语出现在所有 集合中的文档越多 该文件的相关内容是 询问 Lucene
  • SOLR 中的子字符串匹配

    我似乎无法弄清楚如何使用 SOLR 查找子字符串匹配 我已经根据前缀找出了匹配 这样我就可以让火腿与汉堡包匹配 我如何搜索 汉堡 来匹配汉堡包 我试过burger但这引发了错误 或 不允许作为 WildcardQuery 中的第一个字符 如
  • Lucene 上打开的文件太多错误

    我正在进行的项目是对一定数量的数据 长文本 建立索引 并将它们与每个时间间隔 大约 15 到 30 分钟 的单词列表进行比较 一段时间后 比如说第 35 轮 在开始索引第 36 轮的新数据集时 发生了此错误 ERROR 2011 06 01
  • lucene:如何添加不重复的文档

    就我而言 插入 lucene 索引的每个文档都有其唯一的 ID 当向lucene索引添加新文档时 如果该文档已经存在于索引中 则不应将该文档插入到索引中 如何实施这一战略 我想我应该先用docId搜索文档 如果lucene找不到该文档 那么
  • 更改 SOLR 默认连接

    我正在使用嵌入 SOLR 的应用程序 SOLR 在 Tomcat 的 webapp 区域中像一场战争一样运行 是否有 SOLR 配置允许我切换搜索的默认 SOLR 行为以假定 AND 而不是 OR 作为连接运算符 在您的模式文件中添加 或修
  • SolrNet:过滤查询时保留 Facet 计数

    当我查询时 我收到以下方面 Field1 Key Best Facet 1 Value 999 Key Best Facet 2 Value 999 Field2 Key Second Best Facet 1 Value 421 Key
  • 如何在不使用 SPLITSHARD 的情况下动态向 SolrCloud 添加节点?

    我已经设置了Solr云有 4 个碎片 我向 SolrCloud 添加了 8 个节点 4 个领导者和 4 个副本 每个节点运行在不同的机器上 但后来我发现我的数据越来越多 每天400万文件 这样我的 4 个分片就不够用了 因此 我想动态地向该
  • solr索引嵌套文档

    solr支持嵌套文档吗 有没有更好的方法来实现这种文档
  • SOLR - 过滤器查询中的正则表达式

    我想在 fq 中实现 Regex 但以前从未实现过 我的属性中有以下值 字段类型为 小写 Prop company1 city1 state1 country1 高级分析化学家 芝加哥 我想根据正则表达式过滤结果 正则表达式应该与上面的内容
  • 复杂的 SOLR 查询,包括 NOT 和 OR

    我对 SOLR 搜索有一些相当复杂的要求 我需要针对标记内容的数据库执行这些搜索 我需要首先过滤数据库以获取与我的过滤器标签匹配的结果 任何具有黑名单中的标签的结果都应被删除 除非它们也包含白名单中的标签 假设我想检索所有标记为 森林 或
  • SLF4J 日志记录到文件 vs. DB vs. Solr

    我需要一些关于 SLF4J 日志记录的建议 目前 我们正在为 Java Web 应用程序使用 SLF4J 日志记录 log4j 绑定 该应用程序使用简单的 ConsoleAppender 我们的下一步是研究可以保存日志的地方 我们的应用程序
  • openNLP 与 Solr 集成时出现异常

    我正在尝试将 openNLP 与 Solr 6 1 0 集成 我配置了架构和 solrconfig 文件 详细信息请参见 wiki 链接 https wiki apache org solr OpenNLP https wiki apach
  • Solr 您的意思是(拼写检查组件)

    我在我的应用程序中使用 solr 并集成了拼写检查组件 但我遇到了一些问题 第一的 当我输入一个用空格分隔的术语时 他们会给我每个术语的更正 Eg 水 gt 什么术语 但事实是watters 第二 当我输入一些带有错误术语的短语时 尽管其他
  • Lucene,索引已经/外部标记化的标记并定义自己的分析过程

    在使用Lucene的过程中 我有点失望 我不明白或不明白我应该如何继续为任何 Lucene 分析器提供已经可直接索引的东西 或者我应该如何继续创建我自己的分析器 例如 如果我有一个List
  • solr + haystack + django 我在哪里放置 schema.xml?

    我刚刚安装Solr and Haystack for a Django我正在做的项目 下列的this http docs haystacksearch org dev tutorial html Haystack教程 我创建了一个 sche
  • 如何使用 solrnet 在 solr 中使字段搜索不区分大小写

    在 solr 模式中我有如下字段
  • 在 Solr 中实现术语关联挖掘的最简单方法是什么?

    关联挖矿似乎为检索提供了良好的结果相关术语在文本语料库中 有很多关于这个主题的著作 其中包括著名的LSA http en wikipedia org wiki Latent semantic analysis方法 挖掘关联最直接的方法是构建
  • Solr 索引时间提升 VS 查询时间提升?

    问题 1 我们可以只进行查询时间提升 使用 dismax 而不在索引时间提及提升值吗 问题 2 与查询时间提升相比 索引时间提升有何优点 缺点 反之亦然 查询时间和索引时间提升 在索引时 您可以选择提升特定文档 整个文档或仅一个字段 它作为

随机推荐

  • 静态分析-常量传播

    提示 文章写完后 目录可以自动生成 如何生成可参考右边的帮助文档 文章目录 前言 一 ConstantPropagation 1 newBoundaryFact CFG 2 newInitialFact 3 void meetInto CP
  • vue scoped属性的作用

    当style标签具有该scoped属性时 其CSS将仅应用于当前组件的元素 作用功能 实现组件的私有化 不对全局造成样式污染 表示当前style属性只属于当前模块虽然方便但是我们需要慎用 因为当我们使用公共组件时会造成很多困难 增加难度 想
  • ValueError: Attempt to convert a value (1) with an unsupported type xx to a Tensor

    如题所述问题 其本质是tensorflow版本不兼容的问题 但是为了一个错误去更新tensorflow版本 往往会消耗较长时间 而且说不定会引起其他地方依赖的问题 关于该问题可以考虑从不同角度进行考量 迂回解决 比如我在实验中 在使用a N
  • Flowable

    flowable介绍 flowable 是一个业务流程管理 BPM 和工作流系统 适用于开发人员和系统管理员 它是著名 Java 工作流引擎 Activiti 的原作者从 Activiti 分支创建的新工作流引擎 其核心是超快速 稳定的 B
  • 了解 ceil 和 floor 函数:C++ 中的取整函数

    在许多实际应用中 我们需要对浮点数进行取整操作 C 中提供了两个非常有用的函数 即 ceil 和 floor 用于进行向上取整和向下取整 这两个函数是 C 标准库 头文件中的函数 下面我们分别来了解一下它们的具体用法和示例 ceil 函数
  • ReactiveUI 入门

    ReactiveUI入门 ReactiveUI使您能够使用MVVM模式构建反应式 可测试和可组合的UI代码 请参阅我们的ReactiveUI文档手册 我们还有一个完整的跨平台演示应用程序 入门 要开始使用 请访问我们的 安装 页面 在引人注
  • CG v-光照着色探索:Educoder

    CG v 光照着色探索 Educoder 光照着色是计算机图形学中一个关键的概念 它可以使得渲染出的场景更加逼真和具有立体感 在本文中 我们将深入探讨光照着色的原理和实现 并使用源代码来演示 首先 让我们来了解一下什么是光照着色 在计算机图
  • 隐马尔可夫模型(HMM)攻略

    隐马尔可夫模型 Hidden Markov Model HMM 最初由 L E Baum 和其它一些学者发表在一系列的统计学论文中 随后在语言识别 自然语言处理以及生物信息等领域体现了很大的价值 平时 经常能接触到涉及 HMM 的相关文章
  • [Spring Boot]03 Maven常用的打包(packaging)类型

    目录 什么是pom xml Maven常用的打包类型 jar war pom 什么是pom xml POM是项目对象模型 Project Object Model 的简称 它是Maven项目中的一个XML文件 pom xml 此文件用于管理
  • 常见编译Warning的解决方法

    Warning 1 always inline redefined enabled by default 意思是 always inline 重复定义了 位置分别是gcc arm none eabi 4 8 4 include fixed
  • java实体类根据某个或多个属性排序

    public class ListUtils 对list的元素按照多个属性名称排序 list元素的属性可以是数字 byte short int long float double等 支持正数 负数 0 char String java ut
  • cv2.resize

    import cv2 img cv2 imread home img python png cv2 IMREAD UNCHANGED print Original Dimensions img shape scale percent 60
  • shell脚本学习-04

    65 IFS 文本分隔符 默认的文本分隔符是 但是可以手动设置为其他的 如 cities Delhi chennai bangaluru kolkata old ifs IFS IFS for place in cities do echo
  • Chrome 浏览器的 PDF 插件使用了 Foxit PDF SDK

    Chrome 浏览器的 PDF 插件使用了 Foxit PDF SDK 2010年8月22日 Chrome的内置PDF插件实际上有使用Foxit的PDF SDK 如果你查看这个网页会找到Chromium的一些PDF功能多次用到Foxit的S
  • 【C++】C++的四种类型转换

    文章目录 一 隐式类型转换和显示类型转换 二 C 的四种类型转换 2 1 static cast 相似转化 2 2 reinterpret cast 不同类型转化 2 3 const cast 去除const属性 2 4 dynamic c
  • 利用枚举类型变量求从5种颜色球中取3个不同颜色球的取法

    利用枚举类型变量求从5种颜色球中取3个不同颜色球的取法 C程序设计 第二版 谭浩强 著 11 9 例11 3 口袋里有红 黄 蓝 白 黑5种颜色的若干个 每次从口袋中取出3个球 问得到3种不同色的球的可能取法 输出每种排列的情况 程序 在V
  • CASAIM与南京航空航天大学在自动化叶片曲面分析系统开展合作,推动航空航天发动机零部件自动化3D检测进程

    近期 CASAIM与南京航空航天大学在自动化叶片曲面分析系统展开深入合作 充分发挥双方在航空航天和智能检测领域优势 共同推动航空航天发动机零部件自动化3D检测进程 南京航空航天大学创建于1952年10月 是新中国自己创办的第一批航空高等院校
  • 【python】python求解矩阵的转置(详细讲解)

    博 主 米码收割机 技 能 C Python语言 公众号 测试开发自动化 获取源码 商业合作 荣 誉 阿里云博客专家博主 51CTO技术博主 专 注 专注主流机器人 人工智能等相关领域的开发 测试技术 python求解矩阵的转置 详细讲解
  • pytorch:交换tensor的维度

    在pytorch中 tensor有两个成员函数可以实现维度交换 分别时transpose 和permute transpose 该函数可以交换tensor的任意两个维度 但是该函数一次只有两个参数 即一次只能交换两个维度 import to
  • Solr 检索结果集List<SolrDocument> 转换为指定业务对象总结

    前提说明 从solr结果集中取数据 取到了结果集 但是结果集是一个map 而我想要得到的是一个对象 怎么处理呢 我总计如下三种方法 第一种 solrDocument中提供了一个获取每个field对应值的方法 使用此方法获取所有的field对