index optimized

优化solr全量建索引

主要优化从数据库取数据这一块。


先简单为读取某个单表数据:该表数据很多娄,数据库为MySQL。

旧的建索引设计:

之前的设计是分段读取数据,可以按自增主键分段或者按记录更新的时间截分段取。但由于数据模型是可增删改查,这种更新会导致按自增id的数据在有些地方比较稀疏,而按记录的更新时间截,也有可能在某个时间段里更新大量数据,所以也会有不同时间段数据过稀或者过密的情况,这种情况导致分段取数据调控不方便。。


所以一直以来solr的更新瓶颈一直是在读取数据那一块,因为是取数据跟发送数据多线程进行,实践得出花费的时间更多是在等待读取源。所以如果可以提高读取数据源的效率,那么索引时间可以缩短不少时间。



新的建索引设计 :

现在使用另一种方式读取数据源:


1)首先将远程的某个表数据写入到文件data.txt,字段以一定特殊符号间隔,方便分析,每行一条记录


2)将远程文件data.txt同步到本地机器,并处理掉某些特殊符号影响解析。

        a)这里要注意文件的一些特殊符号,导致分析失败。比如字段里包含有换行符或者分隔符。

         b)dump整个表数据到文件很快,记得写2g大小(300万)的数据,消耗30秒左右.

        c)使用linunx的rsync脚本拷贝远程文件到本地,同步时间100秒左右。

3)解析本地数据文件data.txt,并批量提交给solr

          a) 脚本程序要配置的dump 使用sql语句的字段,所以这里可以使用对应的sql(取字段名列表),获取该sql拿到的字段列表。有严格的顺序对应。

             b)以同样的顺序解析数据存到map.

             c)业务逻辑处理记录,封装数据包批量提交solr


4) solr提交的方式的优化:(主要是索引脚本跟solr服务在同一台机)

        a) solr 服务使用多core协助,一写core_w一读core_r

       b)使用EmbeddedSolrServer嵌入式提交给本地solr服务core_w。

       c)提交完数据后,发送命令切换solr的两个core.将core_w与core_r互换

       d)同步索引,将新的core_r的索引数据同步给其它子机的core_r

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
void ADC_Activate(void) { __IO uint32_t wait_loop_index = 0U; #if (USE_TIMEOUT == 1) uint32_t Timeout = 0U; /* Variable used for timeout management / #endif / USE_TIMEOUT / /## Operation on ADC hierarchical scope: ADC instance #####################/ / Note: Hardware constraint (refer to description of the functions / / below): / / On this STM32 series, setting of these features is conditioned to / / ADC state: / / ADC must be disabled. / / Note: In this example, all these checks are not necessary but are / / implemented anyway to show the best practice usages / / corresponding to reference manual procedure. / / Software can be optimized by removing some of these checks, if / / they are not relevant considering previous settings and actions / / in user application. / if (LL_ADC_IsEnabled(ADC1) == 0) { / Run ADC self calibration / LL_ADC_StartCalibration(ADC1, LL_ADC_CALIB_OFFSET); / Poll for ADC effectively calibrated / #if (USE_TIMEOUT == 1) Timeout = ADC_CALIBRATION_TIMEOUT_MS; #endif / USE_TIMEOUT / while (LL_ADC_IsCalibrationOnGoing(ADC1) != 0) { #if (USE_TIMEOUT == 1) / Check Systick counter flag to decrement the time-out value / if (LL_SYSTICK_IsActiveCounterFlag()) { if(Timeout-- == 0) { / Error: Time-out / Error_Handler(); } } #endif / USE_TIMEOUT / } / Delay between ADC end of calibration and ADC enable. / / Note: Variable divided by 2 to compensate partially / / CPU processing cycles (depends on compilation optimization). / wait_loop_index = (ADC_DELAY_CALIB_ENABLE_CPU_CYCLES >> 1); while(wait_loop_index != 0) { wait_loop_index--; } / Enable ADC / LL_ADC_Enable(ADC1); / Poll for ADC ready to convert / #if (USE_TIMEOUT == 1) Timeout = ADC_ENABLE_TIMEOUT_MS; #endif / USE_TIMEOUT / while (LL_ADC_IsActiveFlag_ADRDY(ADC1) == 0) { #if (USE_TIMEOUT == 1) / Check Systick counter flag to decrement the time-out value / if (LL_SYSTICK_IsActiveCounterFlag()) { if(Timeout-- == 0) { / Error: Time-out / Error_Handler(); } } #endif / USE_TIMEOUT / } / Note: ADC flag ADRDY is not cleared here to be able to check ADC / / status afterwards. / / This flag should be cleared at ADC Deactivation, before a new / / ADC activation, using function "LL_ADC_ClearFlag_ADRDY()". */ }请逐行解释代码
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值