コード例 #1
0
        public Table GetCountersTable(Transaction tx, CollectionName collection)
        {
            var tableName = collection.GetTableName(CollectionTableType.Counters);

            if (tx.IsWriteTransaction && _tableCreated.Contains(collection.Name) == false)
            {
                // RavenDB-11705: It is possible that this will revert if the transaction
                // aborts, so we must record this only after the transaction has been committed
                // note that calling the Create() method multiple times is a noop
                CountersSchema.Create(tx, tableName, 16);
                tx.LowLevelTransaction.OnDispose += _ =>
                {
                    if (tx.LowLevelTransaction.Committed == false)
                    {
                        return;
                    }

                    // not sure if we can _rely_ on the tx write lock here, so let's be safe and create
                    // a new instance, just in case
                    _tableCreated = new HashSet <string>(_tableCreated, StringComparer.OrdinalIgnoreCase)
                    {
                        collection.Name
                    };
                };
            }

            return(tx.OpenTable(CountersSchema, tableName));
        }
コード例 #2
0
        public Table GetCountersTable(Transaction tx, CollectionName collection)
        {
            var tableName = collection.GetTableName(CollectionTableType.Counters);

            if (tx.IsWriteTransaction && _tableCreated.Add(collection.Name))
            {
                CountersSchema.Create(tx, tableName, 32);
            }

            return(tx.OpenTable(CountersSchema, tableName));
        }
コード例 #3
0
        private static void DeleteTombstoneIfNeeded(DocumentsOperationContext context, CollectionName collectionName, byte *lowerId, int lowerSize)
        {
            var tombstoneTable = context.Transaction.InnerTransaction.OpenTable(TombstonesSchema, collectionName.GetTableName(CollectionTableType.Tombstones));

            using (Slice.External(context.Allocator, lowerId, lowerSize, out Slice id))
            {
                if (tombstoneTable.ReadByKey(id, out var reader) == false)
                {
                    return;
                }

                if (tombstoneTable.IsOwned(reader.Id))
                {
                    tombstoneTable.Delete(reader.Id);
                    return;
                }

                // this is using a different collection, so we need to handle that.

                collectionName = new CollectionName(TableValueToId(context, (int)TombstoneTable.Collection, ref reader));
                tombstoneTable = context.Transaction.InnerTransaction.OpenTable(TombstonesSchema, collectionName.GetTableName(CollectionTableType.Tombstones));
                tombstoneTable.Delete(reader.Id);
            }
        }
コード例 #4
0
        private static void DeleteTombstoneIfNeeded(DocumentsOperationContext context, CollectionName collectionName, byte *lowerId, int lowerSize)
        {
            var tombstoneTable = context.Transaction.InnerTransaction.OpenTable(TombstonesSchema, collectionName.GetTableName(CollectionTableType.Tombstones));

            using (Slice.External(context.Allocator, lowerId, lowerSize, out Slice id))
            {
                if (tombstoneTable.ReadByKey(id, out var reader) == false)
                {
                    return;
                }

                if (tombstoneTable.IsOwned(reader.Id))
                {
                    tombstoneTable.Delete(reader.Id);
                }
            }
        }