Example #1
0
 public BackupOperation(DocumentDatabase database, IPersistentSource persistentSource, string src, string to)
 {
     this.database         = database;
     this.persistentSource = persistentSource;
     this.src = src;
     this.to  = to;
 }
Example #2
0
		public BackupOperation(DocumentDatabase database, IPersistentSource persistentSource, string src, string to)
		{
			this.database = database;
		    this.persistentSource = persistentSource;
		    this.to = to.ToFullPath();
            this.src = src.ToFullPath();
		}
Example #3
0
        public EmbeddedDocumentStore(string name)
        {
            try
            {
                Conventions = new DocumentConvention
                {
                    DocumentKeyGenerator = entity =>
                    {
                        var typeTagName = Conventions.GetTypeTagName(entity.GetType());
                        if (typeTagName == null)
                        {
                            return(Guid.NewGuid().ToString());
                        }
                        return(typeTagName + "/" + Guid.NewGuid());
                    }
                };

                persistentSource = new IsolatedStoragePersistentSource(name, "ravenlight");
                storage          = new TableStorage(persistentSource);
                storage.Initialze();
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Example #4
0
        public TableStorage(IPersistentSource persistentSource)
            : base(persistentSource)
        {
            Details = Add(new Table("Details"));

            Identity = Add(new Table(x => x.Value <string>("name"), "Identity"));

            Attachments = Add(new Table(x => x.Value <string>("key"), "Attachments")
            {
                { "ByEtag", x => new ComparableByteArray(x.Value <byte[]>("etag")) },
            });

            Documents = Add(new Table(x => x.Value <string>("key"), "Documents")
            {
                { "ByKey", x => x.Value <string>("key") },
                { "ById", x => x.Value <string>("id") },
                { "ByEtag", x => new ComparableByteArray(x.Value <byte[]>("etag")) }
            });

            DocumentsModifiedByTransactions =
                Add(new Table(x => new JObject {
                { "key", x.Value <string>("key") }
            },
                              "DocumentsModifiedByTransactions")
            {
                { "ByTxId", x => new ComparableByteArray(x.Value <byte[]>("txId")) }
            });

            Transactions =
                Add(new Table(x => x.Value <byte[]>("txId"), "Transactions"));

            IndexingStats =
                Add(new Table(x => x.Value <string>("index"), "IndexingStats"));


            MappedResults = Add(new Table("MappedResults")
            {
                { "ByViewAndReduceKey", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("reduceKey")) },
                { "ByViewAndDocumentId", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("docId")) }
            });

            Queues = Add(new Table(x => new JObject
            {
                { "name", x.Value <string>("name") },
                { "id", x.Value <byte[]>("id") },
            }, "Queues")
            {
                { "ByName", x => x.Value <string>("name") }
            });

            Tasks = Add(new Table(x => new JObject
            {
                { "index", x.Value <string>("index") },
                { "id", x.Value <byte[]>("id") },
            }, "Tasks")
            {
                { "ByIndexAndTime", x => Tuple.Create(x.Value <string>("index"), x.Value <DateTime>("time")) },
                { "ByIndexAndType", x => Tuple.Create(x.Value <string>("index"), x.Value <string>("type")) }
            });
        }
        public bool Initialize(IUuidGenerator generator)
        {
            uuidGenerator = generator;
            if (configuration.RunInMemory == false && Directory.Exists(configuration.DataDirectory) == false)
            {
                Directory.CreateDirectory(configuration.DataDirectory);
            }

            persistenceSource = configuration.RunInMemory
                          ? (IPersistentSource) new MemoryPersistentSource()
                          : new FileBasedPersistentSource(configuration.DataDirectory, "Raven", configuration.TransactionMode == TransactionMode.Safe);

            queuesStroage = new QueuesStorage(persistenceSource);

            idleTimer = new Timer(MaybeOnIdle, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));

            queuesStroage.Initialze();

            if (persistenceSource.CreatedNew)
            {
                Id = Guid.NewGuid();
                Batch(accessor => queuesStroage.Details.Put("id", Id.ToByteArray()));
            }
            else
            {
                var readResult = queuesStroage.Details.Read("id");
                Id = new Guid(readResult.Data());
            }

            return(persistenceSource.CreatedNew);
        }
Example #6
0
        public bool Initialize(IUuidGenerator generator, OrderedPartCollection <AbstractDocumentCodec> documentCodecs)
        {
            DocumentCodecs = documentCodecs;
            uuidGenerator  = generator;
            if (configuration.RunInMemory == false && Directory.Exists(configuration.DataDirectory) == false)
            {
                Directory.CreateDirectory(configuration.DataDirectory);
            }

            persistenceSource = configuration.RunInMemory
                                                  ? (IPersistentSource) new MemoryPersistentSource()
                                                  : new FileBasedPersistentSource(configuration.DataDirectory, "Raven", configuration.TransactionMode == TransactionMode.Safe);

            tableStroage = new TableStorage(persistenceSource);

            idleTimer = new Timer(MaybeOnIdle, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));

            tableStroage.Initialze();

            if (persistenceSource.CreatedNew)
            {
                Id = Guid.NewGuid();
                Batch(accessor => tableStroage.Details.Put("id", Id.ToByteArray()));
            }
            else
            {
                using (tableStroage.BeginTransaction())
                {
                    var readResult = tableStroage.Details.Read("id");
                    Id = new Guid(readResult.Data());
                }
            }

            return(persistenceSource.CreatedNew);
        }
Example #7
0
		public BackupOperation(DocumentDatabase database, IPersistentSource persistentSource, string src, string to, DatabaseDocument databaseDocument)
		{
			this.database = database;
			this.persistentSource = persistentSource;
			this.src = src;
			this.to = to;
			this.databaseDocument = databaseDocument;
		}
		public TableStorage(IPersistentSource persistentSource)
			: base(persistentSource)
		{
			Documents = Add(new Table(token => token.Value<string>("key"), "Documents")
			{
				{"ByTag", jToken => jToken.Value<string>("tag")}
			});
		}
Example #9
0
 public PersistableCatalog(
     IInMemoryCollection <T> collection,
     IPersistentSource <T> source,
     List <PersistencyOperations> supportedOperations,
     KeyManagementStrategyType keyManagementStrategy = KeyManagementStrategyType.CollectionDecides)
     : base(collection, source, supportedOperations, keyManagementStrategy)
 {
 }
Example #10
0
 protected PersistableCatalogAsync(
     IInMemoryCollection <TDomainData> collection,
     IPersistentSource <TPersistentData> source,
     List <PersistencyOperations> supportedOperations)
     : base(collection, source, supportedOperations)
 {
     _persistentSource = source;
 }
 public TableStorage(IPersistentSource persistentSource)
     : base(persistentSource)
 {
     Documents = Add(new Table(token => token.Value <string>("key"), "Documents")
     {
         { "ByTag", jToken => jToken.Value <string>("tag") }
     });
 }
Example #12
0
        public TableStorage(IPersistentSource persistentSource)
            : base(persistentSource)
        {
            Details = Add(new Table("Detauls"));

            Identity = Add(new Table(x => x.Value<string>("name"), "Identity"));

            Attachments = Add(new Table(x => x.Value<string>("key"), "Attachments")
            {
                {"ByEtag", x => new ComparableByteArray(x.Value<byte[]>("etag"))},
            });

            Documents = Add(new Table(x => x.Value<string>("key"), "Documents")
            {
                {"ByKey", x => x.Value<string>("key")},
                {"ById", x => x.Value<string>("id")},
                {"ByEtag", x => new ComparableByteArray(x.Value<byte[]>("etag"))}
            });

            DocumentsModifiedByTransactions =
                Add(new Table(x => new JObject {{"key", x.Value<string>("key")}},
                              "DocumentsModifiedByTransactions")
                {
                    {"ByTxId", x => new ComparableByteArray(x.Value<byte[]>("txId"))}
                });

            Transactions =
                Add(new Table(x => x.Value<byte[]>("txId"), "Transactions"));

            IndexingStats =
                Add(new Table(x => x.Value<string>("index"), "IndexingStats"));


            MappedResults = Add(new Table("MappedResults")
            {
                {"ByViewAndReduceKey", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"))},
                {"ByViewAndDocumentId", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("docId"))}
            });

            Queues = Add(new Table(x => new JObject
            {
                {"name", x.Value<string>("name")},
                {"id", x.Value<byte[]>("id")},
            }, "Queues")
            {
                {"ByName", x => x.Value<string>("name")}
            });

            Tasks = Add(new Table(x => new JObject
            {
                {"index", x.Value<string>("index")},
                {"id", x.Value<byte[]>("id")},
            }, "Tasks")
            {
                {"ByIndexAndTime", x => Tuple.Create(x.Value<string>("index"), x.Value<DateTime>("time"))},
                {"ByIndexAndType", x => Tuple.Create(x.Value<string>("index"), x.Value<string>("type"))}
            });
        }
Example #13
0
 protected PersistableCatalog(
     IInMemoryCollection <T> collection,
     IPersistentSource <TDTO> source,
     List <PersistencyOperations> supportedOperations)
     : base(collection, source, supportedOperations)
 {
     _persistentSource = source;
     Manage();
 }
Example #14
0
 protected PersistableCatalogFull(
     IInMemoryCollection <TDomainData> collection,
     IPersistentSource <TPersistentData> source,
     List <PersistencyOperations> supportedOperations,
     KeyManagementStrategyType keyManagementStrategy = KeyManagementStrategyType.CollectionDecides)
     : base(collection, source, supportedOperations, keyManagementStrategy)
 {
     _persistentSource = source;
 }
 public PersistableCatalog(
     IInMemoryCollection <T> collection,
     IPersistentSource <TDTO> source,
     IFactory <T, TVMO> vmFactory,
     IFactory <T, TDTO> dtoFactory,
     List <PersistencyOperations> supportedOperations)
     : base(collection, source, vmFactory, dtoFactory, supportedOperations)
 {
     Manage();
 }
Example #16
0
 public RemoteManagedStorage(RemoteManagedStorageState state)
 {
     if (state.Path != null)
     {
         persistentSource = new ReadOnlyFileBasedPersistentSource(state.Path, state.Prefix);
     }
     else
     {
         persistentSource = new MemoryPersistentSource(state.Log);
     }
 }
Example #17
0
 public RemoteManagedStorage(RemoteManagedStorageState state)
 {
     if (state.Path != null)
     {
         persistentSource = new ReadOnlyFileBasedPersistentSource(state.Path, state.Prefix);
     }
     else
     {
         persistentSource = new MemoryPersistentSource(state.Log);
     }
 }
Example #18
0
        public MyData(IPersistentSource persistentSource)
            : base(persistentSource)
        {
            Documents = Add(new Table(x => x.Value <string>("key"), "Documents")
            {
                { "ByKey", x => x.Value <string>("key") },
                { "ById", x => x.Value <string>("id") },
                { "ByEtag", x => new ComparableByteArray(x.Value <byte[]>("etag")) }
            });

            Transactions = Add(new Table(x => x.Value <string>("txId"), "Transactions"));
        }
Example #19
0
 public Catalog(
     IInMemoryCollection <T> collection,
     IPersistentSource <TDTO> source,
     IFactory <T, TVMO> vmoFactory,
     IFactory <T, TDTO> dtoFactory,
     List <PersistencyOperations> supportedOperations)
 {
     _collection          = collection;
     _source              = source;
     _vmoFactory          = vmoFactory;
     _dtoFactory          = dtoFactory;
     _supportedOperations = supportedOperations;
 }
        public AggregateDictionary(IPersistentSource persistentSource, int countOfDictionaries)
        {
            this.persistentSource = persistentSource;
            dictionaries = new PersistentDictionary[countOfDictionaries];

            for (var i = 0; i < countOfDictionaries; i++)
            {
                dictionaries[i] = new PersistentDictionary(persistentSource)
                {
                    DictionaryId = i
                };
            }

            Initialze();
        }
Example #21
0
        public void Initialize(IPersistentSource source, int tableId, Database database, ThreadLocal <Guid> transactionId)
        {
            persistentSource = source;
            TableId          = tableId;
            parent           = database;
            txId             = transactionId;

            parent.DictionaryStates[tableId] = new PersistentDictionaryState(comparer);

            int index = 0;

            foreach (var secondaryIndex in SecondaryIndices)
            {
                persistentSource.DictionariesStates[TableId].SecondaryIndicesState.Add(new EmptyAVLTree <IComparable, IBinarySearchTree <RavenJToken, RavenJToken> >(Comparer <IComparable> .Default, x => x, x => x));
                secondaryIndex.Initialize(persistentSource, TableId, index++);
            }
        }
Example #22
0
        public QueuesStorage(IPersistentSource persistentSource)
            : base(persistentSource)
        {
            Messages = Add(new Table(key => key["MsgId"], "Messages")
            {
                {"ByMsgId", key => new ComparableByteArray(key.Value<byte[]>("MsgId"))}
            });

            PendingMessages = Add(new Table(key => key["MsgId"], "Messages")
            {
                {"ByHideDesc", key=> new ReverseComparable(key.Value<DateTime>("Hide"))}
            });

            Queues = Add(new Table(key => key["Name"], "Queues"));

            Identity = Add(new Table(x => x.Value<string>("name"), "Identity"));

            Details = Add(new Table("Details"));
        }
Example #23
0
        public QueuesStorage(IPersistentSource persistentSource) : base(persistentSource)
        {
            Messages = Add(new Table(key => key["MsgId"], "Messages")
            {
                { "ByMsgId", key => new ComparableByteArray(key.Value <byte[]>("MsgId")) }
            });

            PendingMessages = Add(new Table(key => key["MsgId"], "Messages")
            {
                { "ByHideDesc", key => new ReverseComparable(key.Value <DateTime>("Hide")) }
            });

            Queues = Add(new Table(key => key["Name"], "Queues"));


            Identity = Add(new Table(x => x.Value <string>("name"), "Identity"));

            Details = Add(new Table("Details"));
        }
Example #24
0
		public EmbeddedDocumentStore(string name)
		{
			try
			{
				Conventions = new DocumentConvention
				{
					DocumentKeyGenerator = entity =>
					{
						var typeTagName = Conventions.GetTypeTagName(entity.GetType());
						if (typeTagName == null)
							return Guid.NewGuid().ToString();
						return typeTagName + "/" + Guid.NewGuid();
					}
				};

				persistentSource = new IsolatedStoragePersistentSource(name, "ravenlight");
				storage = new TableStorage(persistentSource);
			}
			catch
			{
				Dispose();
				throw;
			}
		}
Example #25
0
		public MyData(IPersistentSource persistentSource)
			: base(persistentSource)
		{
			Documents = Add(new Table(x => x.Value<string>("key"), "Documents")
				{
					{"ByKey", x => x.Value<string>("key")},
					{"ById", x => x.Value<string>("id")},
					{"ByEtag", x => new ComparableByteArray(x.Value<byte[]>("etag"))}
				});

			Transactions = Add(new Table(x => x.Value<string>("txId"), "Transactions"));
		}
Example #26
0
 public Database(IPersistentSource persistentSource)
 {
     this.persistentSource = persistentSource;
 }
Example #27
0
 public IPersistentEpochGroup BeginEpochGroup(string label, IPersistentSource source)
 {
     return null;
 }
Example #28
0
 public IPersistentSource AddSource(string label, IPersistentSource parent)
 {
     return null;
 }
Example #29
0
        public TableStorage(IPersistentSource persistentSource)
            : base(persistentSource)
        {
            Details = new PersistentDictionaryAdapter(txId,
                                                     Add(new PersistentDictionary(persistentSource, JTokenComparer.Instance)
                                                     {
                                                         Name = "Details"
                                                     }));

            Identity = new PersistentDictionaryAdapter(txId,
                                                       Add(new PersistentDictionary(persistentSource, new ModifiedJTokenComparer(x=>x.Value<string>("name")))
                                                       {
                                                           Name = "Identity"
                                                       }));

            Attachments = new PersistentDictionaryAdapter(txId, Add(new PersistentDictionary(persistentSource, new ModifiedJTokenComparer(x => x.Value<string>("key")))
            {
                Name = "Attachments"
            }))
            {
                {"ByEtag", x => x.Value<byte[]>("etag")}
            };

            Documents = new PersistentDictionaryAdapter(txId, Add(new PersistentDictionary(persistentSource, new ModifiedJTokenComparer(x => x.Value<string>("key")))
            {
                Name = "Documents"
            }))
            {
                {"ByKey", x => x.Value<string>("key")},
                {"ById", x => x.Value<string>("id")},
                {"ByEtag", x => x.Value<byte[]>("etag")}
            };

            DocumentsModifiedByTransactions = new PersistentDictionaryAdapter(txId, 
                Add(new PersistentDictionary(persistentSource, new ModifiedJTokenComparer(x => new JObject
                {
                    {"key", x.Value<string>("key")},
                }))
                {
                    Name = "DocumentsModifiedByTransactions"
                }))
            {
                {"ByTxId", x => x.Value<byte[]>("txId")}
            };
            Transactions = new PersistentDictionaryAdapter(txId,
                Add(new PersistentDictionary(persistentSource,new ModifiedJTokenComparer(x => x.Value<byte[]>("txId")))
                {
                    Name = "Transactions"
                }));

            IndexingStats = new PersistentDictionaryAdapter(txId,
                Add(new PersistentDictionary(persistentSource,new ModifiedJTokenComparer(x =>x.Value<string>("index")))
                {
                    Name = "IndexingStats"
                }));

            MappedResults = new PersistentDictionaryAdapter(txId, Add(new PersistentDictionary(persistentSource, JTokenComparer.Instance)
            {
                Name = "MappedResults"
            }))
            {
                {"ByViewAndReduceKey", x => new JObject
                    {
                        {"view", x.Value<string>("view")},
                        {"reduceKey", x.Value<string>("reduceKey")}
                    }},
               {"ByViewAndDocumentId", x => new JObject
                    {
                        {"view", x.Value<string>("view")},
                        {"docId", x.Value<string>("docId")}
                    }}
            };

            Queues = new PersistentDictionaryAdapter(txId, Add(new PersistentDictionary(persistentSource, 
                                                                                        new ModifiedJTokenComparer(x=> new JObject
                                                                                        {
                                                                                            {"name", x.Value<string>("name")},
                                                                                            {"id", x.Value<byte[]>("id")},
                                                                                        }))
            {
                Name = "Queues"
            }))
            {
                {"ByName", x=>x.Value<string>("name")}
            };

            Tasks = new PersistentDictionaryAdapter(txId, Add(new PersistentDictionary(persistentSource,
                                                                                       new ModifiedJTokenComparer(x => new JObject
                                                                                        {
                                                                                            {"index", x.Value<string>("index")},
                                                                                            {"id", x.Value<byte[]>("id")},
                                                                                        }))
            {
                Name = "Tasks"
            }))
            {
                {"ByIndexAndTime", x=>new JObject
                {
                    {"index", x.Value<string>("index")},
                    {"time", x.Value<DateTime>("time")}
                }},
                {"ByIndexAndType", x=>new JObject
                {
                    {"index", x.Value<string>("index")},
                    {"type", x.Value<string>("type")},
                }}
            };
        }
Example #30
0
		public bool Initialize(IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs)
		{
			DocumentCodecs = documentCodecs;
			uuidGenerator = generator;
			if (configuration.RunInMemory  == false && Directory.Exists(configuration.DataDirectory) == false)
				Directory.CreateDirectory(configuration.DataDirectory);

			persistenceSource = configuration.RunInMemory
						  ? (IPersistentSource)new MemoryPersistentSource()
						  : new FileBasedPersistentSource(configuration.DataDirectory, "Raven", configuration.TransactionMode == TransactionMode.Safe);

			tableStroage = new TableStorage(persistenceSource);

			idleTimer = new Timer(MaybeOnIdle, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));

			tableStroage.Initialze();

			if (persistenceSource.CreatedNew)
			{
				Id = Guid.NewGuid();
				Batch(accessor => tableStroage.Details.Put("id", Id.ToByteArray()));
			}
			else
			{
				using(tableStroage.BeginTransaction())
				{
				var readResult = tableStroage.Details.Read("id");
				Id = new Guid(readResult.Data());
			}
			}

			return persistenceSource.CreatedNew;
		}
Example #31
0
        public TableStorage(IPersistentSource persistentSource)
            : base(persistentSource)
        {
            Details = Add(new Table("Details"));

            Identity = Add(new Table(x => x.Value <string>("name"), "Identity"));

            Attachments = Add(new Table(x => x.Value <string>("key"), "Attachments")
            {
                { "ByKey", x => x.Value <string>("key") },
                { "ByEtag", x => new ComparableByteArray(x.Value <byte[]>("etag")) },
            });

            Documents = Add(new Table(x => x.Value <string>("key"), "Documents")
            {
                { "ByKey", x => x.Value <string>("key") },
                { "ById", x => x.Value <string>("id") },
                { "ByEtag", x => new ComparableByteArray(x.Value <byte[]>("etag")) }
            });

            DocumentsModifiedByTransactions =
                Add(new Table(x => new RavenJObject {
                { "key", x.Value <string>("key") }
            },
                              "DocumentsModifiedByTransactions")
            {
                { "ByTxId", x => new ComparableByteArray(x.Value <byte[]>("txId")) }
            });

            Transactions =
                Add(new Table(x => x.Value <byte[]>("txId"), "Transactions"));

            IndexingStats =
                Add(new Table(x => x.Value <string>("index"), "IndexingStats"));


            MappedResults = Add(new Table("MappedResults")
            {
                { "ByViewAndReduceKey", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("reduceKey")) },
                { "ByViewAndDocumentId", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("docId")) },
                { "ByViewAndEtagDesc", x => Tuple.Create(x.Value <string>("view"), new ReverseComparableByteArrayWhichIgnoresNull(x.Value <byte[]>("etag"))) },
                { "ByViewAndEtag", x => Tuple.Create(x.Value <string>("view"), new ComparableByteArray(x.Value <byte[]>("etag"))) },
                { "ByViewReduceKeyAndBucket", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("reduceKey"), x.Value <int>("bucket")) }
            });

            ReduceResults = Add(new Table("ReducedResults")
            {
                { "ByViewReduceKeyAndSourceBucket", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("reduceKey"), x.Value <int>("sourceBucket")) },
                { "ByViewReduceKeyLevelAndBucket", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("reduceKey"), x.Value <int>("level"), x.Value <int>("bucket")) }
            });

            Queues = Add(new Table(x => new RavenJObject
            {
                { "name", x.Value <string>("name") },
                { "id", x.Value <byte[]>("id") }
            }, "Queues")
            {
                { "ByName", x => x.Value <string>("name") }
            });

            Tasks = Add(new Table(x => new RavenJObject
            {
                { "index", x.Value <string>("index") },
                { "id", x.Value <byte[]>("id") }
            }, "Tasks")
            {
                { "ByIndexAndTime", x => Tuple.Create(x.Value <string>("index"), x.Value <DateTime>("time")) },
                { "ByIndexAndType", x => Tuple.Create(x.Value <string>("index"), x.Value <string>("type")) }
            });

            Lists = Add(new Table(x => new RavenJObject
            {
                { "name", x.Value <string>("name") },
                { "key", x.Value <string>("key") },
            }, "Lists")
            {
                { "ByNameAndEtag", x => Tuple.Create(x.Value <string>("name"), new ComparableByteArray(x.Value <byte[]>("etag"))) },
            });

            ScheduleReductions = Add(new Table("ScheduleReductions")
            {
                { "ByView", x => x.Value <string>("view") },
                { "ByViewAndReduceKey", x => Tuple.Create(x.Value <string>("view"), x.Value <string>("reduceKey")) },
                { "ByViewLevelReduceKeyAndBucket", x => Tuple.Create(x.Value <string>("view"), x.Value <int>("level"), x.Value <string>("reduceKey"), x.Value <int>("bucket")) },
            });
        }
Example #32
0
 public void Initialize(IPersistentSource thePersistentSource, int dictionaryId, int indexId)
 {
     DictionaryId     = dictionaryId;
     IndexId          = indexId;
     persistentSource = thePersistentSource;
 }
Example #33
0
		public void Initialize(IPersistentSource thePersistentSource, int dictionaryId, int indexId)
		{
			DictionaryId = dictionaryId;
			IndexId = indexId;
			persistentSource = thePersistentSource;
		}
Example #34
0
		public ToDoRepository(IPersistentSource source)
		{
			database = new Database(source);
			todos = database.Add(new Table("todo"));
			database.Initialize();
		}
Example #35
0
 public ToDoRepository(IPersistentSource source)
 {
     database = new Database(source);
     todos    = database.Add(new Table("todo"));
     database.Initialze();
 }
 public PersistentDictionary(IPersistentSource persistentSource)
 {
     this.persistentSource = persistentSource;
 }
Example #37
0
		public TableStorage(IPersistentSource persistentSource)
			: base(persistentSource)
		{
			Details = Add(new Table("Details"));

			Identity = Add(new Table(x => x.Value<string>("name"), "Identity"));

			Attachments = Add(new Table(x => x.Value<string>("key"), "Attachments")
			{
				{"ByKey", x => x.Value<string>("key")},
				{"ByEtag", x => new ComparableByteArray(x.Value<byte[]>("etag"))},
			});

			Documents = Add(new Table(x => x.Value<string>("key"), "Documents")
			{
				{"ByKey", x => x.Value<string>("key")},
				{"ById", x => x.Value<string>("id")},
				{"ByEtag", x => new ComparableByteArray(x.Value<byte[]>("etag"))}
			});

			DocumentsModifiedByTransactions =
				Add(new Table(x => new RavenJObject{{"key", x.Value<string>("key")}},
							  "DocumentsModifiedByTransactions")
				{
					{"ByTxId", x => new ComparableByteArray(x.Value<byte[]>("txId"))}
				});

			IndexingStats =
				Add(new Table(x => x.Value<string>("index"), "IndexingStats"));

			LastIndexedEtags =
				Add(new Table(x => x.Value<string>("index"), "LastIndexedEtags"));

			MappedResults = Add(new Table("MappedResults")
			{
				{"ByView", x=> x.Value<string>("view")},
				{"ByViewAndReduceKey", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"))},
				{"ByViewAndDocumentId", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("docId"))},
				{"ByViewAndEtagDesc", x => Tuple.Create(x.Value<string>("view"), new ReverseComparableByteArrayWhichIgnoresNull(x.Value<byte[]>("etag")))},
				{"ByViewAndEtag", x => Tuple.Create(x.Value<string>("view"), new ComparableByteArray(x.Value<byte[]>("etag")))},
				{"ByViewReduceKeyAndBucket", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"), x.Value<int>("bucket"))}
			});

			ReduceResults = Add(new Table("ReducedResults")
			{
				{"ByView", x=> x.Value<string>("view")},
				{"ByViewReduceKeyAndSourceBucket", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"), x.Value<int>("sourceBucket"))},
				{"ByViewReduceKeyLevelAndBucket", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"), x.Value<int>("level"), x.Value<int>("bucket"))}
			});

			Queues = Add(new Table(x => new RavenJObject
			{
				{"name", x.Value<string>("name")},
				{"id", x.Value<byte[]>("id")}
			}, "Queues")
			{
				{"ByName", x => x.Value<string>("name")}
			});

			Tasks = Add(new Table(x => new RavenJObject
			{
				{"index", x.Value<string>("index")},
				{"id", x.Value<byte[]>("id")}
			}, "Tasks")
			{
				{"ByIndexAndTime", x => Tuple.Create(x.Value<string>("index"), x.Value<DateTime>("time"))},
				{"ByIndexAndType", x => Tuple.Create(x.Value<string>("index"), x.Value<string>("type"))}
			});

			Lists = Add(new Table(x => new RavenJObject
			{
				{"name", x.Value<string>("name")},
				{"key", x.Value<string>("key")},
			}, "Lists")
			{
				{"ByNameAndEtag", x => Tuple.Create(x.Value<string>("name"), new ComparableByteArray(x.Value<byte[]>("etag")))},
			});

			ScheduleReductions = Add(new Table("ScheduleReductions")
			{
				{"ByView", x=> x.Value<string>("view")},
				{"ByViewAndReduceKey", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"))},
				{"ByViewLevelReduceKeyAndBucket", x => Tuple.Create(x.Value<string>("view"), x.Value<int>("level"), x.Value<string>("reduceKey"), x.Value<int>("bucket"))},
			});

			ReduceKeys = Add(new Table(x => new RavenJObject()
			{
				{"view", x.Value<string>("view")},
				{"reduceKey", x.Value<string>("reduceKey")}                                      
			}, "ReduceTypesPerKey")
			{
				{"ByView", x=> x.Value<string>("view")},
				{"ByViewAndReduceKey", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("reduceKey"))},
			});

			DocumentReferences = Add(new Table(x => new RavenJObject()
			{
				{"view", x.Value<string>("view")},
				{"key", x.Value<string>("key")} ,                                  
				{"ref", x.Value<string>("ref")} ,
			}, "DocumentReferences")
			{
				{"ByKey", x=> x.Value<string>("key")},
				{"ByView", x=> x.Value<string>("view")},
				{"ByRef", x=> x.Value<string>("ref")},
				{"ByViewAndKey", x => Tuple.Create(x.Value<string>("view"), x.Value<string>("key"))},
			});

			EtagSynchronization = Add(new Table(x => x.Value<string>("key"), "EtagSynchronization"));
		}
        public bool Initialize()
        {
            if (configuration.RunInMemory  == false && Directory.Exists(configuration.DataDirectory) == false)
                Directory.CreateDirectory(configuration.DataDirectory);

            persistenceSource = configuration.RunInMemory
                          ? (IPersistentSource)new MemoryPersistentSource()
                          : new FileBasedPersistentSource(configuration.DataDirectory, "Raven", configuration.TransactionMode);

            tableStroage = new TableStorage(persistenceSource);

            idleTimer = new Timer(MaybeOnIdle, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));

            tableStroage.Initialze();

            if(persistenceSource.CreatedNew)
            {
                Id = Guid.NewGuid();
                Batch(accessor => tableStroage.Details.Put("id", Id.ToByteArray()));
            }
            else
            {
                var readResult = tableStroage.Details.Read("id");
                Id = new Guid(readResult.Data());
            }

            return persistenceSource.CreatedNew;
        }