├── docs
├── contributing.md
├── indexing
│ ├── enumerate.md
│ └── indexed_list.md
├── template
│ ├── CNAME
│ ├── images
│ │ └── logo
│ │ │ ├── colors.txt
│ │ │ ├── icon_blue_32x32.png
│ │ │ ├── logo_illustrator.ai
│ │ │ ├── icon_blue_512x512.png
│ │ │ ├── icon_white.svg
│ │ │ └── icon_blue.svg
│ ├── screenshot.png
│ ├── fonts
│ │ ├── FontAwesome.otf
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.ttf
│ │ └── fontawesome-webfont.woff
│ ├── couscous.yml
│ ├── LICENSE
│ ├── README.md
│ └── css
│ │ ├── highlight.tomorrow-night.css
│ │ └── main.css
├── encryption.md
├── upgrade05.md
├── persisting.md
├── upgrade04.md
├── transactions.md
├── longterm.md
├── README.md
├── roadmap.md
└── reading.md
├── BuildArtifacts
└── wpa81
│ └── MarcelloDB.W81.dll
├── UniversalTest
├── UniversalTest.Windows
│ ├── Assets
│ │ ├── Logo.scale-100.png
│ │ ├── SmallLogo.scale-100.png
│ │ ├── StoreLogo.scale-100.png
│ │ └── SplashScreen.scale-100.png
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── Package.appxmanifest
├── UniversalTest.WindowsPhone
│ ├── Assets
│ │ ├── Logo.scale-240.png
│ │ ├── SmallLogo.scale-240.png
│ │ ├── StoreLogo.scale-240.png
│ │ ├── WideLogo.scale-240.png
│ │ ├── SplashScreen.scale-240.png
│ │ └── Square71x71Logo.scale-240.png
│ ├── MainPage.xaml
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── MainPage.xaml.cs
│ └── Package.appxmanifest
└── UniversalTest.Shared
│ ├── App.xaml
│ ├── Article.cs
│ ├── UniversalTest.Shared.projitems
│ └── UniversalTest.Shared.shproj
├── MarcelloDB
├── Serialization
│ ├── NodeSerializer.cs
│ ├── IObjectSerializer.cs
│ ├── ValueSerializers
│ │ ├── StringSerializer.cs
│ │ ├── ByteSerializer.cs
│ │ ├── BooleanSerializers.cs
│ │ ├── DateTimeSerializer.cs
│ │ ├── ValueWithAddressIndexKeySerializer.cs
│ │ ├── IntSerializer.cs
│ │ └── FloatSerializer.cs
│ ├── JsonSerializer.cs
│ ├── BsonSerializer.cs
│ ├── BtreeNodeSerializer.cs
│ ├── IndexMetaRecordSerializer.cs
│ ├── CollectionFileRootSerializer.cs
│ ├── SerializerResolver.cs
│ ├── BufferReader.cs
│ ├── BufferWriter.cs
│ └── TransactionJournalSerializer.cs
├── packages.config
├── Transactions
│ ├── ITransactor.cs
│ ├── JournalEntry.cs
│ └── Transaction.cs
├── Storage
│ ├── IStorageStreamProvider.cs
│ ├── IStorageStream.cs
│ ├── StreamActors
│ │ ├── Writer.cs
│ │ ├── Reader.cs
│ │ ├── JournalledWriter.cs
│ │ ├── StreamActor.cs
│ │ └── JournalledReader.cs
│ └── StorageEngine.cs
├── Platform
│ └── IPlatform.cs
├── AllocationStrategies
│ ├── IAllocationStrategy.cs
│ ├── DoubleSizeAllocationStrategy.cs
│ ├── ExactSizeAllocationStrategy.cs
│ ├── AllocationStrategyResolver.cs
│ └── PredictiveBTreeNodeAllocationStrategy.cs
├── Exceptions
│ ├── IDMissingException.cs
│ └── ObjectNotFoundException.cs
├── Records
│ ├── NamedRecordsIndex.cs
│ ├── CollectionMetaDataT.cs
│ ├── EmptyRecordIndexKey.cs
│ ├── ValueWithAddressIndexKey.cs
│ ├── Record.cs
│ ├── RecordHeader.cs
│ ├── CollectionFileRoot.cs
│ └── IndexMetaRecord.cs
├── Index
│ ├── BTree
│ │ └── IBtreeDataProvider.cs
│ ├── AddressList.cs
│ ├── EntryList.cs
│ ├── EmptyRecordIndex.cs
│ ├── Entry.cs
│ ├── Node.cs
│ ├── CompoundValue.cs
│ └── ObjectComparer.cs
├── Collections
│ ├── Scopes
│ │ ├── Descending.cs
│ │ ├── All.cs
│ │ ├── GreaterThan.cs
│ │ ├── SmallerThan.cs
│ │ └── BaseScope.cs
│ ├── ObjectByIDEnumerator.cs
│ ├── IndexedValue.cs
│ ├── IndexedValueTypes
│ │ ├── UniqueIndexedValue.cs
│ │ ├── IndexedIDValue.cs
│ │ └── IndexedList.cs
│ ├── KeysEnumeratorT.cs
│ └── IndexEntryEnumerator.cs
├── Properties
│ └── AssemblyInfo.cs
└── Helpers
│ └── DataHelper.cs
├── MarcelloDB.Test
├── packages.config
├── AllocationStrategies
│ ├── ExactSizeAllocationStrategy.cs
│ ├── DoubleSizeAllocationStrategyTest.cs
│ ├── AllocationStrategyResolverTest.cs
│ └── PredictiveBTreeNodeAllocationStrategyTest.cs
├── TestStream
│ ├── TestPlatform.cs
│ └── InMemoryStream.cs
├── Classes
│ ├── Location.cs
│ ├── ArticleIndexDefinition.cs
│ └── Article.cs
├── Records
│ ├── RecordHeaderTest.cs
│ ├── EmptyRecordIndexKeyTest.cs
│ └── ValueWithAddressIndexKeyTest.cs
├── Regression
│ ├── Issue32_OutOfMemoryOnSecondPersist.cs
│ ├── Issue31_NullReferenceWhenPersistingWithNonID.cs
│ ├── Issue74_ItemWithSameKeyAllreadyAdded.cs
│ ├── Issue49_DateTime_Indexed_Value.cs
│ ├── Issue69_OutOfMemoryOnEmptyCollection.cs
│ └── Issue67_RootNotSavedAfterRecycle.cs
├── Index
│ ├── Mocks
│ │ ├── MockBTree.cs
│ │ └── MockBTreeDataProvider.cs
│ ├── NodeTest.cs
│ ├── ObjectComparerTest.cs
│ ├── IndexTest.cs
│ └── IndexDefinitionTest.cs
└── Serialization
│ ├── CollectionFileRootSerializerTest.cs
│ ├── BsonSerializerTest.cs
│ ├── TransactionJournalSerializerTest.cs
│ ├── IndexMetaRecordSerializerTest.cs
│ └── EmptyRecordIndexNodeSerializerTest.cs
├── MarcelloDB.BenchmarkTool
├── DataClasses
│ ├── Base.cs
│ ├── Address.cs
│ └── Person.cs
├── Extensions
│ └── ListExtensions.cs
├── Benchmarks
│ ├── RandomIDsBulkInsert.cs
│ ├── SequentialIDsBulkInsert.cs
│ ├── SequentialDestroy.cs
│ ├── RandomRead.cs
│ ├── RandomDestroy.cs
│ ├── EnumerateAll.cs
│ └── Base.cs
└── Properties
│ └── AssemblyInfo.cs
├── .travis.yml
├── MarcelloDB.netfx
├── Platform.cs
├── Properties
│ └── AssemblyInfo.cs
└── MarcelloDB.netfx.csproj
├── MarcelloDB.uwp
├── Platform.cs
└── Properties
│ ├── AssemblyInfo.cs
│ └── MarcelloDB.uwp.rd.xml
├── MarcelloDB.W81
├── Platform.cs
├── Properties
│ └── AssemblyInfo.cs
└── MarcelloDB.W81.csproj
├── Package
└── MarcelloDB.nuspec
├── LICENSE.txt
├── README.md
└── couscous.yml
/docs/contributing.md:
--------------------------------------------------------------------------------
1 | contributing.md
--------------------------------------------------------------------------------
/docs/indexing/enumerate.md:
--------------------------------------------------------------------------------
1 | enumerate.md
--------------------------------------------------------------------------------
/docs/template/CNAME:
--------------------------------------------------------------------------------
1 | www.marcellodb.org
--------------------------------------------------------------------------------
/docs/template/images/logo/colors.txt:
--------------------------------------------------------------------------------
1 | blue #2062c5
--------------------------------------------------------------------------------
/docs/template/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/screenshot.png
--------------------------------------------------------------------------------
/docs/template/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/BuildArtifacts/wpa81/MarcelloDB.W81.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/BuildArtifacts/wpa81/MarcelloDB.W81.dll
--------------------------------------------------------------------------------
/docs/template/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/docs/template/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/docs/template/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/docs/template/images/logo/icon_blue_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/images/logo/icon_blue_32x32.png
--------------------------------------------------------------------------------
/docs/template/images/logo/logo_illustrator.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/images/logo/logo_illustrator.ai
--------------------------------------------------------------------------------
/docs/template/images/logo/icon_blue_512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/docs/template/images/logo/icon_blue_512x512.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/Assets/Logo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.Windows/Assets/Logo.scale-100.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/Assets/SmallLogo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.Windows/Assets/SmallLogo.scale-100.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/Assets/StoreLogo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.Windows/Assets/StoreLogo.scale-100.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/Assets/Logo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.WindowsPhone/Assets/Logo.scale-240.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/Assets/SplashScreen.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.Windows/Assets/SplashScreen.scale-100.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/Assets/SmallLogo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.WindowsPhone/Assets/SmallLogo.scale-240.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/Assets/StoreLogo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.WindowsPhone/Assets/StoreLogo.scale-240.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/Assets/WideLogo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.WindowsPhone/Assets/WideLogo.scale-240.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/Assets/SplashScreen.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.WindowsPhone/Assets/SplashScreen.scale-240.png
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/Assets/Square71x71Logo.scale-240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markmeeus/MarcelloDB/HEAD/UniversalTest/UniversalTest.WindowsPhone/Assets/Square71x71Logo.scale-240.png
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/NodeSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB
4 | {
5 | public class NodeSerializer
6 | {
7 | public NodeSerializer()
8 | {
9 | }
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/MarcelloDB/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MarcelloDB.Test/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MarcelloDB/Transactions/ITransactor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Transactions
4 | {
5 | internal interface ITransactor
6 | {
7 | void SaveState();
8 | void RollbackState();
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/docs/encryption.md:
--------------------------------------------------------------------------------
1 | ##MarcelloDB.Encryption
2 | MarcelloDB's data files are unencrypted by default.
3 | An encryption layer is being developed and is included in the Pro/Support package.
4 |
5 | Please contact mark.meeus@gmail.com if interested.
6 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/DataClasses/Base.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.BenchmarkTool.DataClasses
4 | {
5 | public class Base
6 | {
7 | public Base()
8 | {
9 | }
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/IStorageStreamProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage
4 | {
5 | public interface IStorageStreamProvider: IDisposable
6 | {
7 | IStorageStream GetStream(string streamName);
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/MarcelloDB/Platform/IPlatform.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Storage;
3 |
4 | namespace MarcelloDB.Platform
5 | {
6 | public interface IPlatform
7 | {
8 | IStorageStreamProvider CreateStorageStreamProvider(string rootPath);
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/IObjectSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Serialization
4 | {
5 | internal interface IObjectSerializer
6 | {
7 | byte[] Serialize(T obj);
8 |
9 | T Deserialize(byte[] bytes);
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/IStorageStream.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage
4 | {
5 | public interface IStorageStream
6 | {
7 | byte[] Read(long address, int length);
8 |
9 | void Write(long address, byte[] bytes);
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/MarcelloDB/AllocationStrategies/IAllocationStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 |
4 | namespace MarcelloDB.AllocationStrategies
5 | {
6 | internal interface IAllocationStrategy
7 | {
8 | int CalculateSize(int dataSize);
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/MarcelloDB/Exceptions/IDMissingException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Exceptions
4 | {
5 | public class IDMissingException : Exception
6 | {
7 | public IDMissingException(string Message) : base(Message)
8 | {
9 | }
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Shared/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MarcelloDB/Exceptions/ObjectNotFoundException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Exceptions
4 | {
5 | public class ObjectNotFoundException : Exception
6 | {
7 | public ObjectNotFoundException(string message) : base(message)
8 | {
9 | }
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | solution: MarcelloDB.sln
3 | script:
4 | - nuget install NUnit.Runners -Version 2.6.4 -OutputDirectory testrunner
5 | - xbuild /p:Configuration=Release MarcelloDB.sln
6 | - mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe ./MarcelloDB.Test/bin/Release/MarcelloDB.Test.dll
7 |
8 |
--------------------------------------------------------------------------------
/MarcelloDB/AllocationStrategies/DoubleSizeAllocationStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 |
4 | namespace MarcelloDB.AllocationStrategies
5 | {
6 | internal class DoubleSizeAllocationStrategy : IAllocationStrategy
7 | {
8 | public int CalculateSize(int dataSize)
9 | {
10 | return dataSize * 2;
11 | }
12 | }
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/MarcelloDB/AllocationStrategies/ExactSizeAllocationStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.AllocationStrategies
4 | {
5 | internal class ExactSizeAllocationStrategy : IAllocationStrategy
6 | {
7 | #region IAllocationStrategy implementation
8 |
9 | public int CalculateSize(int dataSize)
10 | {
11 | return dataSize;
12 | }
13 |
14 | #endregion
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/MarcelloDB.netfx/Platform.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Platform;
3 | using System.Collections.Generic;
4 | using MarcelloDB.Storage;
5 | using MarcelloDB.netfx.Storage;
6 |
7 | namespace MarcelloDB.netfx
8 | {
9 | public class Platform : IPlatform
10 | {
11 | public IStorageStreamProvider CreateStorageStreamProvider(string rootPath)
12 | {
13 | return new FileStorageStreamProvider(rootPath);
14 | }
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/MarcelloDB/Records/NamedRecordsIndex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using MarcelloDB.Serialization;
4 |
5 | namespace MarcelloDB.Records
6 | {
7 | internal class NamedRecordsIndex
8 | {
9 | public Dictionary NamedRecordIndexes { get; set;}
10 |
11 | internal NamedRecordsIndex()
12 | {
13 | this.NamedRecordIndexes = new Dictionary();
14 | }
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/StreamActors/Writer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage.StreamActors
4 | {
5 | internal class Writer : StreamActor
6 | {
7 | internal Writer(Session session, string streamName)
8 | : base(session, streamName)
9 | {
10 | }
11 |
12 | internal virtual void Write(long address, byte[] bytes)
13 | {
14 | GetStream().Write (address, bytes);
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/StreamActors/Reader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage.StreamActors
4 | {
5 | internal class Reader : StreamActor
6 | {
7 | internal Reader(Session session, string collectionName)
8 | :base(session, collectionName)
9 | {
10 | }
11 |
12 | internal virtual byte[] Read(long address, int length)
13 | {
14 | return this.GetStream().Read(address, length);
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Shared/Article.cs:
--------------------------------------------------------------------------------
1 | using MarcelloDB.Collections;
2 | using MarcelloDB.Index;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 |
7 | namespace UniversalTest
8 | {
9 | public class ArticleIndex : IndexDefinition
10 | {
11 | public IndexedValue Name { get; set; }
12 | }
13 |
14 | public class Article
15 | {
16 | public int ID { get; set; }
17 | public string Name { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/StreamActors/JournalledWriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage.StreamActors
4 | {
5 | internal class JournalledWriter : Writer
6 | {
7 | internal JournalledWriter(Session session, string streamName)
8 | : base(session, streamName)
9 | {
10 | }
11 |
12 | internal override void Write (long address, byte[] bytes)
13 | {
14 | Session.Journal.Write(this.StreamName, address, bytes);
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/MarcelloDB/Index/BTree/IBtreeDataProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using MarcelloDB.AllocationStrategies;
4 |
5 | namespace MarcelloDB.Index.BTree
6 | {
7 | internal interface IBTreeDataProvider
8 | {
9 | Node GetRootNode(int degree);
10 |
11 | void SetRootNode(Node node);
12 |
13 | Node GetNode(Int64 address);
14 |
15 | Node CreateNode(int degree, bool allowRecordReuse = true);
16 |
17 | void Flush();
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/ValueSerializers/StringSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Serialization.ValueSerializers
4 | {
5 | class StringSerializer : ValueSerializer
6 | {
7 | internal override String ReadValue(BinaryFormatter formatter)
8 | {
9 | return formatter.ReadString();
10 | }
11 | internal override void WriteValue(BinaryFormatter formatter, String value)
12 | {
13 | formatter.WriteString(value);
14 | }
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/MarcelloDB.Test/AllocationStrategies/ExactSizeAllocationStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 | using MarcelloDB.AllocationStrategies;
4 |
5 | namespace MarcelloDB.Test.AllocationStrategies
6 | {
7 | [TestFixture]
8 | public class ExactSizeAllocationStrategyTest
9 | {
10 | [Test]
11 | public void Uses_Exact_Size()
12 | {
13 | var allocationStrategy = new ExactSizeAllocationStrategy();
14 | Assert.AreEqual(100, allocationStrategy.CalculateSize(100));
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/MarcelloDB.Test/AllocationStrategies/DoubleSizeAllocationStrategyTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 | using MarcelloDB.AllocationStrategies;
4 |
5 | namespace MarcelloDB.Test.AllocationStrategies
6 | {
7 | [TestFixture]
8 | public class DoubleSizeAllocationStrategyTest
9 | {
10 | [Test]
11 | public void Uses_Double_Size()
12 | {
13 | var allocationStrategy = new DoubleSizeAllocationStrategy();
14 | Assert.AreEqual(200, allocationStrategy.CalculateSize(100));
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.WindowsPhone/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/MarcelloDB/Index/AddressList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using MarcelloDB.Helpers;
5 |
6 | namespace MarcelloDB.Index
7 | {
8 | internal class AddressList : ChangeTrackingList
9 | {
10 | internal List Addresses
11 | {
12 | get
13 | {
14 | return Items;
15 | }
16 | }
17 |
18 | internal void SetAddresses(List addresses)
19 | {
20 | base.Items = addresses;
21 | }
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/MarcelloDB/Index/EntryList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Helpers;
3 | using System.Collections.Generic;
4 |
5 | namespace MarcelloDB.Index
6 | {
7 |
8 | internal class EntryList : ChangeTrackingList>
9 | {
10 | public List> Entries
11 | {
12 | get
13 | {
14 | return base.Items;
15 | }
16 | }
17 |
18 | internal void SetEntries(List> entries)
19 | {
20 | base.Items = entries;
21 | }
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/StreamActors/StreamActor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage.StreamActors
4 | {
5 | internal class StreamActor : SessionBoundObject
6 | {
7 | protected string StreamName {get;set;}
8 |
9 | internal StreamActor(Session session, string streamName) : base(session)
10 | {
11 | this.StreamName = streamName;
12 | }
13 |
14 | protected IStorageStream GetStream()
15 | {
16 | return this.Session.StreamProvider.GetStream(this.StreamName);
17 | }
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/MarcelloDB/Records/CollectionMetaDataT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Marcello
4 | {
5 | internal class CollectionMetaData
6 | {
7 | Marcello Session { get; set; }
8 |
9 | internal CollectionMetaData (Marcello session)
10 | {
11 | Session = session;
12 | }
13 |
14 | internal CollectionMetaDataRecord GetRecord()
15 | {
16 | return new CollectionMetaDataRecord();
17 | }
18 |
19 | internal void Update(CollectionMetaDataRecord record)
20 | {
21 |
22 | }
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/docs/upgrade05.md:
--------------------------------------------------------------------------------
1 | #Upgrading to 0.5
2 | ~~Code compatible with 0.4 is expected to compile and run without modifications with 0.5.~~
3 |
4 | ##Breaking changes
5 | There is a breaking change in code between 0.4 and 0.5.
6 |
7 | `IndexDefinition.Find` has been renamend to `IndexDefinition.Equals`.
8 |
9 | ##Data compatibility
10 | Data from 0.4 remains readable, but existing indexes are no longer readable so they will have to be rebuilt.
11 |
12 | Copying all objects to a new collection will do the trick. It is even better to copy the data to a new collection-file and delete the previous one to save space.
--------------------------------------------------------------------------------
/MarcelloDB/Storage/StreamActors/JournalledReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Storage.StreamActors
4 | {
5 | internal class JournalledReader : Reader
6 | {
7 | internal JournalledReader(Session session, string collectionName)
8 | : base(session, collectionName)
9 | {
10 | }
11 |
12 | internal override byte[] Read (long address, int length)
13 | {
14 | var readBytes = base.Read (address, length);
15 | Session.Journal.ApplyToData(this.StreamName, address, readBytes);
16 | return readBytes;
17 | }
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/docs/persisting.md:
--------------------------------------------------------------------------------
1 | ##Persisting objects
2 |
3 | Once you have a collection, you can save your objects using the Persist method.
4 |
5 | ```cs
6 | var book = new Book(){ bookId = "123", Title = "The Girl With The Dragon Tattoo" };
7 | bookCollection.Persist(book);
8 | ```
9 |
10 | Persist inserts if there is no object associated with the ID. Otherwise it will perform an update.
11 |
12 | If you are using an index definition, the indexes will be updated.
13 |
14 | ##Destroying objects
15 |
16 | The Destroy method will remove the object with the given ID from the collection.
17 |
18 | ```cs
19 | bookCollection.Destroy("123");
20 | ```
21 |
--------------------------------------------------------------------------------
/MarcelloDB/Index/EmptyRecordIndex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 | using MarcelloDB.AllocationStrategies;
4 | using MarcelloDB.Index.BTree;
5 | using MarcelloDB.Serialization;
6 |
7 | namespace MarcelloDB.Index
8 | {
9 | internal class EmptyRecordIndex : RecordIndex
10 | {
11 |
12 | internal EmptyRecordIndex(
13 | Session session,
14 | IRecordManager recordManager,
15 | string indexName,
16 | IObjectSerializer> serializer
17 | ):base(session, recordManager, indexName, serializer)
18 | {}
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Extensions/ListExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace MarcelloDB.BenchmarkTool.Extensions
5 | {
6 | public static class ListExtensions
7 | {
8 | public static void Shuffle(this IList list)
9 | {
10 | Random rng = new Random();
11 | int n = list.Count;
12 | while (n > 1) {
13 | n--;
14 | int k = rng.Next(n + 1);
15 | T value = list[k];
16 | list[k] = list[n];
17 | list[n] = value;
18 | }
19 | }
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/MarcelloDB.Test/TestStream/TestPlatform.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Platform;
3 | using System.Collections.Generic;
4 |
5 | namespace MarcelloDB.Test
6 | {
7 | public class TestPlatform : IPlatform
8 | {
9 | Dictionary _streams = new Dictionary();
10 | public MarcelloDB.Storage.IStorageStreamProvider CreateStorageStreamProvider(string rootPath)
11 | {
12 | if (!_streams.ContainsKey(rootPath))
13 | {
14 | _streams.Add(rootPath, new InMemoryStreamProvider());
15 | }
16 | return _streams[rootPath];
17 | }
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/MarcelloDB/Index/Entry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Index
4 | {
5 | internal class Entry : IEquatable>
6 | {
7 | TK _key;
8 | public TK Key
9 | {
10 | get { return _key; }
11 | set
12 | {
13 | if (value == null)
14 | {
15 | throw new Exception("PANIC: Entry keys cannot be null");
16 | }
17 | _key = value;
18 | }
19 | }
20 |
21 | public Int64 Pointer { get; set; }
22 |
23 | public bool Equals(Entry other)
24 | {
25 | return this.Key.Equals(other.Key) && this.Pointer.Equals(other.Pointer);
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/docs/template/couscous.yml:
--------------------------------------------------------------------------------
1 | template:
2 | directory: .
3 |
4 | github:
5 | user: CouscousPHP
6 | repo: Template-Dark
7 |
8 | title: Couscous template
9 | subTitle: The dark template for Couscous.
10 |
11 | # The left menu bar
12 | menu:
13 | sections:
14 | main:
15 | name: Main documentation
16 | items:
17 | home:
18 | text: Home page
19 | # You can use relative urls
20 | relativeUrl: doc/faq.html
21 | foo:
22 | text: Another link
23 | # Or absolute urls
24 | absoluteUrl: https://example.com
25 | other:
26 | name: Other topics
27 | items:
28 |
--------------------------------------------------------------------------------
/MarcelloDB/Collections/Scopes/Descending.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 | using MarcelloDB.Collections;
4 |
5 | namespace MarcelloDB.Collections.Scopes
6 | {
7 | public class Descending : BaseScope
8 | {
9 | BaseScope OriginalScope { get; set; }
10 |
11 | internal Descending(BaseScope originalScope)
12 | {
13 | this.OriginalScope = originalScope;
14 | }
15 |
16 | internal override CollectionEnumerator> BuildEnumerator(bool descending)
17 | {
18 | return OriginalScope.BuildEnumerator(true); //force descending enumerator
19 | }
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Benchmarks/RandomIDsBulkInsert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.BenchmarkTool.DataClasses;
3 |
4 | namespace MarcelloDB.BenchmarkTool.Benchmarks
5 | {
6 | public class RandomIDsBulkInsert : Base
7 | {
8 | int _objectCount;
9 |
10 | public RandomIDsBulkInsert(int objectCount)
11 | {
12 | _objectCount = objectCount;
13 | }
14 |
15 | protected override void OnRun()
16 | {
17 | var r = new Random();
18 | for (int i = 1; i < _objectCount; i++)
19 | {
20 | var person = Person.BuildRandom();
21 | person.ID = r.Next();
22 | this.Collection.Persist(person);
23 | }
24 | }
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/docs/indexing/indexed_list.md:
--------------------------------------------------------------------------------
1 | #Indexing a list of fields with ```IndexedList```
2 | MarcelloDB allows multiple index entries per object in the same index.
3 |
4 | Let's say for instance you have a ```Book``` class which has a property ```List Tags```
5 |
6 | Using an ```IndexedList``` allows you to index every tag in the Tags property.
7 |
8 | ##Custom Value
9 | If indexing a property is not enough, custom indexes can be defined.
10 | In this case you also define a property like above, except you return an instance of IndexedValue, created with a function that returns the value to be indexed.
11 |
12 | ```cs
13 | class BookIndexDefinition : IndexDefinition
14 | {
15 | public IndexedList Tags
16 | {
17 | get {
18 | return IndexedList((o) => o.Tags);
19 | }
20 | }
21 | }
22 | ```
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Benchmarks/SequentialIDsBulkInsert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using MarcelloDB.BenchmarkTool.DataClasses;
4 |
5 | namespace MarcelloDB.BenchmarkTool.Benchmarks
6 | {
7 | public class SequentialIDsBulkInsert : Base
8 | {
9 |
10 | int _objectCount;
11 |
12 | public SequentialIDsBulkInsert(int objectCount)
13 | {
14 | _objectCount = objectCount;
15 | }
16 |
17 | protected override void OnRun()
18 | {
19 | for (int i = 1; i < _objectCount; i++)
20 | {
21 | var person = Person.BuildRandom();
22 | person.ID = i;
23 | this.Collection.Persist(person);
24 | }
25 | }
26 | }
27 | }
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/MarcelloDB.uwp/Platform.cs:
--------------------------------------------------------------------------------
1 | using MarcelloDB.Platform;
2 | using MarcelloDB.Storage;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Windows.Storage;
9 |
10 | namespace MarcelloDB.uwp
11 | {
12 | public class Platform : IPlatform
13 | {
14 | public IStorageStreamProvider CreateStorageStreamProvider(string rootPath)
15 | {
16 | return new FileStorageStreamProvider(GetFolderForPath(rootPath));
17 | }
18 |
19 | StorageFolder GetFolderForPath(string path)
20 | {
21 | var getFolderTask = StorageFolder.GetFolderFromPathAsync(path).AsTask();
22 | getFolderTask.ConfigureAwait(false);
23 | getFolderTask.Wait();
24 | return getFolderTask.Result;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/JsonSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace MarcelloDB.Serialization
5 | {
6 | internal class JsonSerializer : IObjectSerializer
7 | {
8 | public JsonSerializer ()
9 | {
10 | }
11 |
12 | #region IObjectSerializer implementation
13 |
14 | public byte[] Serialize (T obj)
15 | {
16 | var json = JsonConvert.SerializeObject(obj);
17 | return System.Text.Encoding.UTF8.GetBytes(json.ToCharArray());
18 | }
19 |
20 | public T Deserialize (byte[] bytes)
21 | {
22 | string json = "";
23 | json = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
24 | return JsonConvert.DeserializeObject(json);
25 | }
26 |
27 | #endregion
28 | }
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/MarcelloDB/Collections/Scopes/All.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using MarcelloDB.Index.BTree;
6 |
7 | namespace MarcelloDB.Collections.Scopes
8 | {
9 | public class All : BaseScope
10 | {
11 | BaseIndexedValue IndexedValue { get; set; }
12 |
13 | internal All(BaseIndexedValue indexedValue)
14 | {
15 | this.IndexedValue = indexedValue;
16 |
17 | }
18 |
19 | override internal CollectionEnumerator> BuildEnumerator(bool descending)
20 | {
21 | return this.IndexedValue
22 | .BuildEnumerator(new BTreeWalkerRange>[]{null}, descending);
23 | }
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/MarcelloDB.W81/Platform.cs:
--------------------------------------------------------------------------------
1 | using MarcelloDB.Collections;
2 | using MarcelloDB.Platform;
3 | using MarcelloDB.Storage;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using Windows.Storage;
10 |
11 | namespace MarcelloDB.W81
12 | {
13 | public class Platform : IPlatform
14 | {
15 | public IStorageStreamProvider CreateStorageStreamProvider(string rootPath)
16 | {
17 | return new FileStorageStreamProvider(GetFolderForPath(rootPath));
18 | }
19 |
20 | StorageFolder GetFolderForPath(string path)
21 | {
22 | var getFolderTask = StorageFolder.GetFolderFromPathAsync(path).AsTask();
23 | getFolderTask.ConfigureAwait(false);
24 | getFolderTask.Wait();
25 | return getFolderTask.Result;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/DataClasses/Address.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.BenchmarkTool.DataClasses
4 | {
5 | public class Address
6 | {
7 | static Random _random = new Random();
8 |
9 | public string Street { get; set; }
10 | public string Number { get; set; }
11 | public int ZipCode { get; set; }
12 | public string City { get; set; }
13 | public string Country { get; set; }
14 |
15 | public static Address BuildRandom()
16 | {
17 | return new Address{
18 | Street = "Street " + _random.Next().ToString(),
19 | Number = "Number " + _random.Next().ToString(),
20 | ZipCode = _random.Next() % 10000,
21 | City = "City " + _random.Next().ToString(),
22 | Country = "Country " + _random.Next().ToString()
23 | };
24 | }
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/ValueSerializers/ByteSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Serialization.ValueSerializers
4 | {
5 | class ByteSerializer : ValueSerializer
6 | {
7 | internal override Byte ReadValue(BinaryFormatter formatter)
8 | {
9 | return formatter.ReadByte();
10 | }
11 | internal override void WriteValue(BinaryFormatter formatter, Byte value)
12 | {
13 | formatter.WriteByte(value);
14 | }
15 | }
16 |
17 | class NullableByteSerializer : ValueSerializer
18 | {
19 | internal override Byte? ReadValue(BinaryFormatter formatter)
20 | {
21 | return formatter.ReadNullableByte();
22 | }
23 | internal override void WriteValue(BinaryFormatter formatter, Byte? value)
24 | {
25 | formatter.WriteNullableByte(value);
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/ValueSerializers/BooleanSerializers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Serialization.ValueSerializers
4 | {
5 | class BooleanSerializer : ValueSerializer
6 | {
7 | internal override Boolean ReadValue(BinaryFormatter formatter)
8 | {
9 | return formatter.ReadBool();
10 | }
11 | internal override void WriteValue(BinaryFormatter formatter, Boolean value)
12 | {
13 | formatter.WriteBool(value);
14 | }
15 | }
16 |
17 | class NullableBooleanSerializer : ValueSerializer
18 | {
19 | internal override Boolean? ReadValue(BinaryFormatter formatter)
20 | {
21 | return formatter.ReadNullableBool();
22 | }
23 | internal override void WriteValue(BinaryFormatter formatter, Boolean? value)
24 | {
25 | formatter.WriteNullableBool(value);
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Shared/UniversalTest.Shared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 268d5135-6f43-4de0-8fda-0053c90d2c93
7 |
8 |
9 | UniversalTest
10 |
11 |
12 |
13 | Designer
14 |
15 |
16 | App.xaml
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/MarcelloDB/Transactions/JournalEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace MarcelloDB.Transactions
5 | {
6 | internal static class TimeStamp
7 | {
8 | static long _lastStamp;
9 |
10 | internal static long Next(){
11 | return ++_lastStamp;
12 | }
13 | }
14 |
15 | internal class TransactionJournal
16 | {
17 | public List Entries { get; set; }
18 |
19 | public TransactionJournal()
20 | {
21 | this.Entries = new List();
22 | }
23 | }
24 |
25 | internal class JournalEntry
26 | {
27 | public long Stamp { get; set; }
28 |
29 | public string StreamName { get; set; }
30 |
31 | public Int64 Address { get; set; }
32 |
33 | public byte[] Data { get; set; }
34 |
35 | public JournalEntry(){
36 | this.Stamp = TimeStamp.Next();
37 | }
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.Foundation.Collections;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Controls.Primitives;
11 | using Windows.UI.Xaml.Data;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 | using Windows.UI.Xaml.Navigation;
15 |
16 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
17 |
18 | namespace UniversalTest
19 | {
20 | ///
21 | /// An empty page that can be used on its own or navigated to within a Frame.
22 | ///
23 | public sealed partial class MainPage : Page
24 | {
25 | public MainPage()
26 | {
27 | this.InitializeComponent();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/ValueSerializers/DateTimeSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Serialization.ValueSerializers
4 | {
5 | class DateTimeSerializer : ValueSerializer
6 | {
7 | internal override DateTime ReadValue(BinaryFormatter formatter)
8 | {
9 | return formatter.ReadDateTime();
10 | }
11 | internal override void WriteValue(BinaryFormatter formatter, DateTime value)
12 | {
13 | formatter.WriteDateTime(value);
14 | }
15 | }
16 |
17 | class NullableDateTimeSerializer : ValueSerializer
18 | {
19 | internal override DateTime? ReadValue(BinaryFormatter formatter)
20 | {
21 | return formatter.ReadNullableDateTime();
22 | }
23 | internal override void WriteValue(BinaryFormatter formatter, DateTime? value)
24 | {
25 | formatter.WriteNullableDateTime(value);
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/MarcelloDB/Records/EmptyRecordIndexKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Records
4 | {
5 | internal class EmptyRecordIndexKey : IComparable, IEquatable
6 | {
7 | public Int64 A { get; set; } //Address, abbreviated to save storage
8 | public Int32 S { get; set; } //Size
9 |
10 | #region IComparable implementation
11 |
12 | public int CompareTo(object obj)
13 | {
14 | var other = (EmptyRecordIndexKey)obj;
15 | var sizeCompared = S.CompareTo(other.S);
16 | if(sizeCompared == 0)
17 | {
18 | return A.CompareTo(other.A);
19 | }
20 | return sizeCompared;
21 | }
22 |
23 | #endregion
24 |
25 | #region IEquatable implementation
26 |
27 | public bool Equals(EmptyRecordIndexKey other)
28 | {
29 | return this.A.Equals(other.A) && this.S.Equals(other.S);
30 | }
31 |
32 | #endregion
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/docs/upgrade04.md:
--------------------------------------------------------------------------------
1 | #Upgrading to 0.4
2 | Version 0.4 contains a refactor which causes data files created with older version to be unreadable.
3 |
4 | There is also a code-level incompatibility.
5 |
6 | From 0.4 on, it is required to specify the type of your ID property.
7 | Also an Object-To-ID mapping function should be provided.
8 |
9 | Before 0.4:
10 | ```cs
11 | session['products'].Collection("My-Products-Collection");
12 | ````
13 |
14 | From 0.4:
15 | ```cs
16 | session['products'].Collection("My-Products-Collection", p => p.ID);
17 | ````
18 |
19 | When using an IndexDefinition:
20 | Before 0.4:
21 | ```cs
22 | session['products'].Collection("My-Products-Collection");
23 | ````
24 |
25 | From 0.4:
26 | ```cs
27 | session['products'].Collection("My-Products-Collection", p => p.ID);
28 | ````
29 |
30 | You are now free to name your ID property as you wish.
31 |
32 | The ID attribute has also been removed as there was no use for it anymore.
33 |
34 |
--------------------------------------------------------------------------------
/MarcelloDB.Test/Classes/Location.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MarcelloDB.Test
4 | {
5 | public class Location
6 | {
7 | public string ID { get; set; }
8 | public string Name { get; set; }
9 | public string Address { get; set; }
10 |
11 | public static Location Harrods
12 | {
13 | get
14 | {
15 | return new Location
16 | {
17 | ID = "1a1a",
18 | Name = "Harrods",
19 | Address = "87-135 Brompton Road, Knightsbridge SW1X 7XL"
20 | };
21 | }
22 | }
23 |
24 | public static Location MandS
25 | {
26 | get
27 | {
28 | return new Location
29 | {
30 | ID = "2b2b",
31 | Name = "Marks & Spencer",
32 | Address = "458 Oxford Street, W1C 1AP"
33 | };
34 | }
35 | }
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/Package/MarcelloDB.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | MarcelloDB
5 | MarcelloDB, Mobile Object Database.
6 | 1.0.9
7 | Mark Meeus
8 | Mark Meeus
9 | http://marcellodb.org
10 | false
11 | NoSql for Xamarin and .net. Persists plain C# objects, including child objects, lists and collections. Supported on Xamarin (Android and iOS) and Windows (8.1-10 and Phone 8.1-10).
12 | 1.0.9. Fixes a race condition with collection creation.
13 | Copyright 2015-2020
14 | Database NoSql Mobile Xamarin Windows Android iOS
15 | http://markmeeus.github.io/MarcelloDB/images/logo/icon_blue_512x512.png
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/MarcelloDB.Test/Records/RecordHeaderTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 | using NUnit.Framework;
4 |
5 | namespace MarcelloDB.Test.Records
6 | {
7 | [TestFixture]
8 | public class RecordHeaderTest
9 | {
10 | [Test]
11 | public void Serializes_To_And_From_Bytes()
12 | {
13 | var header = RecordHeader.New();
14 | header.HeaderVersion = 1;
15 | header.DataSize = 3;
16 | header.AllocatedDataSize = 4;
17 | Int64 address = 5;
18 |
19 | var bytes = header.AsBytes();
20 | var loadedHeader = RecordHeader.FromBytes(address, bytes);
21 |
22 | Assert.AreEqual(header.HeaderVersion, loadedHeader.HeaderVersion, "HeaderVersion");
23 | Assert.AreEqual(header.DataSize, loadedHeader.DataSize, "DataSize");
24 | Assert.AreEqual(header.AllocatedDataSize, loadedHeader.AllocatedDataSize, "AllocatedSize");
25 | Assert.AreEqual(address, loadedHeader.Address, "Address");
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Shared/UniversalTest.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 268d5135-6f43-4de0-8fda-0053c90d2c93
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/docs/transactions.md:
--------------------------------------------------------------------------------
1 | #Transactions
2 |
3 | To avoid data corruption, all changes are written to a write ahead journal and applied as a single atomic and durable action.
4 | MarcelloDB does this for calls to Persist and Destroy automatically.
5 |
6 | You can extend the transaction to make it span multiple data mutations.
7 |
8 | A transaction runs on a session and can include changes in multiple collections from multiple collection files.
9 |
10 | > Warning: only collections obtained from that session will be included in the transaction. If you start to mix multiple sessions, you're on your own.
11 |
12 |
13 | ```cs
14 | session.Transaction(() => {
15 | articleCollection.Persist(article);
16 | clientCollection.Persist(client);
17 | projectCollection.Destroy(project);
18 | });
19 | ```
20 |
21 | Transactions roll back when an exception occurs within the block.
22 | ```cs
23 | session.Transaction(() => {
24 | articleCollection.Persist(article);
25 | clientCollection.Persist(client);
26 | projectCollection.Destroy(project);
27 | throw new Exception("Nothing happened");
28 | });
29 | ```
30 |
--------------------------------------------------------------------------------
/MarcelloDB/Storage/StorageEngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB;
3 | using MarcelloDB.Storage.StreamActors;
4 | using MarcelloDB.Transactions;
5 |
6 | namespace MarcelloDB.Storage
7 | {
8 | internal class StorageEngine : SessionBoundObject
9 | {
10 |
11 | string StreamName { get; set; }
12 |
13 | public StorageEngine(Session session,string streamName) : base(session)
14 | {
15 | this.StreamName = streamName;
16 | }
17 |
18 | internal byte[] Read(long address, int length)
19 | {
20 | return Reader().Read(address, length);
21 | }
22 |
23 | internal void Write(long address, byte[] bytes)
24 | {
25 | Writer().Write(address, bytes);
26 | }
27 |
28 | #region reader/writer factories
29 | Writer Writer()
30 | {
31 | return new JournalledWriter(this.Session, this.StreamName);
32 | }
33 |
34 | Reader Reader()
35 | {
36 | return new JournalledReader(this.Session, this.StreamName);
37 | }
38 | #endregion
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/docs/template/LICENSE:
--------------------------------------------------------------------------------
1 | Couscous
2 |
3 | Copyright (C) Matthieu Napoli
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 | associated documentation files (the "Software"), to deal in the Software without restriction,
7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 | subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all copies or substantial
12 | portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 |
--------------------------------------------------------------------------------
/MarcelloDB.netfx/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle ("MarcelloDB.netfx")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("Mark Meeus")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion ("1.0.9.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("MarcelloDB.BenchmarkTool")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("markmeeus")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 |
--------------------------------------------------------------------------------
/MarcelloDB/AllocationStrategies/AllocationStrategyResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Index;
3 | using MarcelloDB.Records;
4 |
5 | namespace MarcelloDB.AllocationStrategies
6 | {
7 | internal class AllocationStrategyResolver
8 | {
9 | internal IAllocationStrategy StrategyFor(Node emptyRecordIndexNode)
10 | {
11 | return new ExactSizeAllocationStrategy();
12 | }
13 |
14 | internal IAllocationStrategy StrategyFor(Node node)
15 | {
16 | if (node.GetType () == typeof (Node)) {
17 | return StrategyFor ((Node)(object)node);
18 | }
19 | return new PredictiveBTreeNodeAllocationStrategy(node);
20 | }
21 |
22 | internal IAllocationStrategy StrategyFor(object obj)
23 | {
24 | if(obj.GetType() == typeof(Node))
25 | {
26 | return StrategyFor((Node)obj);
27 | }
28 | return new DoubleSizeAllocationStrategy();
29 | }
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/docs/longterm.md:
--------------------------------------------------------------------------------
1 | ## A few long-term ideas.
2 |
3 | Some ideas for MarcelloDB after 1.0:
4 |
5 | ###Pub-Sub
6 |
7 | After deploying a pubsub server (to be developed).
8 | One would be able to do this:
9 |
10 | ```cs
11 | //on the publishing side
12 | session['products.dat'].Publish("marcellodb://user:pass@someserver.tld/products.dat");
13 | ```
14 |
15 | ```cs
16 | //on the receiving side
17 | session['products.dat'].Subscribe("marcellodb://user:pass@someserver.tld/products.dat");
18 | ```
19 | Supports 1 Publisher, and many Subscribers per collection-file.
20 |
21 |
22 | ###Full Text indexes
23 |
24 | ```cs
25 | class BookIndexDefinition : IndexDefinition
26 | {
27 | public FullTextIndexedValue AllFullText { get;set; }
28 | }
29 | ```
30 |
31 | The FullTextIndexedValue will create a full-text index for every String.
32 | When using the auto-implemented get-set, it will use the instance of the persisted object.
33 |
34 | It will also be possible to implement a mapper if only a specific set of properties needs to be indexed.
35 |
36 | Find will return a FullTextResult:
37 | ```cs
38 | bookCollection.AllFullText.Find("for dummies");
39 | ```
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) [2015] [Mark Meeus]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Benchmarks/SequentialDestroy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.BenchmarkTool.DataClasses;
3 | using System.Linq;
4 | using System.Collections.Generic;
5 |
6 | namespace MarcelloDB.BenchmarkTool.Benchmarks
7 | {
8 | public class SequentialDestroy : Base
9 | {
10 | int _objectCount ;
11 |
12 | List _toDestroy;
13 |
14 | public SequentialDestroy(int objectCount)
15 | {
16 | _objectCount = objectCount;
17 | }
18 |
19 | protected override void OnSetup()
20 | {
21 | for (int i = 0; i < _objectCount; i++)
22 | {
23 | var person = Person.BuildRandom();
24 | person.ID = i;
25 | this.Collection.Persist(person);
26 | }
27 |
28 | _toDestroy = this.Collection.All.ToList();
29 |
30 | base.OnSetup();
31 | }
32 |
33 | protected override void OnRun()
34 | {
35 |
36 | foreach (var p in _toDestroy)
37 | {
38 | this.Collection.Destroy(p.ID);
39 | }
40 | }
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/MarcelloDB/Serialization/ValueSerializers/ValueWithAddressIndexKeySerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.Records;
3 |
4 | namespace MarcelloDB.Serialization.ValueSerializers
5 | {
6 | class ValueWithAddressSerializer : ValueSerializer>
7 | {
8 | ValueSerializer ValueSerializer { get; set; }
9 |
10 | public ValueWithAddressSerializer(ValueSerializer valueSerializer){
11 | this.ValueSerializer = valueSerializer;
12 | }
13 |
14 | internal override void WriteValue(BinaryFormatter formatter, ValueWithAddressIndexKey value)
15 | {
16 | formatter.WriteInt64(value.A);
17 | this.ValueSerializer.WriteValue(formatter, value.V);
18 | }
19 |
20 | internal override ValueWithAddressIndexKey ReadValue(BinaryFormatter formatter)
21 | {
22 | var result = new ValueWithAddressIndexKey();
23 | result.A = formatter.ReadInt64();
24 | result.V = this.ValueSerializer.ReadValue(formatter);
25 | return result;
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/MarcelloDB/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle ("MarcelloDB")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("Mark Meeus")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.9.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 | [assembly :InternalsVisibleTo("MarcelloDB.Test")]
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Benchmarks/RandomRead.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MarcelloDB.BenchmarkTool.DataClasses;
3 |
4 | namespace MarcelloDB.BenchmarkTool.Benchmarks
5 | {
6 | public class RandomRead : Base
7 | {
8 | int _objectCount ;
9 |
10 | public RandomRead(int objectCount)
11 | {
12 | _objectCount = objectCount;
13 | }
14 |
15 | protected override void OnSetup()
16 | {
17 | for (int i = 0; i < _objectCount; i++)
18 | {
19 | var person = Person.BuildRandom();
20 | person.ID = i;
21 | this.Collection.Persist(person);
22 | }
23 | base.OnSetup();
24 | }
25 |
26 | protected override void OnRun()
27 | {
28 | var r = new Random();
29 | for (int i = 0; i < _objectCount; i++)
30 | {
31 | var o = this.Collection.Find(r.Next(_objectCount));
32 | if(o == null){
33 | throw new Exception("Object with Id " + i.ToString() + " not found");
34 | }
35 | }
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/MarcelloDB.uwp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MarcelloDB.uwp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MarcelloDB.uwp")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.9.0")]
28 | [assembly: AssemblyFileVersion("1.0.9.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/UniversalTest/UniversalTest.Windows/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UniversalTest.Windows")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UniversalTest.Windows")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/MarcelloDB.W81/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("MarceloDB.uwp")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("MarceloDB.uwp")]
14 | [assembly: AssemblyCopyright("Mark Meeus")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: NeutralResourcesLanguage("en")]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.2.*")]
30 | [assembly: AssemblyFileVersion("1.0.2.*")]
31 |
--------------------------------------------------------------------------------
/MarcelloDB/Collections/ObjectByIDEnumerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections;
4 |
5 | namespace MarcelloDB.Collections
6 | {
7 | class ObjectByIDEnumerator : IEnumerable{
8 |
9 | internal IEnumerable IDs { get; set; }
10 |
11 | internal Collection Collection { get; set; }
12 |
13 | internal ObjectByIDEnumerator(Collection collection, IEnumerable ids){
14 | this.IDs = ids;
15 | this.Collection = collection;
16 | }
17 |
18 | #region IEnumerable implementation
19 | public IEnumerator GetEnumerator()
20 | {
21 | foreach (var id in this.IDs)
22 | {
23 | var obj = this.Collection.Find(id);
24 | if (obj != null)
25 | {
26 | yield return obj;
27 | }
28 | }
29 | }
30 | #endregion
31 |
32 | #region IEnumerable implementation
33 |
34 | IEnumerator IEnumerable.GetEnumerator()
35 | {
36 | return ((IEnumerable)this).GetEnumerator();
37 | }
38 | #endregion
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/MarcelloDB.BenchmarkTool/Benchmarks/RandomDestroy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using MarcelloDB.BenchmarkTool.DataClasses;
4 | using System.Linq;
5 | using MarcelloDB.BenchmarkTool.Extensions;
6 |
7 | namespace MarcelloDB.BenchmarkTool.Benchmarks
8 | {
9 | public class RandomDestroy : Base
10 | {
11 | int _objectCount ;
12 |
13 | List _toDestroy;
14 |
15 | public RandomDestroy(int objectCount)
16 | {
17 | _objectCount = objectCount;
18 | }
19 |
20 | protected override void OnSetup()
21 | {
22 | for (int i = 0; i < _objectCount; i++)
23 | {
24 | var person = Person.BuildRandom();
25 | person.ID = i;
26 | this.Collection.Persist(person);
27 | }
28 |
29 | _toDestroy = this.Collection.All.ToList();
30 | _toDestroy.Shuffle();
31 |
32 | base.OnSetup();
33 | }
34 |
35 | protected override void OnRun()
36 | {
37 |
38 | foreach (var p in _toDestroy)
39 | {
40 | this.Collection.Destroy(p.ID);
41 | }
42 | }
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/MarcelloDB/Collections/IndexedValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Collections.Generic;
4 | using MarcelloDB.Records;
5 | using MarcelloDB.Serialization;
6 | using MarcelloDB.Index;
7 | using System.Collections;
8 | using MarcelloDB.Index.BTree;
9 | using MarcelloDB.Collections.Scopes;
10 |
11 | namespace MarcelloDB.Collections
12 | {
13 | public abstract class IndexedValue : SessionBoundObject
14 | {
15 | public IndexedValue(Session session) : base(session){}
16 |
17 | internal abstract IEnumerable