Ejemplo n.º 1
0
 public void VerifyConsistency(IColumn column, VerificationLevel level, ExecutionDetails details)
 {
     foreach (WordIndexBlock block in _blocks)
     {
         block.VerifyConsistency(column, level, details);
     }
 }
Ejemplo n.º 2
0
        public DataBlockResult Compute(Partition p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            DataBlockResult result = new DataBlockResult(this);

            // Find matches for the remaining query
            ShortSet baseQueryMatches = new ShortSet(p.Count);

            this.Where.TryEvaluate(p, baseQueryMatches, result.Details);

            // Find and count matches per column for the term in the outer query
            List <Tuple <string, int> > matchCountPerColumn = new List <Tuple <string, int> >();

            if (baseQueryMatches.Count() > 0)
            {
                TermExpression bareTerm             = new TermExpression(this.Term);
                ShortSet       termMatchesForColumn = new ShortSet(p.Count);

                bool             succeeded        = false;
                ExecutionDetails perColumnDetails = new ExecutionDetails();

                foreach (IColumn <object> column in p.Columns.Values)
                {
                    termMatchesForColumn.Clear();

                    perColumnDetails.Succeeded = true;
                    column.TryWhere(Operator.Matches, this.Term, termMatchesForColumn, perColumnDetails);
                    succeeded |= perColumnDetails.Succeeded;

                    termMatchesForColumn.And(baseQueryMatches);

                    ushort matchCount = termMatchesForColumn.Count();
                    if (matchCount > 0)
                    {
                        matchCountPerColumn.Add(new Tuple <string, int>(column.Name, (int)matchCount));
                    }
                }

                // Sort results by count of matches descending
                matchCountPerColumn.Sort((left, right) => right.Item2.CompareTo(left.Item2));
            }

            // Copy to a DataBlock and return it
            int       index = 0;
            DataBlock block = new DataBlock(new string[] { "ColumnName", "Count" }, matchCountPerColumn.Count);

            foreach (var column in matchCountPerColumn)
            {
                block[index, 0] = column.Item1;
                block[index, 1] = column.Item2;
                index++;
            }

            result.Values = block;
            result.Total  = baseQueryMatches.Count();
            return(result);
        }
Ejemplo n.º 3
0
        public void CreateTable(IList <ColumnDetails> columns, SecurityPermissions permissions)
        {
            this.Table = new Table(this.Configuration.ArribaTable, this.Configuration.ItemCountLimit);

            // Try to load the table if it already exists
            if (BinarySerializable.EnumerateUnder(Path.Combine("Tables", this.Configuration.ArribaTable)).Count() > 0)
            {
                Trace.WriteLine(string.Format("Loading Arriba Table '{0}'...", this.Configuration.ArribaTable));
                this.Table.Load(this.Configuration.ArribaTable);
            }

            // Verify all columns match requested types [will throw if column exists but as different type]
            foreach (ColumnDetails cd in columns)
            {
                this.Table.AddColumn(cd);
            }

            // Set the table security
            new SecureDatabase().SetSecurity(this.Configuration.ArribaTable, permissions);

            // Debug Only: Verify consistency just after load
            if (this.DiagnosticsEnabled)
            {
                Trace.WriteLine("Verifying Arriba Table consistency [on load]...");

                ExecutionDetails d = new ExecutionDetails();
                this.Table.VerifyConsistency(this.DiagnosticsLevel, d);

                if (!d.Succeeded)
                {
                    Debugger.Break();
                    Trace.TraceError(String.Format("Consistency Errors Detected: {0}", String.Join("\r\n", d.Errors)));
                }
            }
        }
Ejemplo n.º 4
0
        public void CreateTable(IList <ColumnDetails> columns, SecurityPermissions permissions)
        {
            this.Table = new Table(this.Configuration.ArribaTable, this.Configuration.ItemCountLimit);

            // Try to load the table if it already exists
            if (BinarySerializable.EnumerateUnder(Path.Combine("Tables", this.Configuration.ArribaTable)).Count() > 0)
            {
                Trace.WriteLine(string.Format("Loading Arriba Table '{0}'...", this.Configuration.ArribaTable));
                this.Table.Load(this.Configuration.ArribaTable);
            }

            // Columns are added dynamically by Append

            // Set the table security
            SecureDatabase sdb = new SecureDatabase();

            sdb.SetSecurity(this.Configuration.ArribaTable, permissions);
            sdb.SaveSecurity(this.Configuration.ArribaTable);

            // Debug Only: Verify consistency just after load
            if (this.DiagnosticsEnabled)
            {
                Trace.WriteLine("Verifying Arriba Table consistency [on load]...");

                ExecutionDetails d = new ExecutionDetails();
                this.Table.VerifyConsistency(this.DiagnosticsLevel, d);

                if (!d.Succeeded)
                {
                    Debugger.Break();
                    Trace.TraceError(String.Format("Consistency Errors Detected: {0}", String.Join("\r\n", d.Errors)));
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Saves the specified table.
        /// </summary>
        private IResponse Save(IRequestContext request, Route route)
        {
            string tableName = GetAndValidateTableName(route);

            if (!this.Database.TableExists(tableName))
            {
                return(ArribaResponse.NotFound("Table not found to save"));
            }

            using (request.Monitor(MonitorEventLevel.Information, "Save", type: "Table", identity: tableName))
            {
                Table t = this.Database[tableName];

                // Verify before saving; don't save if inconsistent
                ExecutionDetails d = new ExecutionDetails();
                t.VerifyConsistency(VerificationLevel.Normal, d);

                if (d.Succeeded)
                {
                    t.Save();
                    return(ArribaResponse.Ok("Saved"));
                }
                else
                {
                    return(ArribaResponse.Error("Table state inconsistent. Not saving. Restart server to reload. Errors: " + d.Errors));
                }
            }
        }
Ejemplo n.º 6
0
        public void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }

            if (!partition.ContainsColumn(this.ColumnName))
            {
                details.AddError(ExecutionDetails.ColumnDoesNotExist, this.ColumnName);
            }
            else
            {
                IColumn <object> column = partition.Columns[this.ColumnName];

                for (int i = 0; i < this.Values.Length; ++i)
                {
                    column.TryWhere(this.Operator, this.Values.GetValue(i), result, details);
                }
            }
        }
Ejemplo n.º 7
0
        public void VerifyConsistency(VerificationLevel level, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            // Verify there are enough index items
            if (_itemCount > _index.Length)
            {
                details.AddError(ExecutionDetails.ColumnDoesNotHaveEnoughValues, this.Name, _itemCount, _index.Length);
            }

            for (int i = 0; i < _itemCount; ++i)
            {
                BlockPosition p = _index[i];
                if (p.BatchIndex >= _batchCount)
                {
                    // Verify every index item points to a valid batch
                    details.AddError(ExecutionDetails.ByteBlockColumnBatchOutOfRange, this.Name, i, p.BatchIndex, _batchCount);
                }
                else
                {
                    // Verify every empty item is represented correctly and every non-oversize item points to a valid array range
                    BlockBatch batch = _batches[p.BatchIndex];
                    if (p.Length == 0)
                    {
                        if (p.Position != 0)
                        {
                            details.AddError(ExecutionDetails.ByteBlockEmptyValueMisrecorded, this.Name, i, p.Position);
                        }
                    }
                    else if (p.Length == ushort.MaxValue)
                    {
                        if (p.Position != 0)
                        {
                            details.AddError(ExecutionDetails.ByteBlockHugeValueMisrecorded, this.Name, i, p.Position);
                        }
                    }
                    else
                    {
                        if (p.Position >= batch.Array.Length || p.Position + p.Length > batch.Array.Length)
                        {
                            details.AddError(ExecutionDetails.ByteBlockColumnPositionOutOfRange, this.Name, i, p.Position, p.Length, batch.Array.Length);
                        }
                    }
                }
            }

            // Verify all out-of-range items are clear
            for (int i = _itemCount; i < _index.Length; ++i)
            {
                BlockPosition p = _index[i];
                if (p.BatchIndex != 0 || p.Position != 0 || p.Length != 0)
                {
                    details.AddError(ExecutionDetails.ByteBlockColumnUnclearedIndexEntry, this.Name, i, p);
                }
            }
        }
Ejemplo n.º 8
0
        public void SortedColumn_StartsWith_NonString()
        {
            ExecutionDetails   details = new ExecutionDetails();
            SortedColumn <int> column  = ColumnFactory.CreateSortedColumn <int>(new ValueTypeColumn <int>(-1), 0);

            column.TryWhere(Operator.StartsWith, 5, new ShortSet(ushort.MaxValue), details);
            Assert.IsFalse(details.Succeeded);
        }
Ejemplo n.º 9
0
 public void TryWhere(Operator op, ComparableColor value, ShortSet result, ExecutionDetails details)
 {
     // Base Column can't identify matches for any operator in bulk efficiently.
     if (details != null)
     {
         details.AddError(ExecutionDetails.ColumnDoesNotSupportOperator, op, this.Name);
     }
 }
Ejemplo n.º 10
0
        private void Init()
        {
            if (!first)
            {
                return;
            }
            string host = null;
            string port = null;

            try
            {
                enabled = Boolean.Parse(Configuration.Instance.GetProperty(CONFIGURATION_SECTION, "enabled"));
            }
            catch
            {
                enabled = false;
            }

            try
            {
                if (!enabled)
                {
                    return;
                }
                host = Configuration.Instance.GetProperty(CONFIGURATION_SECTION, "host");
                port = Configuration.Instance.GetProperty(CONFIGURATION_SECTION, "port");
                ExecutionDetails executionDetails = new ExecutionDetails();
                if (Configuration.Instance.IsPropertyExists(CONFIGURATION_SECTION, "executionDescription"))
                {
                    executionDetails.description = Configuration.Instance.GetProperty(CONFIGURATION_SECTION, "executionDescription");
                }
                if (Configuration.Instance.IsPropertyExists(CONFIGURATION_SECTION, "executionProperties"))
                {
                    string executionPropertiesValue = Configuration.Instance.GetProperty(CONFIGURATION_SECTION, "executionProperties");

                    // Parsing the properties from the configuration file and adding them as execution properties
                    executionDetails.executionProperties = executionPropertiesValue.Split(';')
                                                           .Select(value => value.Split('='))
                                                           .ToDictionary(pair => pair[0], pair => pair[1]);

                    // We are also adding the execution properties as scenario properties so we could see it in the ElasticSearch
                    Scenario scenario = (Scenario)CurrentExecution.GetLastMachine().children[0];
                    scenario.scenarioProperties = executionDetails.executionProperties;
                }

                client      = new DifidoClient(host, Int32.Parse(port));
                executionId = client.AddExecution(executionDetails);
                machineId   = client.AddMachine(executionId, CurrentExecution.GetLastMachine());
                enabled     = true;
            }
            catch
            {
                enabled = false;
            }
            first = false;
        }
Ejemplo n.º 11
0
        public void TryWhere(Operator op, ByteBlock value, ShortSet result, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            // Base Column can't identify matches for any operator in bulk efficiently.
            details.AddError(ExecutionDetails.ColumnDoesNotSupportOperator, op, this.Name);
        }
Ejemplo n.º 12
0
        public int AddExecution(ExecutionDetails details)
        {
            if (null == details)
            {
                throw new Exception("Execution details can't be null");
            }
            WebRequest request = WebRequest.Create(baseUri + "executions/");

            request.Method = "POST";
            return(Int32.Parse(SendContent(request, details)));
        }
Ejemplo n.º 13
0
        public static void AssertConsistent(IColumn column)
        {
            if (column is ICommittable)
            {
                (column as ICommittable).Commit();
            }

            ExecutionDetails verifyDetails = new ExecutionDetails();

            column.VerifyConsistency(VerificationLevel.Full, verifyDetails);
            Assert.IsTrue(verifyDetails.Succeeded, verifyDetails.Errors);
        }
Ejemplo n.º 14
0
        private static string GetMatches(IpRangeColumn col, Operator op, ByteBlock value)
        {
            ExecutionDetails details = new ExecutionDetails();
            ShortSet         result  = new ShortSet(col.Count);

            col.TryWhere(op, value, result, details);

            if (!details.Succeeded)
            {
                return(null);
            }

            return(result.ToString());
        }
Ejemplo n.º 15
0
        public virtual void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }

            if (this.ColumnName.Equals("*"))
            {
                // '*' queries succeed if any column succeeds
                bool             succeeded        = false;
                ExecutionDetails perColumnDetails = new ExecutionDetails();

                foreach (IColumn <object> column in partition.Columns.Values)
                {
                    perColumnDetails.Succeeded = true;
                    column.TryWhere(this.Operator, this.Value, result, perColumnDetails);
                    succeeded |= perColumnDetails.Succeeded;
                }

                details.Succeeded &= succeeded;

                // If no column succeeded, report the full errors
                if (!succeeded)
                {
                    details.Merge(perColumnDetails);
                }
            }
            else
            {
                if (!partition.ContainsColumn(this.ColumnName))
                {
                    details.AddError(ExecutionDetails.ColumnDoesNotExist, this.ColumnName);
                }
                else
                {
                    partition.Columns[this.ColumnName].TryWhere(this.Operator, this.Value, result, details);
                }
            }
        }
Ejemplo n.º 16
0
        public static string GetMatches <T>(IColumn <T> column, Operator op, T value)
        {
            ShortSet         result  = new ShortSet(column.Count);
            ExecutionDetails details = new ExecutionDetails();

            // Get the matches
            column.TryWhere(op, value, result, details);

            // Return a distinct value if the evaluation was reported unsuccessful
            if (!details.Succeeded)
            {
                return(null);
            }

            // Return matches for successful evaluation
            return(String.Join(", ", result.Values));
        }
Ejemplo n.º 17
0
        public void Save()
        {
            // Debug Only: Verify consistency just before save
            if (this.DiagnosticsEnabled)
            {
                Trace.WriteLine("Verifying Arriba Table consistency [on save]...");

                ExecutionDetails d = new ExecutionDetails();
                this.Table.VerifyConsistency(this.DiagnosticsLevel, d);

                if (!d.Succeeded)
                {
                    Debugger.Break();
                    Trace.TraceError(String.Format("Consistency Errors Detected: {0}", String.Join("\r\n", d.Errors)));
                }
            }

            this.Table.Save();
        }
Ejemplo n.º 18
0
        private void Init()
        {
            if (!first)
            {
                return;
            }
            string host = "localhost";
            int    port = 8080;

            try
            {
                if (!enabled)
                {
                    return;
                }
                // host = Configuration.Instance.GetProperty("report", "reportServerHost");
                // port = Configuration.Instance.GetProperty("report", "reportServerPort");
                ExecutionDetails executionDetails = new ExecutionDetails();
                //executionDetails.description = "Some description";

                //string executionPropertiesValue = "key0=val0;key1=val1";

                //// Parsing the properties from the configuration file and adding them as execution properties
                //executionDetails.executionProperties = executionPropertiesValue.Split(';')
                //    .Select(value => value.Split('='))
                //    .ToDictionary(pair => pair[0], pair => pair[1]);

                //// We are also adding the execution properties as scenario properties so we could see it in the ElasticSearch
                //Scenario scenario = (Scenario)CurrentExecution.GetLastMachine().children[0];
                //scenario.scenarioProperties = executionDetails.executionProperties;

                client      = new DifidoClient(host, port);
                executionId = client.AddExecution(executionDetails);
                machineId   = client.AddMachine(executionId, CurrentExecution.GetLastMachine());
                enabled     = true;
            }
            catch
            {
                enabled = false;
            }
            first = false;
        }
Ejemplo n.º 19
0
        public void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }

            // Include all items - clear any and then add everything.
            // ShortSet will scope the set to the ID range valid within the data set.
            result.Clear();
            result.Not();
        }
Ejemplo n.º 20
0
        private static void CheckConsistency(string tableName)
        {
            Trace.WriteLine(String.Format("Checking '{0}' table consistency...", tableName));

            Table t = new Table();

            t.Load(tableName);

            ExecutionDetails details = new ExecutionDetails();

            t.VerifyConsistency(VerificationLevel.Normal, details);

            if (details.Succeeded)
            {
                Trace.WriteLine(String.Format("Done. '{0}' is consistent.", tableName));
            }
            else
            {
                Trace.WriteLine(String.Format("Done. '{0}' has consistency problems.\r\n{1}\r\n{2}", tableName, details.Errors, details.Warnings));
            }
        }
Ejemplo n.º 21
0
        public void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            ushort itemCount = partition.Count;

            foreach (IExpression part in _set)
            {
                part.TryEvaluate(partition, result, details);
                if (result.Count() == itemCount)
                {
                    break;
                }
            }
        }
Ejemplo n.º 22
0
        private static void LogDeviceExecution(string executionId)
        {
            ExecutionRecorder       recorder = new ExecutionRecorder();
            ExecutionRecorderParams recorderParams
                = new ExecutionRecorderParams(executionId, Host, Username, Password, TestType.Appium,
                                              BaseProjectPath, TestCaseName, CurrentDevice.DeviceDetails, ExecutionErrors);

            if (executionId == Constants.UNKNOWN)
            {
                //No id to get details - need to create our own details
                ExecutionDetails details = new ExecutionDetails();
                details.executionId = executionId;
                details.status      = Constants.UNKNOWN;
                details.description = "Tried to get execution details but failed.";
                details.reason      = Constants.UNKNOWN;
                recorder.RecordExecutionRun(recorderParams, details);
                return;
            }

            //We have an executionId so try to get run results.
            recorder.GetAndRecordExecutionRun(recorderParams);
        }
Ejemplo n.º 23
0
        public void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            ushort   itemCount         = partition.Count;
            ShortSet expressionResults = null;
            ShortSet partResults       = new ShortSet(itemCount);

            foreach (IExpression part in _set)
            {
                partResults.Clear();
                part.TryEvaluate(partition, partResults, details);

                if (expressionResults == null)
                {
                    expressionResults = new ShortSet(itemCount);
                    expressionResults.Or(partResults);
                }
                else
                {
                    expressionResults.And(partResults);
                }

                if (expressionResults.IsEmpty())
                {
                    break;
                }
            }

            result.Or(expressionResults);
        }
Ejemplo n.º 24
0
            public void VerifyConsistency(IColumn column, VerificationLevel level, ExecutionDetails details)
            {
                if (_words.Count > WordCountLimit)
                {
                    details.AddError(ExecutionDetails.WordIndexBlockTooFull, column.Name, _words.Count);
                }

                if (_words.Count != _sets.Count)
                {
                    details.AddError(ExecutionDetails.WordIndexBlockSizesMismatch, column.Name, _words.Count, _sets.Count);
                }

                if (level == VerificationLevel.Full)
                {
                    // Validate that all IDs in all sets are valid
                    // NOTE: Replacing with a validating GetInSet would be more thorough; check for duplicate values, padding problems, etc.
                    ShortSet allValidItems = new ShortSet(column.Count);
                    allValidItems.Not();

                    ShortSet items = new ShortSet(ushort.MaxValue);
                    for (ushort i = 0; i < _words.Count; ++i)
                    {
                        items.Clear();
                        GetInSet(i, items);

                        items.AndNot(allValidItems);
                        if (items.Count() > 0)
                        {
                            details.AddError(ExecutionDetails.WordIndexInvalidItemID, column.Name, _words[i], String.Join(", ", items.Values));
                        }
                    }
                }

                // Ask the Sets and Words columns to self-verify
                _sets.VerifyConsistency(level, details);
                _words.VerifyConsistency(level, details);
            }
Ejemplo n.º 25
0
        public override void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }

            // Run on every column *except* excluded ones
            bool             succeeded        = false;
            ExecutionDetails perColumnDetails = new ExecutionDetails();

            foreach (IColumn <object> column in partition.Columns.Values)
            {
                if (!this.RestrictedColumns.Contains(column.Name))
                {
                    perColumnDetails.Succeeded = true;
                    column.TryWhere(this.Operator, this.Value, result, perColumnDetails);
                    succeeded |= perColumnDetails.Succeeded;
                }
            }

            details.Succeeded &= succeeded;

            // If no column succeeded, report the full errors
            if (!succeeded)
            {
                details.Merge(perColumnDetails);
            }
        }
Ejemplo n.º 26
0
        public void TryEvaluate(Partition partition, ShortSet result, ExecutionDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            if (partition == null)
            {
                throw new ArgumentNullException("partition");
            }

            ushort itemCount = partition.Count;

            ShortSet partResults = new ShortSet(itemCount);

            _part[0].TryEvaluate(partition, partResults, details);
            partResults.Not();

            result.Or(partResults);
        }
Ejemplo n.º 27
0
 public void VerifyConsistency(VerificationLevel level, ExecutionDetails details)
 {
     this.StartAddressColumn.VerifyConsistency(level, details);
     this.EndAddressColumn.VerifyConsistency(level, details);
 }
Ejemplo n.º 28
0
        public void TryWhere(Operator op, ByteBlock value, ShortSet result, ExecutionDetails details)
        {
            // Convert the value to an IP Range. Error if not.
            IpRange valueRange;

            if (!IpRange.TryParse(value.ToString(), out valueRange))
            {
                details.AddError(ExecutionDetails.UnableToConvertType, value, this.Name, "IP Range");
                return;
            }

            if (op == Operator.Matches)
            {
                // Matches finds rows which overlap the passed range.

                // Get rows which *don't overlap* because the start address is after the range being searched for
                this.StartAddressColumn.TryWhere(Operator.GreaterThan, valueRange.EndInclusive, result, details);

                // Add rows which *don't overlap* because the end address is before the range being searched for
                this.EndAddressColumn.TryWhere(Operator.LessThan, valueRange.StartInclusive, result, details);

                // Negate to find the set which *do* overlap
                result.Not();
            }
            else if (op == Operator.Equals || op == Operator.MatchesExact || op == Operator.NotEquals)
            {
                // Equals and MatchExact find rows which exactly equal the range being searched for

                // Find rows with the wrong start
                this.StartAddressColumn.TryWhere(Operator.NotEquals, valueRange.StartInclusive, result, details);

                // Add rows the wrong end
                this.EndAddressColumn.TryWhere(Operator.NotEquals, valueRange.EndInclusive, result, details);

                // Negate to find the set which are equal (both start and end match)
                if (op != Operator.NotEquals)
                {
                    result.Not();
                }
            }
            else if (op == Operator.LessThan)
            {
                // Find rows which end before the start of the search range
                this.EndAddressColumn.TryWhere(Operator.LessThan, valueRange.StartInclusive, result, details);
            }
            else if (op == Operator.GreaterThan)
            {
                // Find rows start after the end of the search range
                this.StartAddressColumn.TryWhere(Operator.GreaterThan, valueRange.EndInclusive, result, details);
            }
            else if (op == Operator.LessThanOrEqual)
            {
                // Find rows which end before the end of the search range
                this.EndAddressColumn.TryWhere(Operator.LessThanOrEqual, valueRange.EndInclusive, result, details);
            }
            else if (op == Operator.GreaterThanOrEqual)
            {
                // Find rows which start after the start of the search range
                this.StartAddressColumn.TryWhere(Operator.GreaterThanOrEqual, valueRange.StartInclusive, result, details);
            }
            else
            {
                details.AddError(ExecutionDetails.ColumnDoesNotSupportOperator, op, this.Name);
            }
        }
Ejemplo n.º 29
0
        public void SortedColumn_Where()
        {
            SortedColumn <int> c = ColumnFactory.CreateSortedColumn <int>(new ValueTypeColumn <int>(-1), 0);

            c.SetSize(8);
            c[0] = 0;
            c[1] = 1;
            c[2] = 1;
            c[3] = 2;
            c[4] = 2;
            c[5] = 8;
            c[6] = 8;
            c[7] = 9;
            ColumnTests.AssertConsistent(c);

            // Find a middle value
            Assert.AreEqual("3, 4", ColumnTests.GetMatches(c, Operator.Equals, 2));

            // Find the minimum value
            Assert.AreEqual("0", ColumnTests.GetMatches(c, Operator.Equals, 0));

            // Find the maximum value
            Assert.AreEqual("7", ColumnTests.GetMatches(c, Operator.Equals, 9));

            // Find a value not in set (too small)
            Assert.AreEqual("", ColumnTests.GetMatches(c, Operator.Equals, -1));

            // Find a value not in set (too big)
            Assert.AreEqual("", ColumnTests.GetMatches(c, Operator.Equals, 10));


            // Find not of a value
            Assert.AreEqual("0, 1, 2, 5, 6, 7", ColumnTests.GetMatches(c, Operator.NotEquals, 2));

            // Find not of a value not in set
            Assert.AreEqual("0, 1, 2, 3, 4, 5, 6, 7", ColumnTests.GetMatches(c, Operator.NotEquals, -1));


            // Find less than not in set (too small)
            Assert.AreEqual("", ColumnTests.GetMatches(c, Operator.LessThan, -1));

            // Find less than an existing value
            Assert.AreEqual("0, 1, 2", ColumnTests.GetMatches(c, Operator.LessThan, 2));

            // Find less than a gap between values
            Assert.AreEqual("0, 1, 2, 3, 4", ColumnTests.GetMatches(c, Operator.LessThan, 4));

            // Find less than more than set (too big)
            Assert.AreEqual("0, 1, 2, 3, 4, 5, 6, 7", ColumnTests.GetMatches(c, Operator.LessThan, 99));


            // Find less than or equal not in set (too small)
            Assert.AreEqual("", ColumnTests.GetMatches(c, Operator.LessThanOrEqual, -1));

            // Find less than or equal an existing value
            Assert.AreEqual("0, 1, 2, 3, 4", ColumnTests.GetMatches(c, Operator.LessThanOrEqual, 2));

            // Find less than or equal a gap between values
            Assert.AreEqual("0, 1, 2, 3, 4", ColumnTests.GetMatches(c, Operator.LessThanOrEqual, 4));

            // Find less than or equal more than set (too big)
            Assert.AreEqual("0, 1, 2, 3, 4, 5, 6, 7", ColumnTests.GetMatches(c, Operator.LessThanOrEqual, 99));


            // Find greater than not in set (too small)
            Assert.AreEqual("0, 1, 2, 3, 4, 5, 6, 7", ColumnTests.GetMatches(c, Operator.GreaterThan, -1));

            // Find greater than an existing value
            Assert.AreEqual("5, 6, 7", ColumnTests.GetMatches(c, Operator.GreaterThan, 2));

            // Find greater than a gap between values
            Assert.AreEqual("5, 6, 7", ColumnTests.GetMatches(c, Operator.GreaterThan, 4));

            // Find greater than more than set (too big)
            Assert.AreEqual("", ColumnTests.GetMatches(c, Operator.GreaterThan, 99));

            // Find greater than or equal not in set (too small)
            Assert.AreEqual("0, 1, 2, 3, 4, 5, 6, 7", ColumnTests.GetMatches(c, Operator.GreaterThanOrEqual, -1));

            // Find greater than or equal an existing value
            Assert.AreEqual("3, 4, 5, 6, 7", ColumnTests.GetMatches(c, Operator.GreaterThanOrEqual, 2));

            // Find greater than or equal a gap between values
            Assert.AreEqual("5, 6, 7", ColumnTests.GetMatches(c, Operator.GreaterThanOrEqual, 4));

            // Find greater than or equal more than set (too big)
            Assert.AreEqual("", ColumnTests.GetMatches(c, Operator.GreaterThanOrEqual, 99));

            // Verify sorting consistency problems are detected
            ((IColumn <int>)c.InnerColumn)[0] = 8;
            ExecutionDetails d = new ExecutionDetails();

            c.VerifyConsistency(VerificationLevel.Full, d);
            Assert.IsFalse(d.Succeeded);
        }
Ejemplo n.º 30
0
 /// <summary>
 /// ExecutionDetails event invocator
 /// </summary>
 protected virtual void OnExecutionDetails(ExecutionDetailsEventArgs e)
 {
     ExecutionDetails?.Invoke(this, e);
 }