• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Voron.Slice类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Voron.Slice的典型用法代码示例。如果您正苦于以下问题:C# Slice类的具体用法?C# Slice怎么用?C# Slice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Slice类属于Voron命名空间,在下文中一共展示了Slice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Flush

        public void Flush()
        {
            _bufferSize = 0;

            using (var tx = _storageEnvironment.NewTransaction(TransactionFlags.ReadWrite))
            {
                foreach (var kvp in _buffer)
                {
                    var data = _storageEnvironment.CreateTree(tx, "channel:" + kvp.Key);
                    var buffer = new byte[16];
                    var key = new Slice(buffer);
                    var ms = new MemoryStream();
                    var bw = new BinaryWriter(ms);
                    foreach (var item in kvp.Value)
                    {
                        var date = item.Timestamp;
                        EndianBitConverter.Big.CopyBytes(date.Ticks, buffer, 0);
                        EndianBitConverter.Big.CopyBytes(_last++, buffer, 8);
                        ms.SetLength(0);
                        bw.Write(item.Value);
                        ms.Position = 0;

                        data.Add(tx, key, ms);
                    }
                }

                tx.State.Root.Add(tx, _lastKey, new MemoryStream(BitConverter.GetBytes(_last)));
                tx.Commit();
            }
            _buffer.Clear();
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:31,代码来源:DateTimeSeries.cs


示例2: Accept

		public override void Accept(Disk d)
		{
			var ms = new MemoryStream();
			_serializer.Serialize(new JsonTextWriter(new StreamWriter(ms)), d);
			ms.Position = 0;
			var key = new Slice(EndianBitConverter.Big.GetBytes(counter++));
			_currentBatch.Add(key, ms, "albums");

			foreach (var diskId in d.DiskIds)
			{
				_currentBatch.MultiAdd(diskId, key, "ix_diskids");
			}

			if(d.Artist != null)
				_currentBatch.MultiAdd(d.Artist.ToLower(), key, "ix_artists");
			if (d.Title != null)
				_currentBatch.MultiAdd(d.Title.ToLower(), key, "ix_titles");

			if (counter%1000 == 0)
			{
				_storageEnvironment.Writer.Write(_currentBatch);
				_currentBatch = new WriteBatch();
			}

		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:25,代码来源:VoronDisksDestination.cs


示例3: SetInline

 public static void SetInline(Slice slice, NodeHeader* node)
 {
     slice.Pointer = (byte*)node + Constants.NodeHeaderSize;
     slice.Size = node->KeySize;
     slice.KeyLength = node->KeySize;
     slice.Array = null;
 }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:7,代码来源:Slice.cs


示例4: Add

        public virtual void Add(WriteBatch writeBatch, Slice key, byte[] value, ushort? expectedVersion = null)
        {
            var stream = new BufferPoolMemoryStream();
            stream.Write(value, 0, value.Length);
            stream.Position = 0;

            writeBatch.Add(key, stream, TableName, expectedVersion);
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:TableBase.cs


示例5: PrefixedSlice

 public PrefixedSlice()
 {
     Options = SliceOptions.Key;
     Size = 0;
     KeyLength = 0;
     Header = new PrefixedSliceHeader();
     NonPrefixedData = new Slice(SliceOptions.Key);
 }
开发者ID:jesuslpm,项目名称:ravendb,代码行数:8,代码来源:PrefixedSlice.cs


示例6: Add

		public virtual void Add(WriteBatch writeBatch, Slice key, RavenJToken value, ushort? expectedVersion = null)
		{
            var stream = new BufferPoolMemoryStream(BufferPool);
            value.WriteTo(stream);
            stream.Position = 0;

			writeBatch.Add(key, stream, TableName, expectedVersion);
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:8,代码来源:TableBase.cs


示例7: Compare

		public static int Compare(Slice x, PrefixedSlice y, SliceComparer cmp, ushort size)
		{
			fixed (byte* p1 = x.Array)
			fixed (byte* p2 = y.NonPrefixedData.Array)
			{
				var xPtr = p1 != null ? p1 : x.Pointer;
				var yPtr = p2 != null ? p2 : y.NonPrefixedData.Pointer;

				if (y.Header.PrefixId == PrefixedSlice.NonPrefixedId)
					return Compare(null, 0, null, 0, xPtr, x.KeyLength, yPtr, y.Header.NonPrefixedDataSize, cmp, size);

				if (x.PrefixComparisonCache == null)
				{
					if(y.Prefix == null)
						return Compare(null, 0, null, 0, xPtr, x.KeyLength, yPtr, y.Header.NonPrefixedDataSize, cmp, size);
					else if (y.Prefix.Value == null)
						return Compare(null, 0, y.Prefix.ValuePtr, y.Header.PrefixUsage, xPtr, x.KeyLength, yPtr, y.Header.NonPrefixedDataSize, cmp, size);
					else
					{
						fixed (byte* prefixVal = y.Prefix.Value)
							return Compare(null, 0, prefixVal, y.Header.PrefixUsage, xPtr, x.KeyLength, yPtr, y.Header.NonPrefixedDataSize, cmp, size);
					}
				}

				var prefixBytesToCompare = Math.Min(y.Header.PrefixUsage, x.KeyLength);

				int r;

				if (x.PrefixComparisonCache.TryGetCachedResult(y.Header.PrefixId, y.Prefix.PageNumber, prefixBytesToCompare, out r) == false)
				{
					if (y.Prefix == null)
						r = Compare(null, 0, null, 0, xPtr, x.KeyLength, null, 0, cmp,
							prefixBytesToCompare);

					else if (y.Prefix.Value == null)
						r = Compare(null, 0, y.Prefix.ValuePtr, y.Header.PrefixUsage, xPtr, x.KeyLength, null, 0, cmp,
							prefixBytesToCompare);
					else
					{
						fixed (byte* prefixVal = y.Prefix.Value)
							r = Compare(null, 0, prefixVal, y.Header.PrefixUsage, xPtr, x.KeyLength, null, 0, cmp,
								prefixBytesToCompare);
					}

					x.PrefixComparisonCache.SetPrefixComparisonResult(y.Header.PrefixId, y.Prefix.PageNumber, prefixBytesToCompare, r);
				}

				if (r != 0)
					return r;

				size -= prefixBytesToCompare;

				return Compare(null, 0, null, 0, xPtr + prefixBytesToCompare, (ushort)(x.KeyLength - prefixBytesToCompare), yPtr, y.Header.NonPrefixedDataSize, cmp, size);
			}
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:55,代码来源:SliceComparisonMethods.cs


示例8: Slice

		public Slice(Slice other, ushort size)
		{
			if (other.Array != null)
				Array = other.Array;
			else
				Pointer = other.Pointer;

			Options = other.Options;
			Size = size;
			KeyLength = size;
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:11,代码来源:Slice.cs


示例9: Initialize

		private void Initialize()
		{
			using (var tx = storageEnvironment.NewTransaction(TransactionFlags.ReadWrite))
			{
				var serverNamesToIds = storageEnvironment.CreateTree(tx, "serverNames->Ids");
				var serverIdsToNames = storageEnvironment.CreateTree(tx, "Ids->serverNames");
				storageEnvironment.CreateTree(tx, "servers->lastEtag");
				storageEnvironment.CreateTree(tx, "counters");
				storageEnvironment.CreateTree(tx, "countersGroups");
				var etags = storageEnvironment.CreateTree(tx, "etags->counters");
				storageEnvironment.CreateTree(tx, "counters->etags");
				
				var metadata = tx.State.GetTree(tx, "$metadata");
				var id = metadata.Read("id");

				if (id == null) // new counter db
				{
					var serverIdBytes = EndianBitConverter.Big.GetBytes(0); // local is always 0
					var serverIdSlice = new Slice(serverIdBytes);
					serverNamesToIds.Add(CounterStorageUrl, serverIdSlice);
					serverIdsToNames.Add(serverIdSlice, CounterStorageUrl);

					Id = Guid.NewGuid();
					metadata.Add("id", Id.ToByteArray());
					metadata.Add("name", Encoding.UTF8.GetBytes(CounterStorageUrl));

					tx.Commit();
				}
				else // existing counter db
				{
					int used;
					Id = new Guid(id.Reader.ReadBytes(16, out used));
					var nameResult = metadata.Read("name");
					if (nameResult == null)
						throw new InvalidOperationException("Could not read name from the store, something bad happened");
					var storedName = new StreamReader(nameResult.Reader.AsStream()).ReadToEnd();

					if (storedName != CounterStorageUrl)
						throw new InvalidOperationException("The stored name " + storedName + " does not match the given name " + CounterStorageUrl);

					using (var it = etags.Iterate())
					{
						if (it.Seek(Slice.AfterAllKeys))
						{
							LastEtag = it.CurrentKey.CreateReader().ReadBigEndianInt64();
						}
					}
				}

                ReplicationTask.StartReplication();
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:52,代码来源:CounterStorage.cs


示例10: Init

        protected override void Init()
        {
            base.Init();

            _positionsTree = Transaction.ReadTree("TermPositions");
            _docsTree = Transaction.ReadTree("Docs");

            _fieldId = Index.GetFieldNumber(Field);
            _prefix = new byte[FullTextIndex.FieldDocumentSize];
            _prefixSlice = new Slice(_prefix);

            _maxKey = new byte[FullTextIndex.FieldDocumentSize];
            _maxKeySlice = new Slice(_maxKey);
        }
开发者ID:votrongdao,项目名称:Corax,代码行数:14,代码来源:PhraseQuery.cs


示例11: LoadJson

 protected RavenJObject LoadJson(Table table, Slice key, WriteBatch writeBatch, out ushort version)
 {
     var read = table.Read(Snapshot, key, writeBatch);
     if (read == null)
     {
         version = table.ReadVersion(Snapshot, key, writeBatch) ?? 0;
         return null;
     } 
     
     using (var stream = read.Reader.AsStream())
     {
         version = read.Version;
         return stream.ToJObject();
     }
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:15,代码来源:StorageActionsBase.cs


示例12: SetupDatabaseIdAndSchemaVersion

		public void SetupDatabaseIdAndSchemaVersion()
		{
			using (var snapshot = storage.CreateSnapshot())
			{
                var idSlice = new Slice("id");
                var schemaVersionSlice = new Slice("schema_version");

				Guid id;
				string schemaVersion;

                var read = storage.Details.Read(snapshot, idSlice, null);
				if (read == null) // new db
				{
					id = Guid.NewGuid();
					schemaVersion = SchemaVersion;
					using (var writeIdBatch = new WriteBatch())
					{
                        storage.Details.Add(writeIdBatch, idSlice, id.ToByteArray());
                        storage.Details.Add(writeIdBatch, schemaVersionSlice, schemaVersion);
						storage.Write(writeIdBatch);
					}
				}
				else
				{
					if (read.Reader.Length != 16) //precaution - might prevent NRE in edge cases
						throw new InvalidDataException("Failed to initialize Voron transactional storage. Possible data corruption. (no db id)");

					using (var stream = read.Reader.AsStream())
					using (var reader = new BinaryReader(stream))
					{
						id = new Guid(reader.ReadBytes((int)stream.Length));
					}

                    var schemaRead = storage.Details.Read(snapshot, schemaVersionSlice, null);
					if (schemaRead == null)
						throw new InvalidDataException("Failed to initialize Voron transactional storage. Possible data corruption. (no schema version)");

					schemaVersion = schemaRead.Reader.ToStringValue();
				}

				storage.SetDatabaseIdAndSchemaVersion(id, schemaVersion);
			}
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:43,代码来源:SchemaCreator.cs


示例13: PrefixedSlice

		public PrefixedSlice(NodeHeader* node)
		{
			if (node->KeySize > 0)
			{
				var prefixHeaderPtr = (PrefixedSliceHeader*)((byte*)node + Constants.NodeHeaderSize);
				Header = *prefixHeaderPtr;

				NonPrefixedData = new Slice((byte*)prefixHeaderPtr + Constants.PrefixedSliceHeaderSize, Header.NonPrefixedDataSize);

				Size = node->KeySize;
				KeyLength = (ushort) (Header.PrefixUsage + Header.NonPrefixedDataSize);
			}
			else
			{
				Size = 0;
				KeyLength = 0;
			}

			Options = SliceOptions.Key;
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:20,代码来源:PrefixedSlice.cs


示例14: Accept

        public override int Accept(string d)
        {
            var disk = JObject.Parse(d);

            var ms = new MemoryStream();
            var writer = new StreamWriter(ms);
            writer.Write(d);
            writer.Flush();
            ms.Position = 0;
            var key = new Slice(EndianBitConverter.Big.GetBytes(counter++));
            _currentBatch.Add(key, ms, "albums");
            int count = 1;

            foreach (var diskId in disk.Value<JArray>("DiskIds"))
            {
                count++;
                _currentBatch.MultiAdd(diskId.Value<string>(), key, "ix_diskids");
            }

            var artist = disk.Value<string>("Artist");
            if (artist != null)
            {
                count++;
                _currentBatch.MultiAdd(artist.ToLower(), key, "ix_artists");
            }
            var title = disk.Value<string>("Title");
            if (title != null)
            {
                count++;
                _currentBatch.MultiAdd(title.ToLower(), key, "ix_titles");
            }

            if (counter % 500 == 0)
            {
                _storageEnvironment.Writer.Write(_currentBatch);
                _currentBatch = new WriteBatch();
            }
            return count;
        }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:39,代码来源:VoronEntriesDestination.cs


示例15: WriteDocumentMetadata

        //returns true if it was update operation
        private bool WriteDocumentMetadata(JsonDocumentMetadata metadata, Slice key, bool shouldIgnoreConcurrencyExceptions = false)
        {
            var metadataStream = CreateStream();

            metadataStream.Write(metadata.Etag);
            metadataStream.Write(metadata.Key);

            if (metadata.LastModified.HasValue)
                metadataStream.Write(metadata.LastModified.Value.ToBinary());
            else
                metadataStream.Write((long)0);

            metadata.Metadata.WriteTo(metadataStream);

            metadataStream.Position = 0;

            ushort? existingVersion;
            var isUpdate = metadataIndex.Contains(Snapshot, key, writeBatch.Value, out existingVersion);
            metadataIndex.Add(writeBatch.Value, key, metadataStream, existingVersion, shouldIgnoreConcurrencyExceptions);

            return isUpdate;
        }
开发者ID:hero106wen,项目名称:ravendb,代码行数:23,代码来源:DocumentsStorageActions.cs


示例16: PutDocumentMetadataInternal

 private bool PutDocumentMetadataInternal(string key, Slice normalizedKey, RavenJObject metadata, Etag newEtag, DateTime savedAt)
 {
     return WriteDocumentMetadata(new JsonDocumentMetadata
     {
         Key = key,
         Etag = newEtag,
         Metadata = metadata,
         LastModified = savedAt
     }, normalizedKey);
 }
开发者ID:hero106wen,项目名称:ravendb,代码行数:10,代码来源:DocumentsStorageActions.cs


示例17: Contains

		public bool Contains(SnapshotReader snapshot, Slice key, WriteBatch writeBatch, out ushort? version)
		{
			return snapshot.Contains(TableName, key, out version, writeBatch);
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:4,代码来源:TableBase.cs


示例18: MultiRead

		public virtual IIterator MultiRead(SnapshotReader snapshot, Slice key)
		{
			return snapshot.MultiRead(TableName, key);
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:4,代码来源:TableBase.cs


示例19: Read

		public virtual ReadResult Read(SnapshotReader snapshot, Slice key, WriteBatch writeBatch)
		{
			return snapshot.Read(TableName, key, writeBatch);
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:4,代码来源:TableBase.cs


示例20: Increment

		public virtual void Increment(WriteBatch writeBatch, Slice key, long delta, ushort? expectedVersion = null)
		{
			writeBatch.Increment(key, delta, TableName, expectedVersion);
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:4,代码来源:TableBase.cs



注:本文中的Voron.Slice类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Impl.Transaction类代码示例发布时间:2022-05-26
下一篇:
C# Basement.DataEntities类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap