/// <summary>
 /// Get the size of a node. Child nodes are not be accounted for.
 /// </summary>
 /// <param name="node">The node</param>
 /// <returns>The size of the bound plus the size the pointeres.
 /// </returns>
 public static long GetNodeInBytes(Node node, int level, int repLevel)
 {
     long size = 0;
     if (node is LeafNode)
     {
         LeafNode leaf = (LeafNode)node;
         size += GetSizeInBytes(node.Bounds);
         size += leaf.Points.Count * BytesPerPtr;
     }
     else
     {
         IntNode intNode = (IntNode)node;
         //Check to see if this node is to be replicated
         if (level <= repLevel)
         {
             int n = intNode.Children.Count;
             int s = (n + 1) * n / 2;
             size += s * GetSizeInBytes(node.Bounds);
             size += s * BytesPerPtr;
         }
         else
         {
             size += GetSizeInBytes(node.Bounds);
             size += intNode.Children.Count * BytesPerPtr;
         }
     }
     return size;
 }
Example #2
0
        //private List<Bucket> program;
        //private int offset;
        //DFDIPlanner()
        //{
        //    program = new List<Bucket>();
        //    offset = 0;
        //}
        public static List<Bucket> MakeProgram(Node node, int offset,
            int repLevel)
        {
            List<Bucket> result = new List<Bucket>();
            if (node is LeafNode)
            {
                LeafNode leaf = (LeafNode)node;
                DataBucket b = new DataBucket(leaf.Points);
                result.Add(b);
            }
            else
            {
                IntNode intNode = (IntNode)node;
                for (int i = 0; i < intNode.Children.Count; i++)
                {
                    if (i == 0)
                    {
                        result.Add(MakeIndexBucket(intNode, 0,
                            offset, repLevel));
                    }
                    else if (repLevel != 0)
                    {
                        result.Add(MakeIndexBucket(intNode, i,
                            result.Count + offset, repLevel));
                    }

                    result.AddRange(MakeProgram(intNode.Children[i],
                        result.Count + offset, repLevel - 1));
                }
            }

            return result;
        }
        /// <summary>
        /// Get the size of the index tree rooted with node.
        /// </summary>
        /// <param name="node">The root node of the tree.</param>
        /// <returns>The size of the tree in byte.</returns>
        public static long GetIndexInBytes(Node node)
        {
            long size = 0;
            size = GetNodeInBytes(node);

            if (node is IntNode)
            {
                IntNode intNode = (IntNode)node;
                foreach (Node n in intNode.Children)
                    size += GetIndexInBytes(n);
            }
            return size;
        }
        /// <summary>
        /// Get the size of the index tree rooted with node.
        /// </summary>
        /// <param name="node">The root node of the tree.</param>
        /// <param name="level"></param>
        /// <param name="repLevel"></param>
        /// <returns>The size of the tree in byte.</returns>
        public static long GetIndexInBytes(Node node, int level, int repLevel)
        {
            long size = 0;
            size = GetNodeInBytes(node, level, repLevel);

            if (node is IntNode)
            {
                IntNode intNode = (IntNode)node;
                foreach (Node n in intNode.Children)
                    size += GetIndexInBytes(n, level + 1, repLevel);
            }
            return size;
        }
 /// <summary>
 /// Get the size of a node. Child nodes are not be accounted for.
 /// </summary>
 /// <param name="node">The node</param>
 /// <returns>The size of the bound plus the size the pointeres.
 /// </returns>
 public static long GetNodeInBytes(Node node)
 {
     long size = GetSizeInBytes(node.Bounds);
     if (node is LeafNode)
     {
         LeafNode leaf = (LeafNode)node;
         size += leaf.Points.Count * BytesPerPtr;
     }
     else
     {
         IntNode intNode = (IntNode)node;
         size += intNode.Children.Count * BytesPerPtr;
     }
     return size;
 }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="child"></param>
        /// <exception cref="NullReferenceException">
        /// If node is null
        /// </exception>
        public void AddChild(Node child)
        {
            if (child.Height + 1 > height)
                height = child.Height + 1;

            if (child.MBR != null)
            {
                if (mbr == null)
                    mbr = child.MBR.Copy();
                else
                    mbr.Add(child.MBR);
            }

            bounds.Add(child.Bounds);
            children.Add(child);
        }
        public static long GetDataPointsInBytes(Node node)
        {
            long size = 0;

            if (node is LeafNode)
            {
                LeafNode leafNode = (LeafNode)node;
                size = leafNode.Points.Count *
                    leafNode.Bounds.Dimensions * BytesPerDouble;
            }
            else
            {
                IntNode intNode = (IntNode)node;
                foreach (Node n in intNode.Children)
                    size += GetDataPointsInBytes(n);
            }

            return size;
        }
Example #8
0
        private void BuildTree(List<Point> records, Orthotope bounds,
            int branchFactor)
        {
            int dimensions = records[0].Dimensions;
            int height = ApproxTreeHeight(records.Count, branchFactor);

            //Assign partitions to each dimension.
            int[] dimensionPartitions = GetPartitionPerDimension(
                GetPartitionPowerFactor(dimensions, height),
                branchFactor);
            //Get cell width for each dimension
            double[] cellWidths = GetPartitionWidth(bounds, dimensionPartitions);
            //Make Leaves
            List<Node> leaves = MakeLeaves(bounds, dimensionPartitions,
                cellWidths);

            //Build the tree bottom up from leaves.
            List<Node> nodes = leaves;
            while (true)
            {
                if (nodes.Count == 1)
                {
                    root = nodes[0];
                    break;
                }
                List<Node> newNodes = new List<Node>();
                for (int i = 0; i < (int)(nodes.Count / branchFactor); i++)
                {
                    IntNode node = new IntNode(
                        nodes.GetRange(i * branchFactor, branchFactor));
                    newNodes.Add(node);
                }
                nodes = newNodes;
            }
        }
Example #9
0
        static int CountDataPoints(Node node)
        {
            if (node is LeafNode)
            {
                LeafNode leafNode = (LeafNode)node;
                return leafNode.Points.Count;
            }

            IntNode intNode = (IntNode)node;
            int count = 0;
            foreach (Node n in intNode.Children)
            {
                count += CountDataPoints(n);
            }

            return count;
        }
 private void ComputeSkyline(Node node)
 {
     ran = true;
     if (!Covered(node))
     {
         if (node is LeafNode)
         {
             LeafNode leafNode = (LeafNode)node;
             ComputeSkyline(leafNode.Points);
         }
         else
         {
             IntNode intNode = (IntNode)node;
             foreach (Node child in intNode.Children)
             {
                 ComputeSkyline(child);
             }
         }
     }
 }
        private bool Covered(Node node)
        {
            foreach (PruningRegion pruneReg in pruneRegs)
            {
                if (pruneReg.Covers(node.Bounds))
                    return true;
            }

            return false;
        }
 private void ComputeSkyline(Node node)
 {
     ran = true;
     if (node.MBR != null && !Covered(node))
     {
         if (node is LeafNode)
         {
             LeafNode leafNode = (LeafNode)node;
             List<Point> s = ComputeSkyline(leafNode.Points);
             if(node.MBR != null)
                 AddPruningRegion(
                     new PruningRegion(leafNode.MBR, pref), true);
             skyline.AddRange(s);
         }
         else
         {
             IntNode intNode = (IntNode)node;
             foreach (Node child in intNode.Children)
             {
                 ComputeSkyline(child);
             }
             if (node.MBR != null)
                 AddPruningRegion(
                     new PruningRegion(node.MBR, pref), false);
         }
     }
 }