public void TestGetSet() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); arr[3] = 400; Assert.AreEqual(400, arr[3]); }
public void TestGetSetBig() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, ulong.MaxValue); arr[3] = ulong.MaxValue; Assert.AreEqual(ulong.MaxValue, arr[3]); }
public void TestGetSetWithSpecifiedStream() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000, new MemoryStream()); arr[3] = 400; Assert.AreEqual(400, arr[3]); }
public void TestConstructorBiggerThan2Gb() { //Test that an array larger than 2GiB in size can be constructed const long LENGTH = 3L * 1024L * 1024L * 1024L; // 3GiB at 1byte per el MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(LENGTH, byte.MaxValue); }
public void TestGetSetByteAligned() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, byte.MaxValue); arr[7] = 12; Assert.AreEqual(12, arr[7]); }
public void TestSetIndexTooSmall() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); Assert.Throws <IndexOutOfRangeException>(() => { arr[-1] = 1; }); }
public void TestGetIndexTooBig() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); Assert.Throws <IndexOutOfRangeException>(() => { ulong val = arr[arr.Length]; }); }
public void TestSetValueTooBig() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); Assert.Throws <ArgumentOutOfRangeException>(() => { arr[1] = arr.MaxValue + 1; }); }
public void TestGetSetBigArray() { long len = 1000000000; MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(len, (ulong)len - 1); long setPos = 50; ulong setVal = 4; arr[setPos] = setVal; Assert.AreEqual(setVal, arr[setPos]); }
public void TestGetSetMultipleValuesReverseOrder() { ulong[] ulongArr = { 23, 47, 1000, 247, 803, 2, 0, 403 }; MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(ulongArr.Length, 1000); //Populate the arr for (int i = ulongArr.Length - 1; i >= 0; i--) { arr[i] = ulongArr[i]; } //Check the values for (int i = ulongArr.Length - 1; i >= 0; i--) { Assert.AreEqual(ulongArr[i], arr[i]); } }
public void TestCalculateBytesPerValue() { Dictionary <ulong, byte> answers = new Dictionary <ulong, byte>() { { 1, 1 }, { 2, 1 }, { 3, 1 }, { 7, 1 }, { byte.MaxValue, 1 }, { uint.MaxValue, 4 }, { ulong.MaxValue, 8 } }; foreach (KeyValuePair <ulong, byte> kvp in answers) { ulong num = kvp.Key; byte numBits = kvp.Value; byte actual = MemoryEfficientByteAlignedBigULongArray.calculateBytesPerValue(num); Assert.AreEqual(numBits, actual); } }
public void ScanTest() { ba_createData.Properties.Settings.Default.EncryptionLength = 8; const string text = "skalskor$sibirien$gabriela$sokrates$belgiens$bicuspid$accorded$jumpsuit$sjalland$bandidos$barefoot$skotland$abrahams$afrodite$gertrude$beaching$sabrinas$gadzooks$girllike$jailbird$abutting$"; var byteAlignedBigULongArray = new MemoryEfficientByteAlignedBigULongArray(text.Length); SuffixArrayInducedSorting.Sufsort(text, byteAlignedBigULongArray, text.Length); var suffixArrayuLong = byteAlignedBigULongArray.ToArray(); var suffixArray = suffixArrayuLong.Select(x => int.Parse(x.ToString())).ToArray(); var intSuffixArray = MinimizeSuffixArray.Minimize(suffixArray, text); //var intLcpArray = BuildLcpArray.Build(intSuffixArray, text); var result = !Scanner.IndexOf(intSuffixArray, text, "accorded$").Equals(-1); var result4 = text.Contains("accorded$"); var result1 = BinarySearchUsingLcp.BinarySearchWLcp(text, intSuffixArray, "accorded$"); var result2 = BinarySearchUsingLcp.BinarySearchWLcp(text, intSuffixArray, "randomss$"); var result3 = !Scanner.IndexOf(intSuffixArray, text, "randomss$").Equals(-1); Assert.AreEqual(true, result); Assert.AreEqual(true, result1); Assert.AreEqual(false, result2); Assert.AreEqual(false, result3); }
public void TestConstructorBig() { //number 7 requires minimum 3 bits, so thats (5bil * 3) / 8 bytes ~= 1.75GiB of RAM used MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(5000000000, 7); }
public void TestConstructor() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10); }
public void TestGetUnset() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); Assert.AreEqual(0, arr[5]); }
public void TestMaxValue() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); Assert.AreEqual(1000, arr.MaxValue); }
public void TestLength() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10); Assert.AreEqual(10, arr.Length); }
public void TestConstructorWithStreamNoMaxValue() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, new MemoryStream()); }
public void DatabaseInsertion() { // SET AS TEST ENVIRONMENT, THIS WILL TRIGGER TEST MODE // CHOOSING TEST DATABASE ba_createData.Properties.Settings.Default.Test = true; // USE RAM ONLY ba_createData.Properties.Settings.Default.UseRAMOnly = true; // USE CACHING ba_createData.Properties.Settings.Default.UseCashing = true; // DEFINE EncryptionLength AS THE LENGTH OF THE INDIVIDUAL SUBSTRINGS IN TEST // ONLY ACCEPT FIXED LENGTH STRINGS ba_createData.Properties.Settings.Default.EncryptionLength = 8; const string text = "skalskor$sibirien$gabriela$sokrates$belgiens$bicuspid$accorded$jumpsuit$sjalland$bandidos$barefoot$skotland$abrahams$afrodite$gertrude$beaching$sabrinas$gadzooks$girllike$jailbird$abutting$"; var dictHolder = new Dictionary <char, string[]>(); // We sort them into buckets var splitArray = text.Split('$'); foreach (var stringVariable in splitArray) { if (!stringVariable.Equals(string.Empty)) { var getPrefix = Convert.ToChar(stringVariable[0]); //Get dict for prefix if it exists if (dictHolder.ContainsKey(getPrefix)) { var currentTextArrayForPrefix = dictHolder[getPrefix].ToList(); currentTextArrayForPrefix.Add(stringVariable); dictHolder[getPrefix] = currentTextArrayForPrefix.ToArray(); } // Dict does not hold any information on the current prefix else { var stringList = new List <string>(); stringList.Add(stringVariable); dictHolder.Add(getPrefix, stringList.ToArray()); } } } // Clear tables Database.ClearTable("TEXT_a"); Database.ClearTable("TEXT_s"); Database.ClearTable("TEXT_g"); Database.ClearTable("TEXT_b"); Database.ClearTable("TEXT_j"); Database.ClearTable("SUFFIXARRAY_s"); Database.ClearTable("SUFFIXARRAY_a"); Database.ClearTable("SUFFIXARRAY_g"); Database.ClearTable("SUFFIXARRAY_b"); Database.ClearTable("SUFFIXARRAY_j"); Database.ClearTable("LCPARRAY_s"); Database.ClearTable("LCPARRAY_a"); Database.ClearTable("LCPARRAY_g"); Database.ClearTable("LCPARRAY_b"); Database.ClearTable("LCPARRAY_j"); // INSERT VALUES INTO DATABSE foreach (KeyValuePair <char, string[]> entry in dictHolder) { var stringList = entry.Value; var concatText = stringList.Select(r => string.Concat(r, '$')).ToList(); var completeText = string.Join(string.Empty, concatText); // do something with entry.Value or entry.Key Database.InsertTextIntoDatabase(completeText, entry.Key); // GET INFORMATION BACK FROM DATABASE var databaseText = Database.GetTextFromDatabase(entry.Key); //var databaseText = "mmiissiissiippii$"; var byteAlignedBigULongArray = new MemoryEfficientByteAlignedBigULongArray(databaseText.Length); ba_createData.Suffix_Arrays.SuffixArrayInducedSorting.Sufsort(databaseText, byteAlignedBigULongArray, databaseText.Length); var suffixArrayuLong = byteAlignedBigULongArray.ToArray(); var suffixArray = suffixArrayuLong.Select(x => int.Parse(x.ToString())).ToArray(); var intSuffixArray = ba_createData.Suffix_Arrays.MinimizeSuffixArray.Minimize(suffixArray, databaseText); var intLcpArray = ba_createData.Suffix_Arrays.BuildLcpArray.Build(intSuffixArray, databaseText); //var suffixArray = new SuffixArray(databaseText, true); //var lowestCommonPrefix = suffixArray._mLcp; //var array = suffixArray._mSa; // PLACE THEM IN DATABASE Database.BuildSqlSuffixArrayDatabase(intSuffixArray, entry.Key, true); Database.BuildLcpDatabase(intLcpArray, entry.Key, true); } }
public void TestConstructorWithMaxValue() { MemoryEfficientByteAlignedBigULongArray arr = new MemoryEfficientByteAlignedBigULongArray(10, 1000); }