Exemplo n.º 1
0
        public int GetNextIdForTable(Table table)
        {
            if (!tableIds.ContainsKey(table.TableName))
                throw new InvalidOperationException(string.Format("Id generation has not been configured for table '{0}'.", table.TableName));

            return tableIds.AddOrUpdate(table.TableName, s =>
            {
                throw new NotSupportedException();
            }, (s, l) => l + 1);
        }
Exemplo n.º 2
0
        private static int ReadLastIdFromTable(Table table, SnapshotReader snapshot)
        {
            using (var iterator = table.Iterate(snapshot, null))
            {
                if (!iterator.Seek(Slice.AfterAllKeys))
                    return 0;

                var id = iterator.CurrentKey.ToString();
                return int.Parse(id);
            }
        }
Exemplo n.º 3
0
		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();
			}
		}
Exemplo n.º 4
0
 private void Initialize()
 {
     Files = new Table(Tables.Files.TableName, bufferPool);
     Signatures = new Table(Tables.Signatures.TableName, bufferPool, Tables.Signatures.Indices.ByName);
     Config = new Table(Tables.Config.TableName, bufferPool);
     Usage = new Table(Tables.Usage.TableName, bufferPool);
     Pages = new Table(Tables.Pages.TableName, bufferPool, Tables.Pages.Indices.Data, Tables.Pages.Indices.ByKey);
     Details = new Table(Tables.Details.TableName, bufferPool);
 }