Skip to content

Instantly share code, notes, and snippets.

View royguo's full-sized avatar

Roy Guo royguo

  • Bytedance
  • Beijing
View GitHub Profile
#include "io_engine.h"
namespace demo {
Status PosixAIOEngine::AsyncWrite(int fd, uint64_t offset, const char* buffer, uint64_t size,
char** cb) {
// TODO Check io_depth
requests_.push_back({.aio_req_ = {}, .type_ = kAsyncWrite});
auto& request = requests_.back();
memset(&request.aio_req_, 0, sizeof(struct aiocb));
@royguo
royguo / policy_aware_cache.cc
Created December 18, 2023 13:39
policy_aware_cache
#include "innovic/cache/policy_aware_cache.h"
#include <iostream>
#include <memory>
namespace innovic {
namespace cache {
void DRAMStore::Put(const std::string &key, std::shared_ptr<CachedValue> value) {
std::unique_lock<std::shared_mutex> write_lock(map_mutex_);
// Item exist
CMake ../ -DCMAKE_BUILD_TYPE=RelWithDebInfo 
          -DWITH_ZENFS=ON 
          -DWITH_TERARK_ZIP=OFF
          -DWITH_BYTEDANCE_METRICS=OFF
          -DWITH_TOOLS=ON
          -DWITH_TESTS=OFF
@royguo
royguo / mapsun.hpp
Last active December 23, 2018 09:23
test demo
// https://www.lintcode.com/problem/map-sum-pairs/description
class MapSum {
class TrieNode {
public:
unordered_map<char, TrieNode*> children;
int val = 0;
TrieNode() {}
TrieNode(const int& val) : val(val) {
@royguo
royguo / wiki-media.sql
Created June 15, 2017 04:26
WIKI Media SQL Schema
-- SQL to create the initial tables for the MediaWiki database.
-- This is read and executed by the install script; you should
-- not have to run it by itself unless doing a manual install.
-- This is a shared schema file used for both MySQL and SQLite installs.
--
-- For more documentation on the database schema, see
-- https://www.mediawiki.org/wiki/Manual:Database_layout
--
-- General notes:
jstests/aggregation/mongos_slaveok.js
jstests/aggregation/testshard1.js
jstests/aggregation/testSlave.js
jstests/aggregation/bugs/match.js
jstests/aggregation/bugs/server19095.js
jstests/aggregation/bugs/server21632.js
jstests/aggregation/bugs/server6118.js
jstests/aggregation/bugs/server6125.js
jstests/aggregation/bugs/server6179.js
jstests/aggregation/bugs/server6556.js
#include <iostream>
#include <terark/db/db_table.hpp>
#include <terark/io/MemStream.hpp>
#include <terark/io/DataIO.hpp>
#include <terark/io/RangeStream.hpp>
#include <terark/lcast.hpp>
#include "user.hpp"
package main;
import java.util.concurrent.atomic.AtomicReference;
public class CASCalculator extends CalculatorBase {
private enum Status {
NOT_STARTED,
STARTED,
DISPOSED
@royguo
royguo / Leaves.java
Last active December 30, 2015 08:29
Java Mail using Playframework
package controllers.oa;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import models.oa.Leave;
import models.oa.Vacation;
import models.system.User;
@royguo
royguo / BufferTest.java
Created July 16, 2013 08:16
双Buffer切换的一个Java小实验
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class BufferTest {
private static volatile List<String> list = new ArrayList<String>();
public static void init() {