This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BufFileReader | |
| : public ISerializer | |
| { | |
| private: | |
| int fd; | |
| uint64_t chunkOffset; | |
| uint64_t chunkSize; | |
| uint64_t chunkEnd; | |
| uint64_t offset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int8_t TryAppend(const ColumnFamily *__restrict const self, const ColumnFamily *__restrict const cf, colNameCmpProc_t cmpProc) | |
| { | |
| const uint32_t cfColumnsCnt = cf->columns.Size(); | |
| if (unlikely(cfColumnsCnt == 0)) | |
| return 0; | |
| const uint32_t selfColumnsCnt = self->columns.Size(); | |
| if (unlikely(selfColumnsCnt == 0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct IColumn | |
| : public RefCounted<IColumn>, public IExpirable | |
| { | |
| column_name name; | |
| }; | |
| struct IColumnsContainer | |
| : public IColumn | |
| { | |
| Vector<IColumn *, ReleaseRefDestructor> columns; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct NPC | |
| { | |
| uint8_t activeScale; // higher => will execute more logic / TICK | |
| void AdjustActivityScale(const float normalizedDistanceFromPC) // Clamped to 0...1 | |
| { | |
| activeScale = normalizedDistanceFromPC * 10.0; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A simple std::function alternative. | |
| // You can use e.g variadic templates to support arbitrary signatures, but this here demonstrates how | |
| // type erasure makes it possible to wrap any callable function | |
| // | |
| // type erasure is a nifty C++ pattern. There are alternatives to it, but this is usually a better fit. | |
| // | |
| // move/copy constructors and assignemnt operators not implemented, but trivial to do so anyway | |
| // May be worth using e.g std::unique_ptr or whatever for ref-counted wrapped object for sharing, but should | |
| // also be trivial to implement. Apparenly you need a few different alternative implementations to satisfy different | |
| // requirements; can't practically have one impl. for everything. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename T> | |
| void SimpleMovingAverage(const T *const timeSeries, const uint32_t timeSeriesCnt, const uint32_t windowSize, Vector<T> &res) | |
| { | |
| T window[128], sum = 0; | |
| uint8_t windowIndex, windowBase = 0; | |
| uint32_t i = 0; | |
| const auto n = Min<uint32_t>(timeSeriesCnt, windowSize - 1); | |
| runtime_assert(windowSize <= ARRAY_SIZE(window), "Too large window"); | |
| static_assert((ARRAY_SIZE(window)&(ARRAY_SIZE(window) - 1)) == 0, "window size not base 2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int SwitchFS::EnumResidentVMAs(const uint8_t *const base, const uint64_t size, const uint8_t *offset, uint64_t len, std::function<void(const uint8_t *, const uint64_t)> cb) | |
| { | |
| #ifdef SWITCH_OS_LINUX | |
| static const uint32_t pageSize = getpagesize(); | |
| #else | |
| static const uint32_t pageSize = sysconf(_SC_PAGESIZE); | |
| #endif | |
| const uint8_t *const end = offset + len; | |
| const uint8_t *const upto = base + Min<uint64_t>(size, ALIGNUP_TO_POWEROF2BOUNDARY((uint64_t)(uintptr_t)(end - base), pageSize)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int SSTable::VMResidentRows(Vector<token_t> *const out) const | |
| { | |
| uint8_t *const fileData = (uint8_t *)mmapReader->Data(); | |
| Vector<token_offset> tokens; | |
| tokens.EnsureCapacity(metadata.rowsCnt); | |
| if (offsetSize == 8) | |
| { | |
| for (const uint8_t *indexIt = fileData + indexChunkOffset, *const indexEnd = indexIt + indexChunkSize; indexIt != indexEnd; ) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (const auto cnt = rowsToWarmup.Size()) | |
| { | |
| int fd = open(finalPath, O_RDONLY|O_LARGEFILE); | |
| const row *const all = rowsToWarmup.Values(); | |
| const auto shift = __builtin_ffs(getpagesize()) - 1; | |
| volatile uint32_t ac = 0; | |
| const auto before = Timings::Microseconds::Tick(); | |
| if (unlikely(fd == -1)) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <elf.h> | |
| // Scans an ELF DLL/DSO looking for globally epxorted symbols/objects of type object or function | |
| // Very useful for e.g application servers or games where you don't really want to pre-define those functions/objects in e.g a list | |
| // and instead you can define them in any file that makes up the module. That way you will scan them and identfiy what you need and load it later | |
| // | |
| // e.g | |
| // EnumDynSyms("AppServerModules/search.dso", [](const char *const name, const uint8_t type) | |
| // { |
OlderNewer