Beispiel #1
0
        public IEnumerable <Node <T, U> > GetNodes(KeyValuePair <T, T>[] coords, KeyTuplePairs <T> selectors)
        {
            CoordsCase coordstype            = CoordsType(coords, selectors);
            IEnumerable <Node <T, U> > nodes = null;

            switch (coordstype)
            {
            case CoordsCase.Point:
                nodes = GetSingleNode(coords);
                break;

            case CoordsCase.PointAll:
                nodes = GetPointAllNodes(coords, selectors);
                break;

            case CoordsCase.ALL:
                nodes = GetAllNodes(coords);
                break;
            }

            foreach (var item in nodes)
            {
                yield return(item);
            }
            // (1.1, 2.0, 3.1) : (1.0.2.0,3.0) -> (1.1,2.n,3.1)
            // (1.0,2.0,3.0)
        }
        public IEnumerable <U> GetCells(KeyTuplePairs <T> pairs)
        {
            KeyValuePair <T, T>[] cpairs = _canonicFormater.Format(pairs.AnchorTuple);

            foreach (var item in _globalGraph.GetNodes(cpairs, pairs))
            {
                yield return(item.Container);
            }
        }
        public IEnumerable <U> GetCells(T key, KeyTuplePairs <T> pairs)
        {
            var graph = _onDemandAggregations[key];

            KeyValuePair <T, T>[] cpairs = _canonicFormater.Format(pairs.AnchorTuple);

            foreach (var item in graph.GetNodes(cpairs, pairs))
            {
                yield return(item.Container);
            }
        }
        private IOutputCell <T> Map(Cell <T> cell, KeyTuplePairs <T> tuples, Query <T> query)
        {
            var ocell = new OutputCell <T>(cell.Coords, tuples.XAnchorTuple, tuples.YAnchorTuple);

            foreach (var item in query.MeasuresOrMetrics)
            {
                var dataItem = _resolver.GetDataItemInfo(item);
                var value    = cell.Values[item];

                ocell.Add(dataItem.Name, value);
            }

            return(ocell);
        }
Beispiel #5
0
        private CoordsCase CoordsType(KeyValuePair <T, T>[] coords, KeyTuplePairs <T> selectors)
        {
            KeyValuePair <T, T>[] bcoords = Array.FindAll(coords, x => x.Value.Equals(default(T)));

            if (!selectors.HasSelectors)
            {
                return(CoordsCase.Point);
            }
            else if (selectors.HasSelectors && bcoords.Length > selectors.SelectorCount())
            {
                return(CoordsCase.PointAll);
            }
            else
            {
                return(CoordsCase.PointAll); // redefine this todo
            }
        }
Beispiel #6
0
        private IEnumerable <Node <T, U> > TravelNodes(Node <T, U> node, KeyValuePair <T, T>[] coords, int coordsLastIndex, KeyTuplePairs <T> selectors, int selectorIndex)
        {
            var currSelector = selectors.Selectors[selectorIndex];
            var index        = Array.FindIndex(coords, x => currSelector.Item1.Key.Equals(x.Key) &&
                                               currSelector.Item1.Value.Equals(x.Value));
            var length  = index == 0 ? 1 : index;
            var ncoords = new KeyValuePair <T, T> [length];

            Array.Copy(coords, ncoords, length);

            var nxnode = FilterNode(node, ncoords) ? node : node.GetNode(GetHashPoints(ncoords));

            if (nxnode == null &&
                index >= node.Coords.Length)
            {
                nxnode = node.GetNode(GetHashPoints(ncoords), node.Coords.Length - 1);
            }

            if (nxnode != null)
            {
                if (selectors.Selectors.Length > selectorIndex + 1)
                {
                    if (currSelector.Item2.IsAll())
                    {
                        foreach (var item in nxnode.Adjacent)
                        {
                            if (!item.IsRootDim && FilterNode(item, new[] { currSelector.Item1 }))
                            {
                                var nlength = index != 0 ? coords.Length : coords.Length + 1;
                                var xcoords = new KeyValuePair <T, T> [nlength];

                                if (index == 0)
                                {
                                    Array.Copy(item.Coords, 1, xcoords, 0, item.Coords.Length - 1);
                                    Array.Copy(coords, 1, xcoords, item.Coords.Length - 1, xcoords.Length - (item.Coords.Length - 1));
                                }
                                else
                                {
                                    Array.Copy(coords, xcoords, coords.Length);
                                    xcoords[index] = item.Coords[item.Coords.Length - 1];
                                }

                                foreach (var nxitem in TravelNodes(item, xcoords, index, selectors, selectorIndex + 1))
                                {
                                    yield return(nxitem);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in GetLeafNodes(nxnode, currSelector, coords, index))
                    {
                        yield return(item);
                    }
                }
            }
        }
Beispiel #7
0
        private IEnumerable <Node <T, U> > GetPointAllNodes(KeyValuePair <T, T>[] coords, KeyTuplePairs <T> selectors)
        {
            var selectorList = selectors.Selectors;

            if (selectorList.Length > 0)
            {
                var ncoords = new KeyValuePair <T, T>[] { };

                foreach (var item in TravelNodes(this.Root, coords, 0, selectors, 0))
                {
                    yield return(item);
                }
            }
        }