示例#1
0
 public QueueStorageActions(TableStorage tableStorage, IUuidGenerator generator, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool)
     : base(snapshot, bufferPool)
 {
     this.tableStorage = tableStorage;
     this.writeBatch = writeBatch;
     this.generator = generator;
 }
示例#2
0
 public GeneralStorageActions(TableStorage storage, Reference<WriteBatch> writeBatch, Reference<SnapshotReader> snapshot, IBufferPool bufferPool)
     : base(snapshot, bufferPool)
 {
     this.storage = storage;
     this.writeBatch = writeBatch;
     this.snapshot = snapshot;
 }
        public MappedResultsStorageActions(TableStorage tableStorage, IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool)
			: base(snapshot, bufferPool)
		{
			this.tableStorage = tableStorage;
			this.generator = generator;
			this.documentCodecs = documentCodecs;
			this.writeBatch = writeBatch;
		}
示例#4
0
		public SchemaCreator(InMemoryRavenConfiguration configuration, TableStorage storage, Action<string> output, ILog log)
		{
			this.storage = storage;
			this.output = output;
			this.log = log;

			configuration.Container.SatisfyImportsOnce(this);
		}
        public IndexingStorageActions(TableStorage tableStorage, IUuidGenerator generator, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IStorageActionsAccessor storageActionsAccessor, IBufferPool bufferPool)
			: base(snapshot, bufferPool)
		{
			this.tableStorage = tableStorage;
			this.generator = generator;
			this.writeBatch = writeBatch;
			this.currentStorageActionsAccessor = storageActionsAccessor;
		}
示例#6
0
		public void UpdateSchemaVersion(TableStorage tableStorage,  Action<string> output)
		{
			using (var tx = tableStorage.Environment.NewTransaction(TransactionFlags.ReadWrite))
			{
				tx.ReadTree(Tables.Details.TableName).Add(tx, "schema_version", ToSchemaVersion);
				tx.Commit();
			}

			tableStorage.SetDatabaseIdAndSchemaVersion(tableStorage.Id, ToSchemaVersion);
		}
        public AttachmentsStorageActions(Table attachmentsTable,
                                         Reference<WriteBatch> writeBatch, 
                                         Reference<SnapshotReader> snapshot, 
                                         IUuidGenerator uuidGenerator, 
                                         TableStorage tableStorage,
                                         Raven.Storage.Voron.TransactionalStorage transactionalStorage, 
                                         IBufferPool bufferPool)
            :base(snapshot, bufferPool)
        {
            this.attachmentsTable = attachmentsTable;
            this.writeBatch = writeBatch;
            this.uuidGenerator = uuidGenerator;
            this.tableStorage = tableStorage;
            this.transactionalStorage = transactionalStorage;

            metadataIndex = tableStorage.Attachments.GetIndex(Tables.Attachments.Indices.Metadata);
        }
		public DocumentsStorageActions(IUuidGenerator uuidGenerator,
			OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
			IDocumentCacher documentCacher,
			Reference<WriteBatch> writeBatch,
			Reference<SnapshotReader> snapshot,
            TableStorage tableStorage, 
            IBufferPool bufferPool)
			: base(snapshot, bufferPool)
		{
			this.uuidGenerator = uuidGenerator;
			this.documentCodecs = documentCodecs;
			this.documentCacher = documentCacher;
			this.writeBatch = writeBatch;
			this.tableStorage = tableStorage;

			metadataIndex = tableStorage.Documents.GetIndex(Tables.Documents.Indices.Metadata);
		}
示例#9
0
		public override void Update(TableStorage tableStorage, Action<string> output)
		{
			using (var tx = tableStorage.Environment.NewTransaction(TransactionFlags.ReadWrite))
			{
				var lists = tx.ReadTree(Tables.Lists.TableName);

				var iterator = lists.Iterate();

				if (iterator.Seek(Slice.BeforeAllKeys))
				{
					do
					{
						var result = lists.Read(iterator.CurrentKey);

						using (var stream = result.Reader.AsStream())
						{
							var listItem = stream.ToJObject();

							if (listItem.ContainsKey("createdAt"))
								continue;
							
							listItem.Add("createdAt", SystemTime.UtcNow);

							using (var streamValue = new MemoryStream())
							{
								listItem.WriteTo(streamValue);
								streamValue.Position = 0;

								lists.Add(iterator.CurrentKey, streamValue);
							}
						}

					} while (iterator.MoveNext());
				}

				tx.Commit();
			}

			UpdateSchemaVersion(tableStorage, output);
		}
示例#10
0
		private static void CreateDocumentReferencesSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.DocumentReferences.TableName);
			storage.Environment.CreateTree(tx, storage.DocumentReferences.GetIndexKey(Tables.DocumentReferences.Indices.ByRef));
			storage.Environment.CreateTree(tx, storage.DocumentReferences.GetIndexKey(Tables.DocumentReferences.Indices.ByView));
			storage.Environment.CreateTree(tx, storage.DocumentReferences.GetIndexKey(Tables.DocumentReferences.Indices.ByViewAndKey));
			storage.Environment.CreateTree(tx, storage.DocumentReferences.GetIndexKey(Tables.DocumentReferences.Indices.ByKey));
		}
示例#11
0
		private static void CreateMappedResultsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.MappedResults.TableName);
			storage.Environment.CreateTree(tx, storage.MappedResults.GetIndexKey(Tables.MappedResults.Indices.ByView));
			storage.Environment.CreateTree(tx, storage.MappedResults.GetIndexKey(Tables.MappedResults.Indices.ByViewAndDocumentId));
			storage.Environment.CreateTree(tx, storage.MappedResults.GetIndexKey(Tables.MappedResults.Indices.ByViewAndReduceKey));
			storage.Environment.CreateTree(tx, storage.MappedResults.GetIndexKey(Tables.MappedResults.Indices.ByViewAndReduceKeyAndSourceBucket));
			storage.Environment.CreateTree(tx, storage.MappedResults.GetIndexKey(Tables.MappedResults.Indices.Data));
		}
示例#12
0
		private static void CreateReduceKeyTypesSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.ReduceKeyTypes.TableName);
			storage.Environment.CreateTree(tx, storage.ReduceKeyTypes.GetIndexKey(Tables.ReduceKeyCounts.Indices.ByView));
		}
示例#13
0
		private static void CreateGeneralSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.General.TableName);
		}
示例#14
0
		private static void CreateScheduledReductionsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.ScheduledReductions.TableName);
			storage.Environment.CreateTree(tx, storage.ScheduledReductions.GetIndexKey(Tables.ScheduledReductions.Indices.ByView));
			storage.Environment.CreateTree(tx, storage.ScheduledReductions.GetIndexKey(Tables.ScheduledReductions.Indices.ByViewAndLevelAndReduceKey));
		}
示例#15
0
		private static void CreateStalenessSchema(Transaction tx, TableStorage storage)
		{
		}
示例#16
0
		public void Initialize(IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs)
		{
		    if (generator == null) throw new ArgumentNullException("generator");
		    if (documentCodecs == null) throw new ArgumentNullException("documentCodecs");

		    uuidGenerator = generator;
		    _documentCodecs = documentCodecs;

		    StorageEnvironmentOptions options = configuration.RunInMemory ?
				CreateMemoryStorageOptionsFromConfiguration(configuration) :
		        CreateStorageOptionsFromConfiguration(configuration);

		    tableStorage = new TableStorage(options, bufferPool);
			var schemaCreator = new SchemaCreator(configuration, tableStorage, Output, Log);
			schemaCreator.CreateSchema();
			schemaCreator.SetupDatabaseIdAndSchemaVersion();
			schemaCreator.UpdateSchemaIfNecessary();

		    SetupDatabaseId();
		}
示例#17
0
		private static void CreateTasksSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.Tasks.TableName);
			storage.Environment.CreateTree(tx, storage.Tasks.GetIndexKey(Tables.Tasks.Indices.ByIndexAndType));
			storage.Environment.CreateTree(tx, storage.Tasks.GetIndexKey(Tables.Tasks.Indices.ByType));
			storage.Environment.CreateTree(tx, storage.Tasks.GetIndexKey(Tables.Tasks.Indices.ByIndex));
		}
示例#18
0
		private static void CreateListsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.Lists.TableName);
			storage.Environment.CreateTree(tx, storage.Lists.GetIndexKey(Tables.Lists.Indices.ByName));
			storage.Environment.CreateTree(tx, storage.Lists.GetIndexKey(Tables.Lists.Indices.ByNameAndKey));
		}
示例#19
0
		private static void CreateQueuesSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.Queues.TableName);
			storage.Environment.CreateTree(tx, storage.Queues.GetIndexKey(Tables.Queues.Indices.ByName));
			storage.Environment.CreateTree(tx, storage.Queues.GetIndexKey(Tables.Queues.Indices.Data));
		}
示例#20
0
		public void Initialize(IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs)
		{
		    if (generator == null) throw new ArgumentNullException("generator");
		    if (documentCodecs == null) throw new ArgumentNullException("documentCodecs");

		    uuidGenerator = generator;
		    _documentCodecs = documentCodecs;

		    StorageEnvironmentOptions options = configuration.RunInMemory ?
				CreateMemoryStorageOptionsFromConfiguration(configuration) :
		        CreateStorageOptionsFromConfiguration(configuration);

			options.OnScratchBufferSizeChanged += size =>
			{
				if (configuration.Storage.Voron.ScratchBufferSizeNotificationThreshold < 0)
					return;

				if (size < configuration.Storage.Voron.ScratchBufferSizeNotificationThreshold * 1024L * 1024L)
					return;

				RunTransactionalStorageNotificationHandlers();
			};

			tableStorage = new TableStorage(options, bufferPool);
			var schemaCreator = new SchemaCreator(configuration, tableStorage, Output, Log);
			schemaCreator.CreateSchema();
			schemaCreator.SetupDatabaseIdAndSchemaVersion();
            if (!configuration.Storage.PreventSchemaUpdate)
			    schemaCreator.UpdateSchemaIfNecessary();

		    SetupDatabaseId();
		}
示例#21
0
		private static void CreateLastIndexedEtagsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.LastIndexedEtags.TableName);
		}
示例#22
0
		public abstract void Update(TableStorage tableStorage, Action<string> output);
示例#23
0
		private static void CreateIndexingStatsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.IndexingStats.TableName);
		}
示例#24
0
		private static void CreateDetailsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.Details.TableName);
		}
示例#25
0
		private static void CreateDocumentsSchema(Transaction tx, TableStorage storage)
		{
			storage.Environment.CreateTree(tx, Tables.Documents.TableName);
			storage.Environment.CreateTree(tx, storage.Documents.GetIndexKey(Tables.Documents.Indices.KeyByEtag));
			storage.Environment.CreateTree(tx, storage.Documents.GetIndexKey(Tables.Documents.Indices.Metadata));
		}
		public StalenessStorageActions(TableStorage tableStorage, Reference<SnapshotReader> snapshot, Reference<WriteBatch> writeBatch, IBufferPool bufferPool)
			: base(snapshot, bufferPool)
		{
			this.tableStorage = tableStorage;
			this.writeBatch = writeBatch;
		}
示例#27
0
		public void Initialize(IUuidGenerator generator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs)
		{
		    if (generator == null) throw new ArgumentNullException("generator");
		    if (documentCodecs == null) throw new ArgumentNullException("documentCodecs");

		    uuidGenerator = generator;
		    _documentCodecs = documentCodecs;

		    StorageEnvironmentOptions options = configuration.RunInMemory ?
		        StorageEnvironmentOptions.CreateMemoryOnly() :
		        CreateStorageOptionsFromConfiguration(configuration);

		    tableStorage = new TableStorage(options, bufferPool);
		    SetupDatabaseId();
		}