Exemplo n.º 1
0
        private EwahCompressedBitArray getCopyBitmap(EwahCompressedBitArray bitmap)
        {
            var bit = (EwahCompressedBitArray)bitmap.Clone();

            bit.SetSizeInBits(_maxBitSize, false);

            return(bit);
        }
Exemplo n.º 2
0
        internal void ValidateExclusionBitMap(EwahCompressedBitArray bitMapIndex, CLR.HashSet <string> expandedTagsNGrams, QueryType queryType)
        {
            // Exclusion BitMap is Set (i.e. 1) in places where you CAN use the question, i.e. it's NOT excluded
            var questionLookup   = GetTagByQueryLookup(queryType)[TagServer.ALL_TAGS_KEY];
            var invalidQuestions = new List <Tuple <Question, string> >();
            var NOTbitMapIndex   = ((EwahCompressedBitArray)bitMapIndex.Clone());

            NOTbitMapIndex.Not();
            var positions = NOTbitMapIndex.GetPositions();

            foreach (var position in positions)
            {
                var question = questions[questionLookup[position]];
                foreach (var tag in question.Tags)
                {
                    if (expandedTagsNGrams.Contains(tag))
                    {
                        invalidQuestions.Add(Tuple.Create(question, tag));
                    }
                }
                // Sometimes the validitation locks up my laptop, this *seems* to make a difference?!
                Thread.Yield();
            }

            using (Utils.SetConsoleColour(ConsoleColor.Blue))
                Logger.Log("Validating Exclusion Bit Map, checked {0:N0} positions for INVALID tags", positions.Count);

            if (invalidQuestions.Any())
            {
                using (Utils.SetConsoleColour(ConsoleColor.Red))
                    Logger.Log("ERROR Validating Exclusion Bit Map, {0:N0} questions should have been excluded",
                               invalidQuestions.Select(i => i.Item1.Id).Distinct().Count());

                foreach (var error in invalidQuestions)
                {
                    Logger.Log("  {0,8}: {1} -> {2}", error.Item1.Id, String.Join(", ", error.Item1.Tags), error.Item2);
                }
            }


            var expectedPositions = bitMapIndex.GetPositions();

            foreach (var position in expectedPositions)
            {
                var question = questions[questionLookup[position]];
                if (question.Tags.Any(t => expandedTagsNGrams.Contains(t)) == false)
                {
                    using (Utils.SetConsoleColour(ConsoleColor.Red))
                        Logger.Log("ERROR {0,8}: {1} -> didn't contain ANY excluded tags", question.Id, String.Join(", ", question.Tags));
                }
            }

            using (Utils.SetConsoleColour(ConsoleColor.Blue))
                Logger.Log("Validating Exclusion Bit Map, checked {0:N0} positions for EXPECTED tags", expectedPositions.Count);

            Logger.Log();
        }
        public void TestCloneEwahCompressedBitArray()
        {
            Console.WriteLine("testing EWAH clone");
            EwahCompressedBitArray a = new EwahCompressedBitArray();

            a.Set(410018);
            a.Set(410019);
            a.Set(410020);
            a.Set(410021);
            a.Set(410022);
            a.Set(410023);

            EwahCompressedBitArray b = (EwahCompressedBitArray)a.Clone();

            a.SetSizeInBits(487123, false);
            b.SetSizeInBits(487123, false);

            Assert.AreEqual(a, b);
        }
        private EwahCompressedBitArray getCopyBitmap(EwahCompressedBitArray bitmap)
        {
            var bit = (EwahCompressedBitArray)bitmap.Clone();
            bit.SetSizeInBits(_maxBitSize, false);

            return bit;
        }