修正部分伪代码逻辑。调整代码可读性
This commit is contained in:
parent
9daaf26169
commit
9ab4fcfa14
|
|
@ -2,6 +2,7 @@ package com.a.eye.skywalking.storage.data;
|
|||
|
||||
import com.a.eye.datacarrier.consumer.IConsumer;
|
||||
import com.a.eye.skywalking.storage.data.file.DataFileWriter;
|
||||
import com.a.eye.skywalking.storage.data.index.IndexDBConnector;
|
||||
import com.a.eye.skywalking.storage.data.index.IndexMetaGroup;
|
||||
import com.a.eye.skywalking.storage.data.index.IndexOperator;
|
||||
import com.a.eye.skywalking.storage.data.index.IndexDBConnectorCache;
|
||||
|
|
@ -17,16 +18,20 @@ public class SpanDataConsumer implements IConsumer<SpanData> {
|
|||
@Override
|
||||
public void consume(List<SpanData> data) {
|
||||
|
||||
Iterator<IndexMetaGroup> iterator = fileWriter.write(data).group().iterator();
|
||||
Iterator<IndexMetaGroup> iterator = fileWriter.write(data).group();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
IndexMetaGroup metaGroup = iterator.next();
|
||||
IndexOperator indexOperator = IndexOperator.newOperator(cache.get(metaGroup.getTimestamp()));
|
||||
indexOperator.update(metaGroup.getMetaInfo());
|
||||
IndexOperator indexOperator = IndexOperator.newOperator(getDBConnector(metaGroup));
|
||||
indexOperator.batchUpdate(metaGroup);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private IndexDBConnector getDBConnector(IndexMetaGroup metaGroup){
|
||||
return cache.get(metaGroup.getTimestamp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(List<SpanData> list, Throwable throwable) {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.a.eye.skywalking.storage.block.index.BlockFinder;
|
|||
import com.a.eye.skywalking.storage.block.index.BlockIndexEngine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class IndexMetaCollections {
|
||||
|
|
@ -12,7 +13,7 @@ public class IndexMetaCollections {
|
|||
private List<IndexMetaInfo> metaInfo;
|
||||
private BlockFinder finder = BlockIndexEngine.newFinder();
|
||||
|
||||
public List<IndexMetaGroup> group() {
|
||||
public Iterator<IndexMetaGroup> group() {
|
||||
List<IndexMetaGroup> indexMetaGroups = new ArrayList<IndexMetaGroup>();
|
||||
for (IndexMetaInfo info : metaInfo) {
|
||||
long timestamp = finder.find(info.getStartTime());
|
||||
|
|
@ -30,7 +31,7 @@ public class IndexMetaCollections {
|
|||
metaGroup.addIndexMetaInfo(info);
|
||||
}
|
||||
|
||||
return indexMetaGroups;
|
||||
return indexMetaGroups.iterator();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,19 +18,10 @@ public class IndexOperator {
|
|||
}
|
||||
|
||||
|
||||
public void update(List<IndexMetaInfo> metaInfo) {
|
||||
public void batchUpdate(IndexMetaGroup metaGroup) {
|
||||
|
||||
}
|
||||
|
||||
private IndexDBConnector getConnector() {
|
||||
return connector;
|
||||
}
|
||||
|
||||
|
||||
public static IndexOperator newOperator(long timestamp) {
|
||||
return newOperator(new IndexDBConnector(timestamp));
|
||||
}
|
||||
|
||||
public static IndexOperator newOperator(IndexDBConnector indexDBConnector) {
|
||||
return new IndexOperator(indexDBConnector);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue