当前位置: 首页>>代码示例>>C#>>正文


C# Row.GetAs方法代码示例

本文整理汇总了C#中Row.GetAs方法的典型用法代码示例。如果您正苦于以下问题:C# Row.GetAs方法的具体用法?C# Row.GetAs怎么用?C# Row.GetAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Row的用法示例。


在下文中一共展示了Row.GetAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyFirstRowOfPeopleDataFrame

        /// <summary>
        /// Verify the contents of 1st row of people dataframe.
        /// </summary>
        /// <param name="firstRow"> First row of people DataFrame </param>
        internal static void VerifyFirstRowOfPeopleDataFrame(Row firstRow)
        {
            Assert.IsNotNull(firstRow);
            Assert.AreEqual(4, firstRow.Size());
            Assert.AreEqual("123", firstRow.GetAs<string>("id"));
            Assert.AreEqual("Bill", firstRow.GetAs<string>("name"));
            Assert.AreEqual(34, firstRow.GetAs<int>("age"));

            var addressCol = firstRow.GetAs<Row>("address");
            Assert.IsNotNull(addressCol);
            Assert.AreEqual("Columbus", addressCol.GetAs<string>("city"));
            Assert.AreEqual("Ohio", addressCol.GetAs<string>("state"));
        }
开发者ID:jinyeqing,项目名称:SparkCLR,代码行数:17,代码来源:DataFrameSamples.cs

示例2: IsRowEqual

        /// <summary>
        /// Verifies that the two Rows are equal. 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="columnsComparer">Specify custom comparer for certain columns. The key of dictionary is column name, the value is comparer.</param>
        /// <returns>True if two Rows are equal.</returns>
        private static bool IsRowEqual(Row x, Row y, Dictionary<string, Func<object, object, bool>> columnsComparer = null)
        {
            if (x == null && y == null) return true;
            if (x == null && y != null || x != null && y == null) return false;

            foreach (var col in x.GetSchema().columns)
            {
                if (!y.GetSchema().columns.Any(c => c.ToString() == col.ToString())) return false;

                if (col.type.columns.Any())
                {
                    if (!IsRowEqual(x.GetAs<Row>(col.name), y.GetAs<Row>(col.name), columnsComparer)) return false;
                }
                else if (x.Get(col.name) == null && y.Get(col.name) != null || x.Get(col.name) != null && y.Get(col.name) == null) return false;
                else if (x.Get(col.name) != null && y.Get(col.name) != null)
                {
                    Func<object, object, bool> colComparer;
                    if (columnsComparer != null && columnsComparer.TryGetValue(col.name, out colComparer))
                    {
                        if (!colComparer(x.Get(col.name), y.Get(col.name))) return false;
                    }
                    else
                    {
                        if (x.Get(col.name).ToString() != y.Get(col.name).ToString()) return false;
                    }
                }
            }
            return true;
        }
开发者ID:hhland,项目名称:SparkCLR,代码行数:36,代码来源:DataFrameSamples.cs


注:本文中的Row.GetAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。