Instantly share code, notes, and snippets.

View sort-warnings.rb
#!/usr/bin/env ruby
require 'forwardable'
FLIP_PATTERN = /^(?:(?<file>\w+\.c(?:pp)?):\d+:\d+: warning: )|(?:In file included from (?<file>\w+\.c(?:pp)?):\d+:)/
FLOP_PATTERN = /^\d+ warnings? generated\.$/
class Warnings
include Enumerable
View timing.md
n\time (ms) \branch 5X moving avg backport patch
16384 53.453 1694.091
32768 95.186 6640.734
65536 187.03 28848.276
131072 398.689 113056.203
262144 809.299 459619.552
524288 1813.492 1876957.178
1048576 4751.661 7464597.714
View dell.bash
# TODO: clang apt source
# TODO: docker apt source
sudo aptitude install -y vim-gnome fish cmake ninja-build g++ ccache libxerces-c-dev- git parallel clang-tidy-6.0 clang-format-6.0 pigz p7zip-full p7zip-rar rename git-cvs patchelf shellcheck- clang-6.0 lld-6.0 direnv
# TODO: extract shellcheck probably from Docker Hub?
View iterate.fish
xargs --verbose --no-run-if-empty -n1 --arg-file ~/src/d/naughty-booleans-sources.txt clang-query-6.0 -f (egrep -v '^//' ~/src/d/naughty-booleans-clang-query.txt | psub)
parallel --no-run-if-empty --keep-order -n1 --arg-file ~/src/d/naughty-booleans-sources.txt clang-query-6.0 --extra-arg="-fcolor-diagnostics" -f (egrep -v '^//' ~/src/d/naughty-booleans-clang-query.txt | psub)
View generate_reflow_diff.bash
#!/bin/bash
set -e -u
_main() {
cat > .clang-format <<YAML
---
Language: Cpp
BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: None
View uber_headers.txt
Jesses-MacBook-Air ~/s/p/gporca (master=)> git describe --tags
v2.55.8
Jesses-MacBook-Air ~/s/p/gporca (master=)> ninja -C build -t deps | grep -F ../ | grep -v -F libgpos | sort | uniq -c | sort -nr
897 ../libnaucrates/include/naucrates/dxl/gpdb_types.h
895 ../libnaucrates/include/naucrates/md/IMDId.h
881 ../libnaucrates/include/naucrates/dxl/operators/CDXLDatum.h
876 ../libnaucrates/include/naucrates/md/CDXLStatsDerivedRelation.h
876 ../libnaucrates/include/naucrates/md/CDXLStatsDerivedColumn.h
876 ../libnaucrates/include/naucrates/md/CDXLBucket.h
871 ../libnaucrates/include/naucrates/dxl/operators/CDXLOperator.h
View dtrace.sh
# wait for gporca_test to launch
dtrace -xmangled -n 'pid$target::__ZN4gpos9CRefCount6AddRefEv:entry { @["AddRef"]=count(); }' -W gporca_test
# list all probes
dtrace -xmangled -l -n 'pid$target:gporca_test::' -n 'pid$target:libgpopt.3.dylib::' -n 'pid$target:libnaucrates.3.dylib::' -n 'pid$target:libgpdbcost.3.dylib::' -n 'pid$target:libgpos.3.dylib::' -p (pgrep gporca_test) > /tmp/gporca_test_probes.txt
# dynamically trace an already running orca process
dtrace -xmangled -n 'pid$target::__ZN4gpos9CRefCount6AddRefEv:return { @["AddRef"]=count(); }' -p (pgrep gporca_test)
View DQA.md

Query

DDL:

CREATE TABLE foo (a int, b int, c int) DISTRIBUTED BY (a);

Query:

SELECT aggfn(DISTINCT b) FROM foo;
View split_row.sql
CREATE TABLE rank_exc(
id int,
year int,
gender char(1)
)
DISTRIBUTED BY (id)
PARTITION BY LIST (gender)
SUBPARTITION BY RANGE (year)
SUBPARTITION TEMPLATE (
SUBPARTITION year1 START (2001),
View CXX11_and_ORCA.md

Mordern C++

New language features that may boost productivity

  1. rvalue references, move assignment operator, and move constructors
  2. (using type aliases)[http://en.cppreference.com/w/cpp/language/type_alias]
  3. range-based for-loops
  4. auto
  5. Variadic templates

Standardized features that were GCC extensions