Skip to content

Instantly share code, notes, and snippets.

@bkietz
bkietz / annotate_arrow.py
Created September 10, 2024 20:06
Basic utility for annotating .arrow files
import click
import struct
import textwrap
import subprocess
import os
import json
from pathlib import Path
CONTINUATION_FORMAT = "<ii"
@bkietz
bkietz / Asserts.c
Created August 14, 2024 15:22
flatcc requires even empty vectors are aligned
#include <assert.h>
#include <stdio.h>
#include "nanoarrow/ipc/flatcc_generated.h"
static const char dump[] = {
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00,
0x0e, 0x00, 0x06, 0x00, 0x05, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x00, 0x03, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x00,
@bkietz
bkietz / find_first.hxx
Last active September 21, 2023 21:04
C++17 string search with SSE4.2's `_mm_cmpistrm`
#if defined(__SSE4_2__)
#if defined(__has_builtin)
#if __has_builtin(__builtin_ctz)
#include <immintrin.h>
#include <cstring>
#define ARROW_TOO_SIMD_FIND_FIRST_OF
#endif
@bkietz
bkietz / LICENSE.txt
Created July 7, 2023 00:45
Minimal std::ostream which outputs to a fixed span of `char`
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
@bkietz
bkietz / LICENSE.txt
Created June 23, 2023 13:08
Minimal C++17 utility for writing `concept`-like checks
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
@bkietz
bkietz / CMakeLists.txt
Created August 8, 2022 21:20
backward trace from all threads
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.18)
project(backward_trace_all_threads)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Threads)
enable_testing()
add_executable(main main.cc)
target_link_libraries(main Threads::Threads dw)
@bkietz
bkietz / LICENSE.txt
Last active May 8, 2023 13:08
Tiny C++17 zip ranges utility
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
@bkietz
bkietz / float_ord_usage.cc
Last active August 16, 2021 15:06
A simple function for configuring and disambiguating the ordering of floating point numbers
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <optional>
#include <vector>
enum NanOrdering {
/// Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)
#include <tuple>
#include <cassert>
#include "reflection.h"
struct Person {
std::string name;
int age;
@bkietz
bkietz / kms_design.md
Last active November 15, 2020 20:56
A proposal for a KMS interaction API in parquet-cpp