コード例 #1
0
        public void TableSortOnFgdbGuidsPerformance()
        {
            IFeatureWorkspace featureWs =
                WorkspaceUtils.OpenFileGdbFeatureWorkspace(TestData.GetArealeFileGdbPath());
            //IFeatureWorkspace featureWs = OpenTestWorkspace();

            ITable table = DatasetUtils.OpenTable(featureWs, "TLM_NUTZUNGSAREAL");
            //ITable table = DatasetUtils.OpenTable(featureWs, "TOPGIS_TLM.TLM_NUTZUNGSAREAL");

            const string uuidFieldName = "UUID";

            var watch = new Stopwatch();

            watch.Start();

            ICursor cursor = TableSortUtils.GetSortedTableCursor(table, uuidFieldName);

            LoopAndWrite(cursor, uuidFieldName);

            watch.Stop();
            long standardSort = watch.ElapsedMilliseconds;

            //featureWs = OpenTestWorkspace();
            //table = DatasetUtils.OpenTable(featureWs, "TOPGIS_TLM.TLM_NUTZUNGSAREAL");

            watch = new Stopwatch();
            watch.Start();

            cursor = TableSortUtils.GetGuidFieldSortedCursor(table, uuidFieldName);
            LoopAndWrite(cursor, uuidFieldName);

            watch.Stop();
            Console.WriteLine(@"Standard Sorter: {0}", standardSort);
            Console.WriteLine(@"Guid Sorter: {0}", watch.ElapsedMilliseconds);
        }
コード例 #2
0
        public void CanSortByStringField()
        {
            IFeatureWorkspace featureWs =
                WorkspaceUtils.OpenFileGdbFeatureWorkspace(TestData.GetArealeFileGdbPath());

            ITable table = DatasetUtils.OpenTable(featureWs, "TLM_NUTZUNGSAREAL");

            const string operatorFieldName = "OPERATEUR";
            ICursor      cursor            = TableSortUtils.GetSortedTableCursor(table, operatorFieldName);

            int fieldIndex = cursor.FindField(operatorFieldName);

            Assert.True(fieldIndex >= 0, "Field not found");

            string lastValue = null;
            IRow   row;

            while ((row = cursor.NextRow()) != null)
            {
                object value = row.get_Value(fieldIndex);

                Assert.False(value == DBNull.Value, "Empty field");

                var currentValue = (string)value;
                Console.WriteLine(currentValue);

                if (lastValue != null)
                {
                    Assert.False(currentValue.CompareTo(lastValue) < 0, "Not sorted");
                }

                lastValue = currentValue;
            }
        }
コード例 #3
0
ファイル: QaUniqueTest.cs プロジェクト: sungaoyong/ProSuite
        public void CanDetect1toNNonUnique_FileGdb()
        {
            ITable relTable = CanDetect1toNNonUnique(_fgdbWorkspace);

            int rowCount             = relTable.RowCount(null);
            var firstUniqueFieldName = "Relate1NNonUnique1.Unique";

            // TableSort verification
            int        sortCount = 0;
            ITableSort tableSort = TableSortUtils.CreateTableSort(relTable,
                                                                  firstUniqueFieldName);

            tableSort.Compare     = new FieldSortCallback();
            tableSort.QueryFilter = null;
            tableSort.Sort(null);

            ICursor rows = tableSort.Rows;

            while (rows.NextRow() != null)
            {
                sortCount++;
            }

            string version = RuntimeUtils.Version;
            double v;

            if (double.TryParse(version, out v) && v < 10.4)
            {
                Assert.AreEqual(rowCount, sortCount);
            }
            else
            {
                Assert.IsTrue(rowCount >
                              sortCount);                 // bug in TableSort for joined FGDB-Tables, since 10.4
            }

            int orderByCount = 0;
            // Order By verification
            int          fieldIndex = relTable.FindField(firstUniqueFieldName);
            IQueryFilter filter     = new QueryFilterClass();

            ((IQueryFilterDefinition)filter).PostfixClause =
                $"ORDER BY {firstUniqueFieldName}";
            int pre = int.MinValue;

            foreach (IRow row in new EnumCursor(relTable, filter, false))
            {
                int id = (int)row.Value[fieldIndex];
                Assert.IsTrue(pre <= id);
                pre = id;

                orderByCount++;
            }

            Assert.AreEqual(rowCount, orderByCount);
        }
コード例 #4
0
        public void CanSortOnFgdbGuids()
        {
            IFeatureWorkspace featureWs =
                WorkspaceUtils.OpenFileGdbFeatureWorkspace(TestData.GetArealeFileGdbPath());
            //IFeatureWorkspace featureWs = OpenTestWorkspace();

            ITable table = DatasetUtils.OpenTable(featureWs, "TLM_NUTZUNGSAREAL");
            //ITable table = DatasetUtils.OpenTable(featureWs, "TOPGIS_TLM.TLM_NUTZUNGSAREAL");

            const string uuidFieldName = "UUID";

            ICursor cursor = TableSortUtils.GetGuidFieldSortedCursor(table, uuidFieldName);

            int fieldIndex = cursor.FindField(uuidFieldName);

            Assert.True(fieldIndex >= 0, "Field not found");

            Guid lastGuid = Guid.Empty;
            IRow row;

            while ((row = cursor.NextRow()) != null)
            {
                object value = row.get_Value(fieldIndex);

                Assert.False(value == DBNull.Value, "Empty UUID field");

                var currentGuid = new Guid((string)value);
                Console.WriteLine(currentGuid);

                if (lastGuid != Guid.Empty)
                {
                    Assert.False(currentGuid.CompareTo(lastGuid) < 0, "Not sorted");
                }

                lastGuid = currentGuid;
            }
        }