Esempio n. 1
0
        internal static void ProcessJsonTraverseAction(FanoutSearchDescriptor fs_desc, JObject queryObject, int i, int len, string element_str)
        {
            List <long>   cell_ids       = null;
            bool          is_cell_id     = TryParseLongList(element_str, out cell_ids);
            bool          is_origin      = (i == 0);
            bool          is_last        = (i == len - 1 || i == len - 2);
            List <string> selectedFields = new List <string>();

            if (is_cell_id)
            {
                if (is_origin)
                {
                    fs_desc.m_origin = cell_ids;
                }
                else
                {
                    if (is_last) /* The last node, action set to return */
                    {
                        fs_desc.AddTraverseStep(ExpressionBuilder.GenerateTraverseActionFromCellIds(Action.Return, cell_ids), null);
                    }
                    else /* Intermediate node, action set to continue */
                    {
                        fs_desc.AddTraverseStep(ExpressionBuilder.GenerateTraverseActionFromCellIds(Action.Continue, cell_ids), null);
                    }
                }
            }
            else
            {
                dynamic action_object = queryObject[element_str];
                ProcessJsonSelectField(selectedFields, action_object);

                if (is_origin)
                {
                    ProcessJsonOriginNodeObject(fs_desc, action_object);
                }
                else /* not origin */
                {
                    ProcessJsonNonOriginNodeObject(fs_desc, is_last, action_object);
                }
            }

            fs_desc.m_selectFields.Add(selectedFields);
        }
Esempio n. 2
0
        private static void ProcessJsonNonOriginNodeObject(FanoutSearchDescriptor fs_desc, bool is_last, dynamic action_object)
        {
            Expression <Func <ICellAccessor, Action> > traverse_action = null;
            Action default_action = is_last ? Action.Return : Action.Continue;

            traverse_action = ExpressionBuilder.GenerateTraverseActionFromQueryObject(action_object, default_action);

            if (traverse_action != null)
            {
                fs_desc.AddTraverseStep(traverse_action, null);
            }
            else
            {
                /* either user didn't specify node desc, or node desc doesn't imply traverse action */
                if (is_last)
                {
                    fs_desc.AddTraverseStep(_ => Action.Return, null);
                }
                else
                {
                    fs_desc.AddTraverseStep(_ => Action.Continue, null);
                }
            }
        }
Esempio n. 3
0
        internal static void ProcessJsonQueryObject(FanoutSearchDescriptor fs_desc, string queryPath, JObject queryObject)
        {
            string[] path_elements = queryPath.Split(s_url_path_separator, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0, len = path_elements.Length; i != len; ++i)
            {
                var element_str = path_elements[i];

                if (0 == (i % 2)) /* Node */
                {
                    ProcessJsonTraverseAction(fs_desc, queryObject, i, len, element_str);
                }
                else /* Edge */
                {
                    ProcessJsonEdgeTypeDescriptor(fs_desc, element_str);
                }
            }

            if (0 == path_elements.Length % 2) /* There's no final node desc. Add a return command. */
            {
                fs_desc.AddTraverseStep(_ => Action.Return, null);
            }
        }