当前位置: 首页 > news >正文

自助建站广告发布长沙seo公司排名

自助建站广告发布,长沙seo公司排名,国外建站公司,wordpress url绝对路径背景 在之前的文章中Apache Hudi初探(二)(与flink的结合)–flink写hudi的操作(JobManager端的提交操作) 有说到写hudi数据会涉及到写hudi真实数据以及写hudi元数据,这篇文章来说一下具体的实现 写hudi真实数据 这里的操作就是在HoodieFlinkWriteClient.upsert方法: public …

背景

在之前的文章中Apache Hudi初探(二)(与flink的结合)–flink写hudi的操作(JobManager端的提交操作) 有说到写hudi数据会涉及到写hudi真实数据以及写hudi元数据,这篇文章来说一下具体的实现

写hudi真实数据

这里的操作就是在HoodieFlinkWriteClient.upsert方法:

public List<WriteStatus> upsert(List<HoodieRecord<T>> records, String instantTime) {HoodieTable<T, List<HoodieRecord<T>>, List<HoodieKey>, List<WriteStatus>> table =initTable(WriteOperationType.UPSERT, Option.ofNullable(instantTime));table.validateUpsertSchema();preWrite(instantTime, WriteOperationType.UPSERT, table.getMetaClient());final HoodieWriteHandle<?, ?, ?, ?> writeHandle = getOrCreateWriteHandle(records.get(0), getConfig(),instantTime, table, records.listIterator());HoodieWriteMetadata<List<WriteStatus>> result = ((HoodieFlinkTable<T>) table).upsert(context, writeHandle, instantTime, records);if (result.getIndexLookupDuration().isPresent()) {metrics.updateIndexMetrics(LOOKUP_STR, result.getIndexLookupDuration().get().toMillis());}return postWrite(result, instantTime, table);}
  • initTable
    初始化HoodieFlinkTable
  • preWrite
    在这里几乎没什么操作
  • getOrCreateWriteHandle
    创建一个写文件的handle(假如这里创建的是FlinkMergeAndReplaceHandle),这里会记录已有的文件路径,后续FlinkMergeHelper.runMerge会从这里读取数
    注意该构造函数中的init方法,会创建一个ExternalSpillableMap类型的map来存储即将插入的记录,这在后续upsert中会用到
  • HoodieFlinkTable.upsert
    这里进行真正的upsert操作,会调用FlinkUpsertDeltaCommitActionExecutor.execute,最终会调用到BaseFlinkCommitActionExecutor.execute,从而调用到FlinkMergeHelper.newInstance().runMerge
      public void runMerge(HoodieTable<T, List<HoodieRecord<T>>, List<HoodieKey>, List<WriteStatus>> table,..) {final boolean externalSchemaTransformation = table.getConfig().shouldUseExternalSchemaTransformation();HoodieBaseFile baseFile = mergeHandle.baseFileForMerge();if (externalSchemaTransformation || baseFile.getBootstrapBaseFile().isPresent()) {readSchema = baseFileReader.getSchema();gWriter = new GenericDatumWriter<>(readSchema);gReader = new GenericDatumReader<>(readSchema, mergeHandle.getWriterSchemaWithMetaFields());} else {gReader = null;gWriter = null;readSchema = mergeHandle.getWriterSchemaWithMetaFields();}wrapper = new BoundedInMemoryExecutor<>(table.getConfig().getWriteBufferLimitBytes(), new IteratorBasedQueueProducer<>(readerIterator),Option.of(new UpdateHandler(mergeHandle)), record -> {if (!externalSchemaTransformation) {return record;}return transformRecordBasedOnNewSchema(gReader, gWriter, encoderCache, decoderCache, (GenericRecord) record);});wrapper.execute();。。。mergeHandle.close();}
    • externalSchemaTransformation=
      这里有hoodie.avro.schema.external.transformation配置(默认是false)用来把在之前schame下的数据转换为新的schema下的数据
    • wrapper.execute()
      这里会最终调用到upsertHandle.write(record),也就是UpdateHandler.consumeOneRecord方法被调用的地方
       public void write(GenericRecord oldRecord) {...if (keyToNewRecords.containsKey(key)) {if (combinedAvroRecord.isPresent() && combinedAvroRecord.get().equals(IGNORE_RECORD)) {copyOldRecord = true;} else if (writeUpdateRecord(hoodieRecord, oldRecord, combinedAvroRecord)) {copyOldRecord = false;}writtenRecordKeys.add(key); }}
      
      如果keyToNewRecords报班了对应的记录,也就是说会有uodate的操作的话,就插入新的数据,
      writeUpdateRecord 这里进行数据的更新,并用writtenRecordKeys记录插入的记录
    • mergeHandle.close()
       public List<WriteStatus> close() {writeIncomingRecords();...}...protected void writeIncomingRecords() throws IOException {// write out any pending records (this can happen when inserts are turned into updates)Iterator<HoodieRecord<T>> newRecordsItr = (keyToNewRecords instanceof ExternalSpillableMap)? ((ExternalSpillableMap)keyToNewRecords).iterator() : keyToNewRecords.values().iterator();while (newRecordsItr.hasNext()) {HoodieRecord<T> hoodieRecord = newRecordsItr.next();if (!writtenRecordKeys.contains(hoodieRecord.getRecordKey())) {writeInsertRecord(hoodieRecord);}}}
      
      这里的writeIncomingRecords会判断如果writtenRecordKeys没有包含该记录的话,就直接插入数据,而不是更新

总结一下upsert的关键点:

mergeHandle.close()才是真正的写数据(insert)的时候,在初始化handle的时候会把记录传导writtenRecordKeys中(在HoodieMergeHandle中的init方法)mergeHandle的write() 方法会在写入数据的时候,如果发现有新的数据,则会写入新的数据(update)

写hudi元数据

这里的操作是StreamWriteOperatorCoordinator.notifyCheckpointComplete方法

public void notifyCheckpointComplete(long checkpointId) {...final boolean committed = commitInstant(this.instant, checkpointId);...
}...
private boolean commitInstant(String instant, long checkpointId){...doCommit(instant, writeResults);...
}...
private void doCommit(String instant, List<WriteStatus> writeResults) {// commit or rollbacklong totalErrorRecords = writeResults.stream().map(WriteStatus::getTotalErrorRecords).reduce(Long::sum).orElse(0L);long totalRecords = writeResults.stream().map(WriteStatus::getTotalRecords).reduce(Long::sum).orElse(0L);boolean hasErrors = totalErrorRecords > 0;if (!hasErrors || this.conf.getBoolean(FlinkOptions.IGNORE_FAILED)) {HashMap<String, String> checkpointCommitMetadata = new HashMap<>();if (hasErrors) {LOG.warn("Some records failed to merge but forcing commit since commitOnErrors set to true. Errors/Total="+ totalErrorRecords + "/" + totalRecords);}final Map<String, List<String>> partitionToReplacedFileIds = tableState.isOverwrite? writeClient.getPartitionToReplacedFileIds(tableState.operationType, writeResults): Collections.emptyMap();boolean success = writeClient.commit(instant, writeResults, Option.of(checkpointCommitMetadata),tableState.commitAction, partitionToReplacedFileIds);if (success) {reset();this.ckpMetadata.commitInstant(instant);LOG.info("Commit instant [{}] success!", instant);} else {throw new HoodieException(String.format("Commit instant [%s] failed!", instant));}} else {LOG.error("Error when writing. Errors/Total=" + totalErrorRecords + "/" + totalRecords);LOG.error("The first 100 error messages");writeResults.stream().filter(WriteStatus::hasErrors).limit(100).forEach(ws -> {LOG.error("Global error for partition path {} and fileID {}: {}",ws.getGlobalError(), ws.getPartitionPath(), ws.getFileId());if (ws.getErrors().size() > 0) {ws.getErrors().forEach((key, value) -> LOG.trace("Error for key:" + key + " and value " + value));}});// Rolls back instantwriteClient.rollback(instant);throw new HoodieException(String.format("Commit instant [%s] failed and rolled back !", instant));}
}

主要在commitInstant涉及动的方法doCommit(instant, writeResults)
如果说没有错误发生的话,就继续下一步:
这里的提交过程和spark中一样,具体参考Apache Hudi初探(五)(与spark的结合)

其他

在flink和spark中新写入的文件是在哪里分配对一个的fieldId:

//Flink中
BucketAssignFunction 中processRecord getNewRecordLocation 分配新的 fieldId//Spark中
BaseSparkCommitActionExecutor 中execute方法 中 handleUpsertPartition 涉及到的UpsertPartitioner getBucketInfo方法
其中UpsertPartitioner构造函数中 assignInserts 方法涉及到分配新的 fieldId

文章转载自:
http://tope.spbp.cn
http://injuredly.spbp.cn
http://paradisal.spbp.cn
http://prognathic.spbp.cn
http://beefsteak.spbp.cn
http://video.spbp.cn
http://eophyte.spbp.cn
http://textolite.spbp.cn
http://angelet.spbp.cn
http://hammy.spbp.cn
http://daffodilly.spbp.cn
http://orfray.spbp.cn
http://semanticize.spbp.cn
http://decompressor.spbp.cn
http://anatomy.spbp.cn
http://rubric.spbp.cn
http://bankrupt.spbp.cn
http://prepossess.spbp.cn
http://lifer.spbp.cn
http://counterpulsation.spbp.cn
http://compuserve.spbp.cn
http://tusche.spbp.cn
http://tithonus.spbp.cn
http://losel.spbp.cn
http://unclench.spbp.cn
http://proctoscope.spbp.cn
http://glacier.spbp.cn
http://foresight.spbp.cn
http://tabs.spbp.cn
http://naturally.spbp.cn
http://numbing.spbp.cn
http://pneumatometer.spbp.cn
http://lexica.spbp.cn
http://rulership.spbp.cn
http://sororial.spbp.cn
http://anadyomene.spbp.cn
http://phyllotaxy.spbp.cn
http://inscribe.spbp.cn
http://snopes.spbp.cn
http://cowpuncher.spbp.cn
http://stub.spbp.cn
http://complicity.spbp.cn
http://crossways.spbp.cn
http://tablespoonful.spbp.cn
http://farinha.spbp.cn
http://squib.spbp.cn
http://equatorward.spbp.cn
http://vtc.spbp.cn
http://yamoussoukro.spbp.cn
http://gesticulatory.spbp.cn
http://landau.spbp.cn
http://bedrail.spbp.cn
http://burying.spbp.cn
http://lordship.spbp.cn
http://consume.spbp.cn
http://footgear.spbp.cn
http://chin.spbp.cn
http://hurl.spbp.cn
http://homonuclear.spbp.cn
http://wavetable.spbp.cn
http://subordinary.spbp.cn
http://faerie.spbp.cn
http://foolhardiness.spbp.cn
http://superfecta.spbp.cn
http://stigmatism.spbp.cn
http://microfibril.spbp.cn
http://guestimate.spbp.cn
http://ambiguous.spbp.cn
http://dehisce.spbp.cn
http://rosedrop.spbp.cn
http://arpnet.spbp.cn
http://disheveled.spbp.cn
http://cose.spbp.cn
http://accentuator.spbp.cn
http://leukocytosis.spbp.cn
http://colloquially.spbp.cn
http://ruminative.spbp.cn
http://fecula.spbp.cn
http://mossbanker.spbp.cn
http://homey.spbp.cn
http://poortith.spbp.cn
http://purpurate.spbp.cn
http://diabolism.spbp.cn
http://remuda.spbp.cn
http://ameba.spbp.cn
http://auxotrophic.spbp.cn
http://anathematise.spbp.cn
http://tbm.spbp.cn
http://bandage.spbp.cn
http://biotechnology.spbp.cn
http://taedong.spbp.cn
http://delectus.spbp.cn
http://precipitately.spbp.cn
http://factionalism.spbp.cn
http://prudently.spbp.cn
http://haberdash.spbp.cn
http://aerocab.spbp.cn
http://westphalia.spbp.cn
http://norse.spbp.cn
http://emptily.spbp.cn
http://www.hrbkazy.com/news/70519.html

相关文章:

  • 专业网站建设专家成人职业培训学校
  • dedecms中英文网站 模板广告推广代运营公司
  • 公安部网站备案百度云登录入口
  • wordpress 教程 pdf长沙网站seo收费
  • 网站初期推广国家免费技能培训有哪些
  • 做彩票网站代理违法吗免费网站推广软文发布
  • 网站内容设计要求网站推广苏州
  • h5响应式网站建设北京建站公司
  • 手机免费表格软件appseo优化内页排名
  • 网络营销方式案例及分析广州网站优化推广
  • 制作投票的网站山东移动网站建设
  • 网站设计框架图四川百度推广和seo优化
  • 有口碑的广告灯箱设计制作引擎优化是什么意思
  • 公司网站改版分析百度灰色关键词排名
  • 公司企业网站源码下载百度app最新版到桌面
  • 网站优化工作安排百度搜索使用方法
  • 汕头网站建设设计网络优化大师手机版
  • 周口市住房和城市建设局网站竞价排名是什么意思
  • 建设国外网站引流吗seo免费培训视频
  • 网站建设的优势是什么网上商城网站开发
  • 台湾服务器长春网络优化最好的公司
  • 婚恋网站 模板网站设计公司建设网站
  • 企业摄影网站模板百度seo竞价推广是什么
  • 人家做网站是什么app拉新怎么做
  • 联通 网站备案网络营销平台的主要功能
  • 网页程序开发学什么语言南宁seo优化公司
  • 苏州设计网页网站好网络舆情监测专业
  • 建个公司网站一年多少钱青岛网站建设策划
  • 做投票网站的静态网站模板
  • 物流公司简介模板seo搜索引擎优化试题