MCPcopy
hub / github.com/apache/echarts / filter

Method filter

src/data/DataStore.ts:606–661  ·  view source on GitHub ↗

* [NOTICE]: Performance-sensitive for large data.

(
        dims: DimensionIndex[],
        cb: FilterCb
    )

Source from the content-addressed store, hash-verified

604 * [NOTICE]: Performance-sensitive for large data.
605 */
606 filter(
607 dims: DimensionIndex[],
608 cb: FilterCb
609 ): DataStore {
610 if (!this._count) {
611 return this;
612 }
613
614 const newStore = this.clone();
615
616 const count = newStore.count();
617 const Ctor = getIndicesCtor(newStore._rawCount);
618 const newIndices = new Ctor(count);
619 const value = [];
620 const dimSize = dims.length;
621
622 let offset = 0;
623 const dim0 = dims[0];
624 const chunks = newStore._chunks;
625
626 for (let i = 0; i < count; i++) {
627 let keep;
628 const rawIdx = newStore.getRawIndex(i);
629 // Simple optimization
630 if (dimSize === 0) {
631 keep = (cb as FilterCb0)(i);
632 }
633 else if (dimSize === 1) {
634 const val = chunks[dim0][rawIdx];
635 keep = (cb as FilterCb1)(val, i);
636 }
637 else {
638 let k = 0;
639 for (; k < dimSize; k++) {
640 value[k] = chunks[dims[k]][rawIdx];
641 }
642 value[k] = i;
643 keep = (cb as FilterCb).apply(null, value);
644 }
645 if (keep) {
646 newIndices[offset++] = rawIdx;
647 }
648 }
649
650 // Set indices after filtered.
651 if (offset < count) {
652 newStore._indices = newIndices;
653 }
654 newStore._count = offset;
655 // Reset data extent
656 newStore._extent = [];
657
658 newStore._updateGetRawIdx();
659
660 return newStore;
661 }
662
663 /**

Callers 15

retrieveFunction · 0.45
wFunction · 0.45
jquery.min.jsFile · 0.45
store.jsFile · 0.45
mainFunction · 0.45
startTestsFunction · 0.45
testsFunction · 0.45
selectedTestsFunction · 0.45
unfinishedTestsFunction · 0.45
failedTestsFunction · 0.45
deleteMarkFunction · 0.45
sankeyLayoutFunction · 0.45

Calls 5

cloneMethod · 0.95
getIndicesCtorFunction · 0.85
_updateGetRawIdxMethod · 0.80
countMethod · 0.65
getRawIndexMethod · 0.65

Tested by

no test coverage detected