[Logo] Space4J - Java Persistence
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Moderation Log] Moderation Log   [Register] Register / 
[Login] Login 
Just few questions...  XML
Forum Index » General Questions
Author Message
JCDenton



Joined: 03/12/2008 03:51:31
Messages: 3
Offline

Hi guys,

first off all, thank you for this interesting tool. I was looking for the component which would allow me to serialize a big amount of objects. Space4j looks very appropriate for this request, most off all because of the index support. I just have a few questions...

1) All objects all serialized in the "./space4_db" directory. Is somehow possible to set the directory and file where the objects will be serialized?

2) I want to use REGULAR index (unique-index, non-sorted), but I didn't find an example of how to get my stored value....Of course I checked an example on this forum

User u = usersById.get(2345);

but I don't understand one thing, what type of the object is usersById???? Can you provide full example where REGULAR index is used.

thank you








JCDenton



Joined: 03/12/2008 03:51:31
Messages: 3
Offline

I forgot to ask one thing....

Are all serializable objects being held in memory during the working with Space4j???? I mean, let's suppose that I've added 1K of objects into space4j...My question is, are all of these objects in memory? Or does it mean that half of these objects (the most used) is in memory and the second half is saved on HD???

Thanks!


saoj



Joined: 05/09/2008 13:26:12
Messages: 46
Offline



1) All objects all serialized in the "./space4_db" directory. Is somehow possible to set the directory and file where the objects will be serialized?


Download the beta jar from http://www.space4j.org/beta/space4j.jar and use the SimpleLogger.setDir("c:\\mydb") for example. You can also use a relative path like SimpleLogger.setDir("mydb").


2) I want to use REGULAR index (unique-index, non-sorted), but I didn't find an example of how to get my stored value....Of course I checked an example on this forum

User u = usersById.get(2345);

but I don't understand one thing, what type of the object is usersById???? Can you provide full example where REGULAR index is used.


usersById in this example is the map which is returned by the Index objetct.



Once you have created the index object by calling im.createIndex(indx, space4j); you can get its map to perform the lookup:



Note that you need a key object. You can even have composite indexes with composite keys (more than one attribute).

Also note that is recommended that you store your objects in the space inside Maps not Lists. The reason for that is the same reason for always having a Primary Key in a database table.


-Sergio Oliveira Junior
saoj



Joined: 05/09/2008 13:26:12
Messages: 46
Offline


Are all serializable objects being held in memory during the working with Space4j????


Yes, all objects are in memory, but they are no serialized in memory. They get serialized when they are logged to disk in a command or when a snapshot is taken.


I mean, let's suppose that I've added 1K of objects into space4j...My question is, are all of these objects in memory? Or does it mean that half of these objects (the most used) is in memory and the second half is saved on HD???


All objects are always in memory, even if they are stale objects that are not being accessed.

I thought about a *passivation* strategy for Space4J in the past, that would swap unused/old objects from memory to disk. But that complicates the whole thing and loses the focus of Space4J which is in-memory access straight through collections.

If you have a logging table that grows indefintely and the information is not accessed regularly, you will be better off with a text log or a relational database. To keep this information in memory would be just a waste of RAM.

This message was edited 2 times. Last update was at 03/12/2008 13:53:28



-Sergio Oliveira Junior
JCDenton



Joined: 03/12/2008 03:51:31
Messages: 3
Offline

Good. Thanks for answers.

Best Regards


 
Forum Index » General Questions
Go to:   
Powered by JForum 2.1.8 © JForum Team