STG Library
So yeah this is another project that I've made as a supply for one of my main's (TeamWork). Since my old EGNoSQL solution wasn't that "fast" according to a memory usage aspect. This one is kind of different. Let me show you what I mean...
First of all this is used to store a huge amount of data in a compressed archive. It automatically writes the data to the archive without the need to "load" it first on memory, which results in a huge memory save. As for the read aspect every data stored in the archive has its own header, which contains its name, length and offset. Those are used to read the data from the archive, yet without the memory hassle.
Yes if you store like 100 objects in the archive they will have 100 headers, but loading small amount of data in the RAM instead of just dumping there 100 objects like 1MB big is still better. A header length is: 8 + <number of characters in the object name>. Which is considerably smaller.
Yet this does not allow you to delete the data from the archive, which is kind of a pain in the ass (programmatically talking), I will eventually add this functionality, yet if anybody is interested in doing this (or even improving what I've already done) is free to do so, since I've included the source code.
Here's an example of how to create a new stg storage:
As you may have seen the db.Data.WriteData( ... ) is used to insert a new object in the storage, it then returns the header of the data. In the case above we store directly the header returned in our headers collection. Source is documented, which will allow you to see what a function does when you use it in your code.
Using the same technique but to read the data:
db.Data.ReadData( ... ) allows you to read a specific area of the storage which corresponds to the given header.
This time this DOES NOT include any outside links. (Even EGNoSQL didn't since I've hex edited the exe, anyways..)
Virus Scans: #1 ~ #2
AGAIN, SOURCE CODE IS INCLUDED SO YOU ARE ABLE TO WRITE WHATEVER YOU WANT AND MODIFY THE GIVEN CLASSES. CREDITS WOULD BE APPRECIATED !
Thanks to NTAuthority, I've found in the aIWNet server source the log class and I've been using it since then.
First of all this is used to store a huge amount of data in a compressed archive. It automatically writes the data to the archive without the need to "load" it first on memory, which results in a huge memory save. As for the read aspect every data stored in the archive has its own header, which contains its name, length and offset. Those are used to read the data from the archive, yet without the memory hassle.
Yes if you store like 100 objects in the archive they will have 100 headers, but loading small amount of data in the RAM instead of just dumping there 100 objects like 1MB big is still better. A header length is: 8 + <number of characters in the object name>. Which is considerably smaller.
Yet this does not allow you to delete the data from the archive, which is kind of a pain in the ass (programmatically talking), I will eventually add this functionality, yet if anybody is interested in doing this (or even improving what I've already done) is free to do so, since I've included the source code.
Here's an example of how to create a new stg storage:
Code:
Log.Initialize("log.txt", LogLevel.All, true); // If you wanna log what you're doing..
STGDatabase db = new STGDatabase(@"D:\test.stg");
db.Headers.AddNewHeader(db.Data.WriteData(Encoding.UTF8.GetBytes("This is a test"), "Test")); // Adds a new header. When you read it it will not display the last character.... idk why?
db.Headers.AddNewHeader(db.Data.WriteData(Encoding.UTF8.GetBytes("This is a test 2"), "Test2")); // Same ^.
db.Commit(); // Updates the archive.
Log.WriteAway(); // Flushes the log data into the text file.
Using the same technique but to read the data:
Code:
Header h = db.Headers.FindHeader("Test2")[0]; // Finds every header corresponding to the given name. Not case sensitive.
string hhh = Encoding.UTF8.GetString(db.Data.ReadData(h)); // The string we've wrote in the storage above.
This time this DOES NOT include any outside links. (Even EGNoSQL didn't since I've hex edited the exe, anyways..)
Virus Scans: #1 ~ #2
AGAIN, SOURCE CODE IS INCLUDED SO YOU ARE ABLE TO WRITE WHATEVER YOU WANT AND MODIFY THE GIVEN CLASSES. CREDITS WOULD BE APPRECIATED !
Thanks to NTAuthority, I've found in the aIWNet server source the log class and I've been using it since then.
