Structure search cache

User eda6f877b4

15-06-2014 20:06:29

Hi,


My first search allways takes an exessive amount of time. I have tried creating a chache using the code below, but it does not seem to help.


String identifier = "THE UNIQUE IDENTIFIER";


            string cacheId = CacheRegistrationUtil.getCacheID();


            if (cacheId != identifier) {


                CacheRegistrationUtil.setPermanentCacheID(identifier);


            }


This is a web application hosted within IIS.


JChem version: 1.6.5.


BR


Dann

ChemAxon 4375c6431d

17-06-2014 08:49:06

Hi Dann,


 


These code examples show you how to fill and search in our memory table:


public IJChemMemoryTable CreateMemoryTable()
{
return new JChemMemoryTable();
}        

public void FillMemoryTable(IJChemMemoryTable memoryTable)
        {
            IJChemMolecule molecule = MainFactory.Chemistry.CreateMolecule("benzene");
            memoryTable.Add(molecule);

            IJChemMolecule[] molecules = new IJChemMolecule[]{
                MainFactory.Chemistry.CreateMolecule("methylpropane"),
                MainFactory.Chemistry.CreateMolecule("benzol")
            };

            memoryTable.Add(molecules);
            Console.WriteLine(string.Format("Count: {0}", memoryTable.Count));
        }


        public void IsMatchMolecule(IJChemMemoryTable memoryTable)
        {
            IJChemMolecule query = MainFactory.Chemistry.CreateMolecule("benzene");
            bool isMatch = memoryTable.
IsMatch(query);
            Console.WriteLine(string.Format("IsMatch: {0}", isMatch));
        }


        public void FindAllMolecule(IJChemMemoryTable memoryTable)
        {
            memoryTable.Options.SearchType = JChemSearchTypes.Similarity;
            memoryTable.Options.SimilarityThreshold = 1f;
            memoryTable.Options.InvertResults = true;
            IJChemMolecule query = MainFactory.Chemistry.CreateMolecule("benzene");

            IEnumerable<IJChemMolecule> result = memoryTable.FindAll(query);

            foreach (IJChemMolecule molecule in result)
                Console.WriteLine(molecule.Formula);
        }

        public void ClearMemoryTable(IJChemMemoryTable memoryTable)
        {
            Console.WriteLine(string.Format("Count before clear: {0}", memoryTable.Count));

            memoryTable.Clear();

            Console.WriteLine(string.Format("Count aftre clear: {0}", memoryTable.Count));

     }

I attached the original *.cs as well. You need at least 6.3.x version of our .NET API. You can find more database example in our homepage: http://www.chemaxon.com/dotNET/6.3/examples.html#connection


I hope this helps you.


 


Regards,


Miklos