From cb3c761e2a8a9bb692a8dd2bf2e7e5327ec371a2 Mon Sep 17 00:00:00 2001 From: dsandersoremutah Date: Tue, 26 Sep 2006 17:39:38 +0000 Subject: [PATCH] Added various methods for settings to DbSystem class in C#. Also changed Languages enum to be a uint instead of an int. Also added compareStrings method to DbSystem class. Also added unit tests for settings and compare strings. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@911 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- xflaim/csharp/cstest/CompareStringsTests.cs | 154 ++++++ xflaim/csharp/cstest/CreateDbTest.cs | 2 +- xflaim/csharp/cstest/RebuildDbTest.cs | 2 +- xflaim/csharp/cstest/SettingsTests.cs | 386 +++++++++++++++ xflaim/csharp/cstest/cstest.cs | 21 +- xflaim/csharp/xflaim/DbSystem.cpp | 251 ++++++++++ xflaim/csharp/xflaim/DbSystem.cs | 498 +++++++++++++++++++- xflaim/csharp/xflaim/Query.cs | 58 +++ xflaim/java/jni/jdbsystem.cpp | 2 +- 9 files changed, 1367 insertions(+), 7 deletions(-) create mode 100644 xflaim/csharp/cstest/CompareStringsTests.cs create mode 100644 xflaim/csharp/cstest/SettingsTests.cs create mode 100644 xflaim/csharp/xflaim/Query.cs diff --git a/xflaim/csharp/cstest/CompareStringsTests.cs b/xflaim/csharp/cstest/CompareStringsTests.cs new file mode 100644 index 0000000..cb23fd9 --- /dev/null +++ b/xflaim/csharp/cstest/CompareStringsTests.cs @@ -0,0 +1,154 @@ +//------------------------------------------------------------------------------ +// Desc: Settings tests +// +// Tabs: 3 +// +// Copyright (c) 2006 Novell, Inc. All Rights Reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the GNU General Public +// License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, contact Novell, Inc. +// +// To contact Novell about this file by physical or electronic mail, +// you may find current contact information at www.novell.com +// +// $Id$ +//------------------------------------------------------------------------------ + +using System; +using System.IO; +using System.Runtime.InteropServices; +using xflaim; + +namespace cstest +{ + + //-------------------------------------------------------------------------- + // String comparison tests. + //-------------------------------------------------------------------------- + public class CompareStringTests : Tester + { + + private bool compareStrTest( + string sLeftStr, + bool bLeftWild, + string sRightStr, + bool bRightWild, + CompareFlags compareFlags, + bool bExpectedEqual, + DbSystem dbSystem) + { + int iCmp; + + beginTest( "Compare Strings, Str1: \"" + sLeftStr + + "\", Str2: \"" + sRightStr + "\""); + + try + { + iCmp = dbSystem.compareStrings( sLeftStr, bLeftWild, + sRightStr, bRightWild, compareFlags, + Languages.FLM_US_LANG); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling compareStrings"); + return( false); + } + if ((bExpectedEqual && iCmp != 0) || + (!bExpectedEqual && iCmp == 0)) + { + endTest( false, false); + System.Console.WriteLine( "Expected Equal [{0}] != Result [{1}]", + bExpectedEqual, iCmp); + System.Console.WriteLine( "Compare Flags: {0}", compareFlags); + System.Console.WriteLine( "Left Wild: {0}", bLeftWild); + System.Console.WriteLine( "Right Wild: {0}", bRightWild); + } + endTest( false, true); + + return( true); + } + + public bool compareStringTests( + DbSystem dbSystem) + { + if (!compareStrTest( "ABC", false, "abc", false, CompareFlags.FLM_COMP_CASE_INSENSITIVE, true, dbSystem)) + { + return( false); + } + if (!compareStrTest( "ABC", false, "abc", false, 0, false, dbSystem)) + { + return( false); + } + if (!compareStrTest( "ab cd", false, "ab cd", false, CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, true, dbSystem)) + { + return( false); + } + if (!compareStrTest( " ab cd", false, "ab cd", false, CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, false, dbSystem)) + { + return( false); + } + if (!compareStrTest( " ab cd", false, "ab cd", false, + CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE, + true, dbSystem)) + { + return( false); + } + if (!compareStrTest( " ab cd", false, " ab cd", false, + CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE, + true, dbSystem)) + { + return( false); + } + if (!compareStrTest( " ab cd ", false, " ab cd", false, + CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE, + false, dbSystem)) + { + return( false); + } + if (!compareStrTest( " ab cd ", false, " ab cd", false, + CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | + CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE | + CompareFlags.FLM_COMP_IGNORE_TRAILING_SPACE, + true, dbSystem)) + { + return( false); + } + if (!compareStrTest( " ab cd ", false, " ab cd ", false, + CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | + CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE | + CompareFlags.FLM_COMP_IGNORE_TRAILING_SPACE, + true, dbSystem)) + { + return( false); + } + if (!compareStrTest( "801-224-8888", false, "8012248888", false, + CompareFlags.FLM_COMP_NO_DASHES, + true, dbSystem)) + { + return( false); + } + if (!compareStrTest( "801_224_8888", false, "801 224 8888", false, + CompareFlags.FLM_COMP_NO_UNDERSCORES, + true, dbSystem)) + { + return( false); + } + if (!compareStrTest( "801_224_8888", false, "801 224 8888", false, + CompareFlags.FLM_COMP_NO_UNDERSCORES | CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, + true, dbSystem)) + { + return( false); + } + return( true); + } + } +} diff --git a/xflaim/csharp/cstest/CreateDbTest.cs b/xflaim/csharp/cstest/CreateDbTest.cs index 1a96e26..fa117c2 100644 --- a/xflaim/csharp/cstest/CreateDbTest.cs +++ b/xflaim/csharp/cstest/CreateDbTest.cs @@ -59,7 +59,7 @@ namespace cstest createOpts.uiMaxRflFileSize = 20000000; createOpts.bKeepRflFiles = 1; createOpts.bLogAbortedTransToRfl = 1; - createOpts.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG; + createOpts.eDefaultLanguage = Languages.FLM_DE_LANG; db = dbSystem.dbCreate( sDbName, null, null, null, null, createOpts); } catch (XFlaimException ex) diff --git a/xflaim/csharp/cstest/RebuildDbTest.cs b/xflaim/csharp/cstest/RebuildDbTest.cs index e6a7fb8..8d17514 100644 --- a/xflaim/csharp/cstest/RebuildDbTest.cs +++ b/xflaim/csharp/cstest/RebuildDbTest.cs @@ -94,7 +94,7 @@ namespace cstest createOpts.uiMaxRflFileSize = 20000000; createOpts.bKeepRflFiles = 1; createOpts.bLogAbortedTransToRfl = 1; - createOpts.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG; + createOpts.eDefaultLanguage = Languages.FLM_DE_LANG; try { dbSystem.dbRebuild( sSrcDbName, null, sDestDbName, null, null, diff --git a/xflaim/csharp/cstest/SettingsTests.cs b/xflaim/csharp/cstest/SettingsTests.cs new file mode 100644 index 0000000..669ab7d --- /dev/null +++ b/xflaim/csharp/cstest/SettingsTests.cs @@ -0,0 +1,386 @@ +//------------------------------------------------------------------------------ +// Desc: Settings tests +// +// Tabs: 3 +// +// Copyright (c) 2006 Novell, Inc. All Rights Reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the GNU General Public +// License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, contact Novell, Inc. +// +// To contact Novell about this file by physical or electronic mail, +// you may find current contact information at www.novell.com +// +// $Id$ +//------------------------------------------------------------------------------ + +using System; +using System.IO; +using System.Runtime.InteropServices; +using xflaim; + +namespace cstest +{ + + //-------------------------------------------------------------------------- + // Settings tests. + //-------------------------------------------------------------------------- + public class SettingsTests : Tester + { + + private bool setTempDirTest( + DbSystem dbSystem) + { + string sSetDir = "abc/def/efg"; + string sGetDir; + + System.IO.Directory.CreateDirectory( sSetDir); + + beginTest( "Set Temporary Directory"); + + try + { + dbSystem.setTempDir( sSetDir); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setTempDir"); + return( false); + } + try + { + sGetDir = dbSystem.getTempDir(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getTempDir"); + return( false); + } + if (sSetDir != sGetDir) + { + endTest( false, false); + System.Console.WriteLine( "GetDir != SetDir"); + System.Console.WriteLine( "GetDir = [{0}], setDir = [{1}]", sGetDir, sSetDir); + } + endTest( false, true); + + return( true); + } + + private bool setCheckpointIntervalTest( + DbSystem dbSystem) + { + uint uiSetValue = 130; + uint uiGetValue; + + beginTest( "Set Checkpoint Interval"); + + try + { + dbSystem.setCheckpointInterval( uiSetValue); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setCheckpointInterval"); + return( false); + } + try + { + uiGetValue = dbSystem.getCheckpointInterval(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getCheckpointInterval"); + return( false); + } + if (uiSetValue != uiGetValue) + { + endTest( false, false); + System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]", + uiGetValue, uiSetValue); + } + endTest( false, true); + + return( true); + } + + private bool setCacheAdjustIntervalTest( + DbSystem dbSystem) + { + uint uiSetValue = 37; + uint uiGetValue; + + beginTest( "Set Cache Adjust Interval"); + + try + { + dbSystem.setCacheAdjustInterval( uiSetValue); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setCacheAdjustInterval"); + return( false); + } + try + { + uiGetValue = dbSystem.getCacheAdjustInterval(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getCacheAdjustInterval"); + return( false); + } + if (uiSetValue != uiGetValue) + { + endTest( false, false); + System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]", + uiGetValue, uiSetValue); + } + endTest( false, true); + + return( true); + } + + private bool setCacheCleanupIntervalTest( + DbSystem dbSystem) + { + uint uiSetValue = 33; + uint uiGetValue; + + beginTest( "Set Cache Cleanup Interval"); + + try + { + dbSystem.setCacheCleanupInterval( uiSetValue); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setCacheCleanupInterval"); + return( false); + } + try + { + uiGetValue = dbSystem.getCacheCleanupInterval(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getCacheCleanupInterval"); + return( false); + } + if (uiSetValue != uiGetValue) + { + endTest( false, false); + System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]", + uiGetValue, uiSetValue); + } + endTest( false, true); + + return( true); + } + + private bool setUnusedCleanupIntervalTest( + DbSystem dbSystem) + { + uint uiSetValue = 31; + uint uiGetValue; + + beginTest( "Set Unused Cleanup Interval"); + + try + { + dbSystem.setUnusedCleanupInterval( uiSetValue); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setUnusedCleanupInterval"); + return( false); + } + try + { + uiGetValue = dbSystem.getUnusedCleanupInterval(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getUnusedCleanupInterval"); + return( false); + } + if (uiSetValue != uiGetValue) + { + endTest( false, false); + System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]", + uiGetValue, uiSetValue); + } + endTest( false, true); + + return( true); + } + + private bool setMaxUnusedTimeTest( + DbSystem dbSystem) + { + uint uiSetValue = 117; + uint uiGetValue; + + beginTest( "Set Max Unused Time"); + + try + { + dbSystem.setMaxUnusedTime( uiSetValue); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setMaxUnusedTime"); + return( false); + } + try + { + uiGetValue = dbSystem.getMaxUnusedTime(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getMaxUnusedTime"); + return( false); + } + if (uiSetValue != uiGetValue) + { + endTest( false, false); + System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]", + uiGetValue, uiSetValue); + } + endTest( false, true); + + return( true); + } + + private bool setQuerySaveMaxTest( + DbSystem dbSystem) + { + uint uiSetValue = 117; + uint uiGetValue; + + beginTest( "Set Query Save Max"); + + try + { + dbSystem.setQuerySaveMax( uiSetValue); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setQuerySaveMax"); + return( false); + } + try + { + uiGetValue = dbSystem.getQuerySaveMax(); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getQuerySaveMax"); + return( false); + } + if (uiSetValue != uiGetValue) + { + endTest( false, false); + System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]", + uiGetValue, uiSetValue); + } + endTest( false, true); + + return( true); + } + + private bool setDirtyCacheLimitsTest( + DbSystem dbSystem) + { + ulong ulSetMaxDirty = 117000000; + ulong ulGetMaxDirty; + ulong ulSetLowDirty = 37000000; + ulong ulGetLowDirty; + + beginTest( "Set Dirty Cache Limits"); + + try + { + dbSystem.setDirtyCacheLimits( ulSetMaxDirty, ulSetLowDirty); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling setDirtyCacheLimits"); + return( false); + } + try + { + dbSystem.getDirtyCacheLimits( out ulGetMaxDirty, out ulGetLowDirty); + } + catch (XFlaimException ex) + { + endTest( false, ex, "calling getDirtyCacheLimits"); + return( false); + } + if (ulSetMaxDirty != ulGetMaxDirty || ulSetLowDirty != ulGetLowDirty) + { + endTest( false, false); + if (ulSetMaxDirty != ulGetMaxDirty) + { + System.Console.WriteLine( "GetMaxDirty [{0}] != SetMaxDirty [{1}]", + ulGetMaxDirty, ulSetMaxDirty); + } + if (ulSetLowDirty != ulGetLowDirty) + { + System.Console.WriteLine( "GetLowDirty [{0}] != SetLowDirty [{1}]", + ulGetLowDirty, ulSetLowDirty); + } + } + endTest( false, true); + + return( true); + } + + public bool settingsTests( + DbSystem dbSystem) + { + if (!setTempDirTest( dbSystem)) + { + return( false); + } + if (!setCheckpointIntervalTest( dbSystem)) + { + return( false); + } + if (!setCacheAdjustIntervalTest( dbSystem)) + { + return( false); + } + if (!setCacheCleanupIntervalTest( dbSystem)) + { + return( false); + } + if (!setUnusedCleanupIntervalTest( dbSystem)) + { + return( false); + } + if (!setMaxUnusedTimeTest( dbSystem)) + { + return( false); + } + if (!setQuerySaveMaxTest( dbSystem)) + { + return( false); + } + if (!setDirtyCacheLimitsTest( dbSystem)) + { + return( false); + } + return( true); + } + } +} diff --git a/xflaim/csharp/cstest/cstest.cs b/xflaim/csharp/cstest/cstest.cs index 8f49e39..fbc461d 100644 --- a/xflaim/csharp/cstest/cstest.cs +++ b/xflaim/csharp/cstest/cstest.cs @@ -38,7 +38,7 @@ namespace cstest public void beginTest( string sTestName) { - System.Console.Write( "{0} ...", sTestName); + System.Console.Write( "{0} ... ", sTestName); } //-------------------------------------------------------------------------- @@ -161,6 +161,7 @@ namespace cstest DbSystem dbSystem = new DbSystem(); +#if false // Database create test CreateDbTest createDb = new CreateDbTest(); @@ -300,6 +301,24 @@ namespace cstest { return; } + +#endif + + // Various settings tests + + SettingsTests settingsTests = new SettingsTests(); + if (!settingsTests.settingsTests( dbSystem)) + { + return; + } + + // Various string comparison tests + + CompareStringTests compareStringTests = new CompareStringTests(); + if (!compareStringTests.compareStringTests( dbSystem)) + { + return; + } } } } diff --git a/xflaim/csharp/xflaim/DbSystem.cpp b/xflaim/csharp/xflaim/DbSystem.cpp index 0d56be7..56f95fa 100644 --- a/xflaim/csharp/xflaim/DbSystem.cpp +++ b/xflaim/csharp/xflaim/DbSystem.cpp @@ -1673,3 +1673,254 @@ Exit: *pui64Stats = (FLMUINT64)((FLMUINT)pStats); return( rc); } + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_setTempDir( + FLMUINT64 ui64This, + const char * pszTempDir) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( pDbSystem->setTempDir( pszTempDir)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_getTempDir( + FLMUINT64 ui64This, + char ** ppszTempDir) +{ + RCODE rc = NE_XFLM_OK; + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + char szPath [F_PATH_MAX_SIZE]; + FLMUINT uiLen; + + if (RC_BAD( rc = pDbSystem->getTempDir( szPath))) + { + goto Exit; + } + uiLen = f_strlen( szPath) + 1; + if (RC_BAD( rc = f_alloc( uiLen, ppszTempDir))) + { + goto Exit; + } + f_memcpy( *ppszTempDir, szPath, uiLen); + +Exit: + return( rc); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setCheckpointInterval( + FLMUINT64 ui64This, + FLMUINT32 ui32Seconds) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setCheckpointInterval( (FLMUINT)ui32Seconds); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getCheckpointInterval( + FLMUINT64 ui64This) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( (FLMUINT32)pDbSystem->getCheckpointInterval()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setCacheAdjustInterval( + FLMUINT64 ui64This, + FLMUINT32 ui32Seconds) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setCacheAdjustInterval( (FLMUINT)ui32Seconds); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getCacheAdjustInterval( + FLMUINT64 ui64This) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( (FLMUINT32)pDbSystem->getCacheAdjustInterval()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setCacheCleanupInterval( + FLMUINT64 ui64This, + FLMUINT32 ui32Seconds) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setCacheCleanupInterval( (FLMUINT)ui32Seconds); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getCacheCleanupInterval( + FLMUINT64 ui64This) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( (FLMUINT32)pDbSystem->getCacheCleanupInterval()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setUnusedCleanupInterval( + FLMUINT64 ui64This, + FLMUINT32 ui32Seconds) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setUnusedCleanupInterval( (FLMUINT)ui32Seconds); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getUnusedCleanupInterval( + FLMUINT64 ui64This) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( (FLMUINT32)pDbSystem->getUnusedCleanupInterval()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setMaxUnusedTime( + FLMUINT64 ui64This, + FLMUINT32 ui32Seconds) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setMaxUnusedTime( (FLMUINT)ui32Seconds); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getMaxUnusedTime( + FLMUINT64 ui64This) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( (FLMUINT32)pDbSystem->getMaxUnusedTime()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_deactivateOpenDb( + FLMUINT64 ui64This, + const char * pszDbFileName, + const char * pszDataDir) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->deactivateOpenDb( pszDbFileName, pszDataDir); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setQuerySaveMax( + FLMUINT64 ui64This, + FLMUINT32 ui32MaxToSave) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setQuerySaveMax( (FLMUINT)ui32MaxToSave); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getQuerySaveMax( + FLMUINT64 ui64This) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + return( (FLMUINT32)pDbSystem->getQuerySaveMax()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setDirtyCacheLimits( + FLMUINT64 ui64This, + FLMUINT64 ui64MaxDirty, + FLMUINT64 ui64LowDirty) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + + pDbSystem->setDirtyCacheLimits( (FLMUINT)ui64MaxDirty, (FLMUINT)ui64LowDirty); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_getDirtyCacheLimits( + FLMUINT64 ui64This, + FLMUINT64 * pui64MaxDirty, + FLMUINT64 * pui64LowDirty) +{ + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + FLMUINT uiMaxDirty; + FLMUINT uiLowDirty; + + pDbSystem->getDirtyCacheLimits( &uiMaxDirty, &uiLowDirty); + *pui64MaxDirty = (FLMUINT64)uiMaxDirty; + *pui64LowDirty = (FLMUINT64)uiLowDirty; +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_compareStrings( + FLMUINT64 ui64This, + const FLMUNICODE * puzLeftString, + FLMBOOL bLeftWild, + const FLMUNICODE * puzRightString, + FLMBOOL bRightWild, + FLMUINT32 ui32CompareRules, + FLMUINT32 ui32Language, + FLMINT32 * pi32Result) +{ + RCODE rc = NE_XFLM_OK; + IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); + FLMINT iResult; + + if (RC_BAD( rc = pDbSystem->compareUnicodeStrings( + puzLeftString, f_unilen( puzLeftString) * 2, bLeftWild, + puzRightString, f_unilen( puzRightString) * 2, bRightWild, + (FLMUINT)ui32CompareRules, (FLMUINT)ui32Language, + &iResult))) + { + goto Exit; + } + *pi32Result = (FLMINT32)iResult; + +Exit: + return( rc); +} diff --git a/xflaim/csharp/xflaim/DbSystem.cs b/xflaim/csharp/xflaim/DbSystem.cs index 586934c..d962ade 100644 --- a/xflaim/csharp/xflaim/DbSystem.cs +++ b/xflaim/csharp/xflaim/DbSystem.cs @@ -41,9 +41,11 @@ namespace xflaim } /// - /// Valid languages + /// Valid languages. + /// IMPORTANT NOTE: These need to be kept in sync with the definitions + /// in ftk.h. /// - public enum Languages : int + public enum Languages : uint { /// English, United States FLM_US_LANG = 0, @@ -183,7 +185,7 @@ namespace xflaim /// /// Default language for the database. Should be one of /// - public uint uiDefaultLanguage; + public Languages eDefaultLanguage; } /// @@ -2150,5 +2152,495 @@ namespace xflaim ulong pDbSystem, out ulong ppDbSystemStats); +//----------------------------------------------------------------------------- +// setTempDir +//----------------------------------------------------------------------------- + + /// + /// Set the directory where temporary files are to be created. + /// + /// + /// Name of temporary directory. + /// + public void setTempDir( + string sTempDir) + { + RCODE rc; + + if ((rc = xflaim_DbSystem_setTempDir( m_pDbSystem, sTempDir)) != 0) + { + throw new XFlaimException( rc); + } + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_DbSystem_setTempDir( + ulong pDbSystem, + [MarshalAs(UnmanagedType.LPStr), In] + string sTempDir); + +//----------------------------------------------------------------------------- +// getTempDir +//----------------------------------------------------------------------------- + + /// + /// Get the directory where temporary files are to be created. + /// + /// + /// Name of temporary directory. + /// + public string getTempDir() + { + RCODE rc; + IntPtr pszTempDir; + string sTempDir; + + if ((rc = xflaim_DbSystem_getTempDir( m_pDbSystem, out pszTempDir)) != 0) + { + throw new XFlaimException( rc); + } + sTempDir = Marshal.PtrToStringAnsi( pszTempDir); + freeUnmanagedMem( pszTempDir); + return( sTempDir); + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_DbSystem_getTempDir( + ulong pDbSystem, + out IntPtr psTempDir); + +//----------------------------------------------------------------------------- +// setCheckpointInterval +//----------------------------------------------------------------------------- + + /// + /// Set the checkpoint interval. The checkpoint interval is the maximum number + /// of seconds that XFLAIM will allow to go by before a checkpoint is forced. + /// Note that XFLAIM attempt to complete a checkpoint as often as possible. + /// However, if many update transctions are being performed one after the other + /// with no break, it is possible that XFLAIM will not be able to complete + /// a checkpoint. If the checkpoint interval is exceeded without a checkpoint + /// being done, XFLAIM will hold off updaters until a checkpoint can be + /// completed. This is what is known as a "forced" checkpoint. + /// + /// + /// Checkpoint interval, in seconds. + /// + public void setCheckpointInterval( + uint uiSeconds) + { + xflaim_DbSystem_setCheckpointInterval( m_pDbSystem, uiSeconds); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setCheckpointInterval( + ulong pDbSystem, + uint uiSeconds); + +//----------------------------------------------------------------------------- +// getCheckpointInterval +//----------------------------------------------------------------------------- + + /// + /// Get the current checkpoint interval. + /// + /// + /// Returns current checkpoint interval, in seconds. + /// + public uint getCheckpointInterval() + { + return( xflaim_DbSystem_getCheckpointInterval( m_pDbSystem)); + } + + [DllImport("xflaim")] + private static extern uint xflaim_DbSystem_getCheckpointInterval( + ulong pDbSystem); + +//----------------------------------------------------------------------------- +// setCacheAdjustInterval +//----------------------------------------------------------------------------- + + /// + /// Set the cache adjust interval. The cache adjust interval is only used + /// when the application has set a dynamic cache limit (see the + /// setDynamicCacheLimit API). It specifies how often XFLAIM should calculate + /// a new cache limit. + /// + /// + /// Specifies the number of seconds between times when XFLAIM + /// recalculates a new cache limit. + /// + public void setCacheAdjustInterval( + uint uiSeconds) + { + xflaim_DbSystem_setCacheAdjustInterval( m_pDbSystem, uiSeconds); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setCacheAdjustInterval( + ulong pDbSystem, + uint uiSeconds); + +//----------------------------------------------------------------------------- +// getCacheAdjustInterval +//----------------------------------------------------------------------------- + + /// + /// Get the current cache adjust interval. + /// + /// + /// Returns the current cache adjust interval, in seconds. + /// + public uint getCacheAdjustInterval() + { + return( xflaim_DbSystem_getCacheAdjustInterval( m_pDbSystem)); + } + + [DllImport("xflaim")] + private static extern uint xflaim_DbSystem_getCacheAdjustInterval( + ulong pDbSystem); + +//----------------------------------------------------------------------------- +// setCacheCleanupInterval +//----------------------------------------------------------------------------- + + /// + /// Set the current cache cleanup interval. XFLAIM has a background thread + /// that periodically wakes up and removes "old" objects from cache. Old + /// objects are objects that are prior versions of current objects. During + /// a cleanup cycle, XFLAIM determines which of these objects are never going + /// to be needed again and removes them from cache. + /// + /// + /// Specifies the number of seconds between times when XFLAIM + /// cleans up "old" objects in cache. + /// + public void setCacheCleanupInterval( + uint uiSeconds) + { + xflaim_DbSystem_setCacheCleanupInterval( m_pDbSystem, uiSeconds); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setCacheCleanupInterval( + ulong pDbSystem, + uint uiSeconds); + +//----------------------------------------------------------------------------- +// getCacheCleanupInterval +//----------------------------------------------------------------------------- + + /// + /// Get the current cache cleanup interval. + /// + /// + /// Returns the current cache cleanup interval, in seconds. + /// + public uint getCacheCleanupInterval() + { + return( xflaim_DbSystem_getCacheCleanupInterval( m_pDbSystem)); + } + + [DllImport("xflaim")] + private static extern uint xflaim_DbSystem_getCacheCleanupInterval( + ulong pDbSystem); + +//----------------------------------------------------------------------------- +// setUnusedCleanupInterval +//----------------------------------------------------------------------------- + + /// + /// Set the current unused cleanup interval. XFLAIM has a background thread + /// that periodically wakes up and removes objects that have not been in use + /// for a certain amount of time (as specified by the setMaxUnusedTime method). + /// This includes file descriptors and other in-memory objects that XFLAIM + /// may have been holding on to in case they are reused. It does NOT include + /// blocks in block cache or nodes in node cache. + /// + /// + /// Specifies the number of seconds between times when XFLAIM + /// cleans up "unused" objects in cache. + /// + public void setUnusedCleanupInterval( + uint uiSeconds) + { + xflaim_DbSystem_setUnusedCleanupInterval( m_pDbSystem, uiSeconds); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setUnusedCleanupInterval( + ulong pDbSystem, + uint uiSeconds); + +//----------------------------------------------------------------------------- +// getUnusedCleanupInterval +//----------------------------------------------------------------------------- + + /// + /// Get the current unused cleanup interval. + /// + /// + /// Returns the current unused cleanup interval, in seconds. + /// + public uint getUnusedCleanupInterval() + { + return( xflaim_DbSystem_getUnusedCleanupInterval( m_pDbSystem)); + } + + [DllImport("xflaim")] + private static extern uint xflaim_DbSystem_getUnusedCleanupInterval( + ulong pDbSystem); + +//----------------------------------------------------------------------------- +// setMaxUnusedTime +//----------------------------------------------------------------------------- + + /// + /// Set the maximum unused time limit. XFLAIM has a background thread + /// that periodically wakes up and removes objects that have not been in + /// for a certain amount of time. This includes file descriptors and + /// other in-memory objects that XFLAIM may have been holding on to in case + /// they are reused. This method allows an application to specify a timeout + /// value that determines the maximum time an object may be "unused" before + /// it is cleaned up. + /// + /// + /// Specifies the time limit (in seconds) for objects to be + /// "unused" before they are cleaned up. + /// + public void setMaxUnusedTime( + uint uiSeconds) + { + xflaim_DbSystem_setMaxUnusedTime( m_pDbSystem, uiSeconds); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setMaxUnusedTime( + ulong pDbSystem, + uint uiSeconds); + +//----------------------------------------------------------------------------- +// getMaxUnusedTime +//----------------------------------------------------------------------------- + + /// + /// Get the maximum unused time limit. + /// + /// + /// Returns the maximum unused time limit, in seconds. + /// + public uint getMaxUnusedTime() + { + return( xflaim_DbSystem_getMaxUnusedTime( m_pDbSystem)); + } + + [DllImport("xflaim")] + private static extern uint xflaim_DbSystem_getMaxUnusedTime( + ulong pDbSystem); + +//----------------------------------------------------------------------------- +// deactivateOpenDb +//----------------------------------------------------------------------------- + + /// + /// Deactivate an open database. This method allows an application to force + /// a particular database to be closed by all threads. + /// + /// + /// The name of the control file of the database to. + /// deactivate. For more explanation see documentation for + /// . + /// + /// + /// The data file directory. See for more information. + /// + public void deactivateOpenDb( + string sDbFileName, + string sDataDir) + { + xflaim_DbSystem_deactivateOpenDb( m_pDbSystem, sDbFileName, sDataDir); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_deactivateOpenDb( + ulong pDbSystem, + [MarshalAs(UnmanagedType.LPStr), In] + string sDbFileName, + [MarshalAs(UnmanagedType.LPStr), In] + string sDataDir); + +//----------------------------------------------------------------------------- +// setQuerySaveMax +//----------------------------------------------------------------------------- + + /// + /// Set maximum number of queries to save statistics and information on. NOTE: + /// If the method is called, the maximum is set to 20 until + /// is called - unless a non-zero value has already been set. + /// + /// + /// The maximum number of queries to save information on. The + /// last N queries that were executed will be saved. + /// + public void setQuerySaveMax( + uint uiMaxToSave) + { + xflaim_DbSystem_setQuerySaveMax( m_pDbSystem, uiMaxToSave); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setQuerySaveMax( + ulong pDbSystem, + uint uiMaxToSave); + +//----------------------------------------------------------------------------- +// getQuerySaveMax +//----------------------------------------------------------------------------- + + /// + /// Get maximum number of queries to save statistics and information on. + /// + /// + /// Returns the maximum number of queries to save information on. + /// + public uint getQuerySaveMax() + { + return( xflaim_DbSystem_getQuerySaveMax( m_pDbSystem)); + } + + [DllImport("xflaim")] + private static extern uint xflaim_DbSystem_getQuerySaveMax( + ulong pDbSystem); + +//----------------------------------------------------------------------------- +// setDirtyCacheLimits +//----------------------------------------------------------------------------- + + /// + /// Set dirty cache limits. + /// + /// + /// This is the maximum amount of cache (in bytes) that the system + /// should allow to be dirty. Once the maximum is exceeded, XFLAIM will + /// attempt to write out dirty blocks until the dirty cache is less than or + /// equal to the value specified by ulLowDirty. + /// + /// + /// This number is the low threshhold for dirty cache. It is + /// a hysteresis value. Once dirty cache exceeds the value specified by + /// the ulMaxDirty parameter, XFLAIM will write out dirty blocks until the + /// dirty cache is once again less than or equal to this number. + /// + public void setDirtyCacheLimits( + ulong ulMaxDirty, + ulong ulLowDirty) + { + xflaim_DbSystem_setDirtyCacheLimits( m_pDbSystem, ulMaxDirty, ulLowDirty); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_setDirtyCacheLimits( + ulong pDbSystem, + ulong ulMaxDirty, + ulong ulLowDirty); + +//----------------------------------------------------------------------------- +// getDirtyCacheLimits +//----------------------------------------------------------------------------- + + /// + /// Get dirty cache limits. + /// + /// + /// Returns the maximum dirty cache limit. + /// + /// + /// Returns the low dirty cache limit. + /// + public void getDirtyCacheLimits( + out ulong ulMaxDirty, + out ulong ulLowDirty) + { + xflaim_DbSystem_getDirtyCacheLimits( m_pDbSystem, out ulMaxDirty, out ulLowDirty); + } + + [DllImport("xflaim")] + private static extern void xflaim_DbSystem_getDirtyCacheLimits( + ulong pDbSystem, + out ulong pulMaxDirty, + out ulong pulLowDirty); + +//----------------------------------------------------------------------------- +// compareStrings +//----------------------------------------------------------------------------- + + /// + /// Compare two strings. + /// + /// + /// This is the string on the left side of the comparison operation. + /// + /// + /// This flag, if true, specifies that wildcard characters + /// found in sLeftString should be treated as wildcard characters instead of + /// literal characters to compare. If false, the wildcard character (*) is + /// treated like a normal character. + /// + /// + /// This is the string on the right side of the comparison operation. + /// + /// + /// This flag, if true, specifies that wildcard characters + /// found in sRightString should be treated as wildcard characters instead of + /// literal characters to compare. If false, the wildcard character (*) is + /// treated like a normal character. + /// + /// + /// Flags for doing string comparisons. Should be logical ORs of the members + /// of . + /// + /// + /// Language to use for doing collation of strings. + /// + /// + /// Returns a value indicating whether sLeftString is less than, equal to, + /// or greater than sRightString. A value of -1 means sLeftString < sRightString. + /// A value of 0 means the strings are equal. A value of 1 means that + /// sLeftString > sRightString. + /// + public int compareStrings( + string sLeftString, + bool bLeftWild, + string sRightString, + bool bRightWild, + CompareFlags eCompareFlags, + Languages eLanguage) + { + RCODE rc; + int iResult; + + if ((rc = xflaim_DbSystem_compareStrings( m_pDbSystem, + sLeftString, (int)(bLeftWild ? 1 : 0), + sRightString, (int)(bRightWild ? 1 : 0), + eCompareFlags, eLanguage, out iResult)) != 0) + { + throw new XFlaimException( rc); + } + return( iResult); + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_DbSystem_compareStrings( + ulong pDbSystem, + [MarshalAs(UnmanagedType.LPWStr), In] + string sLeftString, + int bLeftWild, + [MarshalAs(UnmanagedType.LPWStr), In] + string sRightString, + int bRightWild, + CompareFlags eCompareRules, + Languages eLanguage, + out int piResult); + } } diff --git a/xflaim/csharp/xflaim/Query.cs b/xflaim/csharp/xflaim/Query.cs new file mode 100644 index 0000000..6ad3756 --- /dev/null +++ b/xflaim/csharp/xflaim/Query.cs @@ -0,0 +1,58 @@ +//------------------------------------------------------------------------------ +// Desc: Db Check Status +// +// Tabs: 3 +// +// Copyright (c) 2006 Novell, Inc. All Rights Reserved. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the GNU General Public +// License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, contact Novell, Inc. +// +// To contact Novell about this file by physical or electronic mail, +// you may find current contact information at www.novell.com +// +// $Id$ +//------------------------------------------------------------------------------ + +using System; +using System.Runtime.InteropServices; + +namespace xflaim +{ + + /// + /// Flags for comparing strings. + /// IMPORTANT NOTE: This needs to be kept in sync with the definitions in ftk.h + /// + [Flags] + public enum CompareFlags : uint + { + /// Do case sensitive comparison. + FLM_COMP_CASE_INSENSITIVE = 0x0001, + /// Compare multiple whitespace characters as a single space. + FLM_COMP_COMPRESS_WHITESPACE = 0x0002, + /// Ignore all whitespace during comparison. + FLM_COMP_NO_WHITESPACE = 0x0004, + /// Ignore all underscore characters during comparison. + FLM_COMP_NO_UNDERSCORES = 0x0008, + /// Ignore all dash characters during comparison. + FLM_COMP_NO_DASHES = 0x0010, + /// Treat newlines and tabs as spaces during comparison. + FLM_COMP_WHITESPACE_AS_SPACE = 0x0020, + /// Ignore leading space characters during comparison. + FLM_COMP_IGNORE_LEADING_SPACE = 0x0040, + /// Ignore trailing space characters during comparison. + FLM_COMP_IGNORE_TRAILING_SPACE = 0x0080, + /// Compare wild cards + FLM_COMP_WILD = 0x0100 + } +} diff --git a/xflaim/java/jni/jdbsystem.cpp b/xflaim/java/jni/jdbsystem.cpp index 7b19b21..c974ee4 100644 --- a/xflaim/java/jni/jdbsystem.cpp +++ b/xflaim/java/jni/jdbsystem.cpp @@ -3252,7 +3252,7 @@ JNIEXPORT jstring JNICALL Java_xflaim_DbSystem__1getTempDir( char szPath [F_PATH_MAX_SIZE]; jstring jPath = NULL; - if (RC_BAD( rc = THIS_DBSYS()->setTempDir( szPath))) + if (RC_BAD( rc = THIS_DBSYS()->getTempDir( szPath))) { ThrowError( rc, pEnv); goto Exit;