Skip to content

Commit

Permalink
removed space in index keys of IndexQuery.hs and IndexText.hs by the …
Browse files Browse the repository at this point in the history
…character '-' .Please rename your index data files to be compatible. See TCache.cabal
  • Loading branch information
agocorona committed Jun 3, 2014
1 parent 0e2aa4c commit a0a83cb
Show file tree
Hide file tree
Showing 70 changed files with 303 additions and 213 deletions.
9 changes: 7 additions & 2 deletions Data/TCache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ refcache =unsafePerformIO $ newCache >>= newIORef
-- | Creates a new cache. Experimental
newCache :: IO (Ht , Integer)
newCache =do
c <- H.new -- (==) H.hashString
c <- H.new -- (==) H.hashString
return (c,0)

-- | Return the total number of DBRefs in the cache. For debug purposes.
Expand Down Expand Up @@ -473,9 +473,11 @@ getDBRef key= unsafePerformIO $! getDBRef1 $! key where
getDBRef1 :: (Typeable a, IResource a) => String -> IO (DBRef a)
getDBRef1 key = do
(cache,_) <- readIORef refcache -- !> ("getDBRef "++ key)
takeMVar getRefFlag
r <- H.lookup cache key
case r of
Just (CacheElem mdb w) -> do
putMVar getRefFlag ()
mr <- deRefWeak w
case mr of
Just dbref@(DBRef _ tv) ->
Expand All @@ -487,12 +489,15 @@ getDBRef key= unsafePerformIO $! getDBRef1 $! key where
Nothing -> finalize w >> getDBRef1 key -- !> "finalize" -- the weak pointer has not executed his finalizer

Nothing -> do
tv<- newTVarIO NotRead -- !> "Nothing"
tv <- newTVarIO NotRead -- !> "Nothing"
dbref <- evaluate $ DBRef key tv
w <- mkWeakPtr dbref . Just $ fixToCache dbref
H.insert cache key (CacheElem Nothing w)
putMVar getRefFlag ()
return dbref

getRefFlag= unsafePerformIO $ newMVar ()

{- | Create the object passed as parameter (if it does not exist) and
-- return its reference in the IO monad.
-- If an object with the same key already exists, it is returned as is
Expand Down
9 changes: 5 additions & 4 deletions Data/TCache/Defs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ serialization/deserialization are not performance critical in TCache
Read, Show, instances are implicit instances of Serializable
> serialize = show
> deserialize= read
> serialize = pack . show
> deserialize= read . unpack
Since write and read to disk of to/from the cache are not be very frequent
The performance of serialization is not critical.
Expand Down Expand Up @@ -125,15 +125,16 @@ data Persist = Persist{
, write :: (Key -> B.ByteString -> IO()) -- ^ write. It must be strict
, delete :: (Key -> IO())} -- ^ delete

-- | Implements default persistence of objects in files with their keys as filenames
-- | Implements default default-persistence of objects in files with their keys as filenames
filePersist = Persist
{readByKey= defaultReadByKey
,write = defaultWrite
,delete = defaultDelete}

defaultPersistIORef = unsafePerformIO $ newIORef filePersist

-- | Set the default persistence mechanism of all 'serializable' objetcts. By default it is 'filePersist'
-- | Set the default persistence mechanism of all 'serializable' objects that have
-- @setPersist= const Nothing@. By default it is 'filePersist'
--
-- this statement must be the first one before any other TCache call
setDefaultPersist p= writeIORef defaultPersistIORef p
Expand Down
6 changes: 3 additions & 3 deletions Data/TCache/IndexQuery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ import System.IO.Unsafe
import Data.ByteString.Lazy.Char8(pack, unpack)


class (Read reg, Read a, Show reg, Show a
class (Read a, Show a
, IResource reg,Typeable reg
, Typeable a,Ord a,PersistIndex reg)
=> Queriable reg a

instance (Read reg, Read a, Show reg, Show a
instance (Read a, Show a
, IResource reg,Typeable reg
, Typeable a,Ord a,PersistIndex reg)
=> Queriable reg a
Expand Down Expand Up @@ -136,7 +136,7 @@ instance (Queriable reg a) => Serializable (Index reg a) where



keyIndex treg tv= "index " ++ show treg ++ show tv
keyIndex treg tv= "index-" ++ show treg ++ show tv

instance (Typeable reg, Typeable a) => Indexable (Index reg a) where
key map= keyIndex typeofreg typeofa
Expand Down
2 changes: 1 addition & 1 deletion Data/TCache/IndexText.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ instance Serializable IndexText where
setPersist= const Nothing

instance Indexable IndexText where
key (IndexText v _ _ _ _)= "indextext " ++ v
key (IndexText v _ _ _ _)= "indextext-" ++ v

instance IResource IndexText where
keyResource = key
Expand Down
13 changes: 12 additions & 1 deletion TCache.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: TCache
version: 0.11.0.0
version: 0.12.0
cabal-version: >= 1.6
build-type: Simple
license: BSD3
Expand All @@ -10,9 +10,20 @@ description: TCache is a transactional cache with configurable persitence. It al
STM transactions for objects that syncronize with their user-defined storages.
State in memory and into permanent storage is transactionally coherent.
.
It has interface defined for Amazon WS and Yesod Persistent backends defined in tcache-<backend>
packages.
Persistent is a multi-backend interface for SQL and non SQL databases such in Mongo-db
.
The package implements serializable STM references, access by key and by record field value, triggers,
full text and field indexation, default serialization and a query language based on record fields
.
Since the STM references can be included in data structures and serialized, this is right
for graph databases and other NoSQL databases.
.
0.12.0 space in index data in indexQuery.hs and IndexText.hs triggered errors in the AWS backend.
The space has been changed by '-'. So rename the "index *" files in the TCache folder
in order to be recognized.
.
0.11.0.0 added setIndexParsist to define persistence for indexes by type. started the addition of readDBRefs, readResources and so on for simultaneous read, writes and deletes of
objects of the same type.
.
Expand Down
2 changes: 1 addition & 1 deletion demos/.tcachedata/Emp1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Emp {ename = "Emp1", salary = 41140.0}
Emp {ename = "Emp1", salary = 37400.0}
2 changes: 1 addition & 1 deletion demos/.tcachedata/Emp2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Emp {ename = "Emp2", salary = 42350.0}
Emp {ename = "Emp2", salary = 38500.0}
2 changes: 1 addition & 1 deletion demos/.tcachedata/Emp4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Emp {ename = "Emp4", salary = 77440.0}
Emp {ename = "Emp4", salary = 70400.0}
Binary file added dist/TCache-0.12.0.tar.gz
Binary file not shown.
Binary file modified dist/build/Data/Persistent/Collection.hi
Binary file not shown.
Binary file modified dist/build/Data/Persistent/Collection.o
Binary file not shown.
Binary file modified dist/build/Data/Persistent/IDynamic.hi
Binary file not shown.
Binary file modified dist/build/Data/Persistent/IDynamic.o
Binary file not shown.
Binary file modified dist/build/Data/TCache.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/DefaultPersistence.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/DefaultPersistence.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/Defs.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/Defs.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/IResource.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/IResource.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/IndexQuery.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/IndexQuery.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/IndexText.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/IndexText.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/Memoization.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/Memoization.o
Binary file not shown.
Binary file modified dist/build/Data/TCache/Triggers.hi
Binary file not shown.
Binary file modified dist/build/Data/TCache/Triggers.o
Binary file not shown.
Binary file added dist/build/HSTCache-0.12.0.o
Binary file not shown.
16 changes: 9 additions & 7 deletions dist/build/autogen/Paths_TCache.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Paths_TCache (
version,
getBinDir, getLibDir, getDataDir, getLibexecDir,
getDataFileName
getDataFileName, getSysconfDir
) where

import qualified Control.Exception as Exception
Expand All @@ -14,19 +14,21 @@ catchIO = Exception.catch


version :: Version
version = Version {versionBranch = [0,11,0,0], versionTags = []}
bindir, libdir, datadir, libexecdir :: FilePath
version = Version {versionBranch = [0,12,0], versionTags = []}
bindir, libdir, datadir, libexecdir, sysconfdir :: FilePath

bindir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\bin"
libdir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\TCache-0.11.0.0\\ghc-7.6.3"
datadir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\TCache-0.11.0.0"
libexecdir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\TCache-0.11.0.0"
libdir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\i386-windows-ghc-7.6.3\\TCache-0.12.0"
datadir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\i386-windows-ghc-7.6.3\\TCache-0.12.0"
libexecdir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\TCache-0.12.0"
sysconfdir = "C:\\Users\\magocoal\\AppData\\Roaming\\cabal\\etc"

getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath
getBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
getBinDir = catchIO (getEnv "TCache_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "TCache_libdir") (\_ -> return libdir)
getDataDir = catchIO (getEnv "TCache_datadir") (\_ -> return datadir)
getLibexecDir = catchIO (getEnv "TCache_libexecdir") (\_ -> return libexecdir)
getSysconfDir = catchIO (getEnv "TCache_sysconfdir") (\_ -> return sysconfdir)

getDataFileName :: FilePath -> IO FilePath
getDataFileName name = do
Expand Down
67 changes: 65 additions & 2 deletions dist/build/autogen/cabal_macros.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */

/* package RefSerialize-0.3.1.0 */
#define VERSION_RefSerialize "0.3.1.0"
/* package RefSerialize-0.3.1.1 */
#define VERSION_RefSerialize "0.3.1.1"
#define MIN_VERSION_RefSerialize(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 3 || \
Expand Down Expand Up @@ -70,3 +70,66 @@
(major1) == 0 && (major2) < 11 || \
(major1) == 0 && (major2) == 11 && (minor) <= 3)

/* tool cpphs-1.18.4 */
#define TOOL_VERSION_cpphs "1.18.4"
#define MIN_TOOL_VERSION_cpphs(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 18 || \
(major1) == 1 && (major2) == 18 && (minor) <= 4)

/* tool gcc-4.5.2 */
#define TOOL_VERSION_gcc "4.5.2"
#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\
(major1) < 4 || \
(major1) == 4 && (major2) < 5 || \
(major1) == 4 && (major2) == 5 && (minor) <= 2)

/* tool ghc-7.6.3 */
#define TOOL_VERSION_ghc "7.6.3"
#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\
(major1) < 7 || \
(major1) == 7 && (major2) < 6 || \
(major1) == 7 && (major2) == 6 && (minor) <= 3)

/* tool ghc-pkg-7.6.3 */
#define TOOL_VERSION_ghc_pkg "7.6.3"
#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\
(major1) < 7 || \
(major1) == 7 && (major2) < 6 || \
(major1) == 7 && (major2) == 6 && (minor) <= 3)

/* tool haddock-2.13.2 */
#define TOOL_VERSION_haddock "2.13.2"
#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\
(major1) < 2 || \
(major1) == 2 && (major2) < 13 || \
(major1) == 2 && (major2) == 13 && (minor) <= 2)

/* tool happy-1.19.3 */
#define TOOL_VERSION_happy "1.19.3"
#define MIN_TOOL_VERSION_happy(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 19 || \
(major1) == 1 && (major2) == 19 && (minor) <= 3)

/* tool hpc-0.6 */
#define TOOL_VERSION_hpc "0.6"
#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 6 || \
(major1) == 0 && (major2) == 6 && (minor) <= 0)

/* tool hsc2hs-0.67 */
#define TOOL_VERSION_hsc2hs "0.67"
#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 67 || \
(major1) == 0 && (major2) == 67 && (minor) <= 0)

/* tool hscolour-1.20 */
#define TOOL_VERSION_hscolour "1.20"
#define MIN_TOOL_VERSION_hscolour(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 20 || \
(major1) == 1 && (major2) == 20 && (minor) <= 0)

Binary file added dist/build/libHSTCache-0.12.0.a
Binary file not shown.
Loading

0 comments on commit a0a83cb

Please sign in to comment.