Index False positive when Negative float used.

17 views
Skip to first unread message

Scott Barnes

unread,
Aug 18, 2016, 11:42:19 PM8/18/16
to Siaqodb - NoSQL embedded database for .NET

Hi,

If we create an index on a field that is float ( 3D XYZ coords). We've found that if you do a Query<T>.Where( left < right) when a negative float is used (ie -2300 compared with -2500), the whole thing doesn't return a record. We had this exact issue with SQLite and it was a bug given it can't handle negative numbers. Is this also the same in Siaqodb? as were a bit unnerved by this one, given it shouldn't matter.






Siaqodb Support

unread,
Aug 23, 2016, 1:44:30 AM8/23/16
to Siaqodb - NoSQL embedded database for .NET
Hi Scott,
We cannot simulate the issue. (Ofc, in your example if left =-2300 and right=-2500 is normal to return nothing because -2300 is bigger than -2500)
We wrote the following test:
 public class TestFloat
    {
        public int OID { get; set; }
        public float MyFloat { get; set; }
    }
......
public void TestFloatNegative()
        {
            using (Siaqodb sq = new Siaqodb(objPath))
            {
                sq.DropType<TestFloat>();
                for (int i = 0; i < 5; i++)
                {
                    TestFloat tf = new TestFloat();
                    tf.MyFloat = -2300f - i;
                    

                    sq.StoreObject(tf);
                }

                var queryBigger = sq.Query<TestFloat>().Where(a => a.MyFloat >= -2304f).ToList();
                Assert.AreEqual(5, queryBigger.Count);

                var queryLess = sq.Query<TestFloat>().Where(a => a.MyFloat <= -2300f).ToList();
                Assert.AreEqual(5, queryLess.Count);

            }
        }

And it passes.
Reply all
Reply to author
Forward
0 new messages