Beispiel #1
0
 public Engine(Shard shard, string path, string walPath)
 {
     this.shard              = shard;
     this.path               = path;
     wal                     = new Wal(walPath);
     fileStore               = new FileStore(path);
     cache                   = new Cache(Constants.DefaultCacheMaxMemorySize);
     compactor               = new Compactor(fileStore, path);
     compactionPlan          = new DefaultPlanner(fileStore, Constants.DefaultCompactFullWriteColdDuration);
     enableCompactionsOnOpen = true;
     stats                   = new EngineStatistics();
 }
Beispiel #2
0
        private CompactorViewModel GetModel(Compactor compactorViewModel)
        {
            CompactorViewModel compactor = new CompactorViewModel()
            {
                CompactorNumber = compactorViewModel.CompactorNumber,
                Id         = compactorViewModel.Id,
                LocationId = compactorViewModel.LocationId,
                Make       = compactorViewModel.Make,
                Size       = compactorViewModel.Size
            };

            return(compactor);
        }
    public override void _EnterTree()
    {
        compactor = (Compactor)building;

        blocksSelector = GetNode <ItemList>("back/BlocksList");

        imageDesc       = GetNode <TextureRect>("back/BlockDescription/ImageBlock/TextureRect");
        titleDesc       = GetNode <Label>("back/BlockDescription/Description/HBox/Title");
        energyDesc      = GetNode <Label>("back/BlockDescription/Description/HBox/Energy");
        descriptionDesc = GetNode <Label>("back/BlockDescription/Description/Description");
        itemListDesc    = GetNode <Control>("back/BlockDescription/Description/Items");

        btnCompact = GetNode <Button>("back/BlockDescription/BtnCompact");

        InitBlocksSelector();
        _on_BlocksList_item_selected(0);
        RefreshBtnCompact();
    }
Beispiel #4
0
 public void Save(CompactorViewModel compactorViewModel)
 {
     using (var _context = new NasscomEntities())
     {
         Compactor compactor = _context.Compactor.Find(compactorViewModel.Id);
         if (compactor != null)
         {
             compactor.CompactorNumber = compactorViewModel.CompactorNumber;
             compactor.LocationId      = compactorViewModel.LocationId;
             compactor.Make            = compactorViewModel.Make;
             compactor.Size            = compactorViewModel.Size;
         }
         else
         {
             _context.Compactor.Add(GetEntity(compactorViewModel));
         }
         _context.SaveChanges();
     }
 }
        public async Task Get_Games_As_Existing_User_With_Game()
        {
            // Arrange
            var expected = "123";
            var user     = new AuthenticatedUser()
            {
                Name = "abc",
                PreferredUsername  = "******",
                UserIdentifier     = "u",
                ProviderIdentifier = "p"
            };

            var compactor = new Compactor();
            await _context.UpsertAsync(TableNames.Users, new UserEntity()
            {
                PartitionKey = "u",
                RowKey       = "p",
                UserID       = "user123"
            });

            await _context.UpsertAsync(TableNames.GamesWaitingForYou, new GameEntity()
            {
                PartitionKey = "user123",
                RowKey       = "123",
                Data         = compactor.Compact(new MyChessGame()
                {
                    ID = "123"
                })
            });

            // Act
            var actual = await _gamesHandler.GetGameAsync(user, "123", null);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(expected, actual?.ID);
        }
        public async Task Move_Game_To_Archive()
        {
            // Arrange
            var expectedWaitingForYou      = 0;
            var expectedWaitingForOpponent = 0;
            var expectedArchive            = 2;

            var user1 = new AuthenticatedUser()
            {
                Name = "abc",
                PreferredUsername  = "******",
                UserIdentifier     = "u1",
                ProviderIdentifier = "p1"
            };

            // Player creating the game
            await _context.UpsertAsync(TableNames.Users, new UserEntity()
            {
                PartitionKey = "u1",
                RowKey       = "p1",
                UserID       = "user123"
            });

            await _context.UpsertAsync(TableNames.UserID2User, new UserID2UserEntity()
            {
                PartitionKey   = "user123",
                RowKey         = "user123",
                UserPrimaryKey = "u1",
                UserRowKey     = "p1"
            });

            // Opponent
            await _context.UpsertAsync(TableNames.Users, new UserEntity()
            {
                PartitionKey = "u2",
                RowKey       = "p2",
                UserID       = "user456"
            });

            var game = new MyChessGame
            {
                ID = "aaa"
            };

            game.Players.White.ID = "user123";
            game.Players.Black.ID = "user456";
            var moves = new string[]
            {
                "E2E4", // White Pawn
                "A7A6", // Black Pawn
                "F1C4", // White Bishop
                "H7H6", // Black Pawn
                "D1F3", // White Queen
                "A6A5"  // Black Pawn
            };

            foreach (var m in moves)
            {
                game.Moves.Add(new MyChessGameMove()
                {
                    Move = m
                });
            }

            var compactor = new Compactor();
            var data      = compactor.Compact(game);
            await _context.UpsertAsync(TableNames.GamesWaitingForYou, new GameEntity()
            {
                PartitionKey = "user123",
                RowKey       = "aaa",
                Data         = data
            });

            // White Queen
            var finalMove = new MyChessGameMove()
            {
                Move = "F3F7"
            };

            // Act
            var actual = await _gamesHandler.AddMoveAsync(user1, "aaa", finalMove);

            // Assert
            Assert.Null(actual);
            var actualWaitingForYou      = _context.Tables[TableNames.GamesWaitingForYou].Count;
            var actualWaitingForOpponent = _context.Tables[TableNames.GamesWaitingForOpponent].Count;
            var actualWaitingArchive     = _context.Tables[TableNames.GamesArchive].Count;

            Assert.Equal(expectedWaitingForYou, actualWaitingForYou);
            Assert.Equal(expectedWaitingForOpponent, actualWaitingForOpponent);
            Assert.Equal(expectedArchive, actualWaitingArchive);
        }
Beispiel #7
0
 void Awake()
 {
     Instance   = this;
     _compactor = FindObjectOfType <Compactor>();
 }
Beispiel #8
0
 public CompactorTests()
 {
     _compactor = new Compactor();
 }
Beispiel #9
0
        static int Main(string[] args)
        {
            var compactor = new Compactor();

            var returnValue = 0;

            compactor.EmitLineDirectives = false;
            compactor.Minify             = false;

            if (args.Length == 3 || args.Length == 4)
            {
                var target        = args[0];
                var directoryPath = args[1];

                var forZilch = (target == "-Zilch");
                var forZero  = !forZilch;

                var zeroPath  = directoryPath;
                var zilchPath = directoryPath;

                if (forZero)
                {
                    zilchPath = Path.Combine(directoryPath, @"ZeroLibraries\Zilch");
                }

                compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(zilchPath, @"Project\Zilch"), "*.cpp");

                var standardLibraries = Path.Combine(zilchPath, @"Project\StandardLibraries");

                if (forZero)
                {
                    standardLibraries = Path.Combine(zeroPath, @"ZeroLibraries");
                }

                compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(standardLibraries, @"Common"), "*.cpp");
                compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(standardLibraries, @"Math"), "*.cpp");
                compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(standardLibraries, @"Platform"), "*.cpp", false);

                // These files get conditionally included into the 'Debugging.cpp'
                compactor.FilesToProcess.RemoveFilesByName("DebuggingWindows.cpp");
                compactor.FilesToProcess.RemoveFilesByName("DebuggingGeneric.cpp");

                // At the moment, we don't use regex, so just only include NoRegex.cpp
                compactor.FilesToProcess.RemoveFilesByName("Regex.cpp");

                // We explicitly need to process the platform selector header file first
                compactor.FilesToProcess.Add(Path.Combine(standardLibraries, @"Platform\PlatformSelector.hpp"));

                // Windows platform
                {
                    compactor.DirectoryDirectives.Add(Compactor.NormalizePath(Path.Combine(standardLibraries, @"Platform\Windows")), new CompacterDirectives()
                    {
                        PreprocessorCondition = "defined(PLATFORM_WINDOWS)",
                        CppOnly = true,
                    });
                    compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(standardLibraries, @"Platform\Windows"), "*.cpp");
                }

                // Posix platform
                {
                    compactor.DirectoryDirectives.Add(Compactor.NormalizePath(Path.Combine(standardLibraries, @"Platform\Posix")), new CompacterDirectives()
                    {
                        PreprocessorCondition = "defined(PLATFORM_POSIX)",
                        CppOnly = true,
                    });
                    compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(standardLibraries, @"Platform\Posix"), "*.cpp");
                }

                // Empty platform
                {
                    compactor.DirectoryDirectives.Add(Compactor.NormalizePath(Path.Combine(standardLibraries, @"Platform\Empty")), new CompacterDirectives()
                    {
                        PreprocessorCondition = "defined(PLATFORM_EMSCRIPTEN)",
                        CppOnly = true,
                    });
                    compactor.FilesToProcess.AddFilesFromDirectory(Path.Combine(standardLibraries, @"Platform\Empty"), "*.cpp");
                }

                // This file brings in dependencies upon the engine and other bad things!
                compactor.FilesToProcess.RemoveFilesByName("CrashHandler.cpp");
                compactor.FilesToProcess.RemoveFilesByName("StackWalker.cpp");

                compactor.HppDirectories.Add(Path.Combine(standardLibraries, @"Common"));
                compactor.HppDirectories.Add(standardLibraries);

                var hppPath = args[2];

                var cppPath = String.Empty;
                if (args.Length == 4)
                {
                    cppPath = args[3];
                }

                //var output = Path.Combine(zilchPath, @"Project\ZilchAll\NonCompacted\");
                compactor.Compact(cppPath, hppPath, null);

                Console.WriteLine("Done compacting");
            }
            else
            {
                Console.Error.WriteLine("Expected: <-Zilch or -Zero> <Zilch or Zero directory> <output.hpp> [output.cpp]");
                Console.Error.WriteLine("Given: `" + Environment.CommandLine + "`");
                returnValue = -1;
            }

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press enter to continue...");
                Console.ReadLine();
            }

            if (compactor.WasError)
            {
                returnValue = -1;
            }

            return(returnValue);
        }