When dealing large data sets that do not fit in memory, it is crucial to limit the number of accesses and iterations over the data set. However, in a high level language it may not be immediately obvious how many iterations a particular program will require. The number of iterations becomes even less obvious in the presence of heuristic and statistics-based optimisations, as used by traditional databases: a small tweak to the query or even modifying the number of rows in a table can cause drastic changes to the query plan.
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
## $FILES is names of all files to be split | |
## splits files into two | |
# find largest file | |
largest=`ls $FILES -l | sort -k5 -nr | head -n1 | awk '{ print $9 }'` | |
# count how many lines in it | |
lines=`wc -l $largest` |
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 <fcntl.h> | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/mman.h> | |
#include <sys/param.h> | |
#include <sys/stat.h> |
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 <x86intrin.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
static const uint32_t powers_of_ten_multipliers[] | |
= { 10000000, 1000000, 100000, 10000 | |
, 1000 , 100 , 10 , 1 | |
, 0 , 0 , 0 , 0 | |
, 0 , 0 , 0 , 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
13> let y : UnsafeMutablePointer<UInt8> = unsafeDowncast(malloc(50)) | |
repl.swift:13:39: error: generic parameter 'T' could not be inferred | |
let y : UnsafeMutablePointer<UInt8> = unsafeDowncast(malloc(50)) | |
^ | |
Swift.unsafeDowncast:12:13: note: in call to function 'unsafeDowncast' | |
public func unsafeDowncast<T : AnyObject>(x: AnyObject) -> T | |
^ | |
13> let y : UnsafeMutablePointer<UInt8> = unsafeDowncast<UnsafeMutablePointer<UInt8>>(malloc(50)) | |
repl.swift:13:39: error: cannot explicitly specialize a generic function |
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
amos@localhost option-test $ swiftc uint.swift && ./main | |
2^62 = 4611686018427387904 | |
2^63 - 1 = 9223372036854775807 | |
Illegal instruction | |
# Running with -Ounchecked gives wrong result.. (last two numbers are same) | |
amos@localhost option-test $ swiftc tx1-uint.swift -Ounchecked && ./main | |
2^62 = 4611686018427387904 | |
2^63 - 1 = 9223372036854775807 | |
2^63 = 9223372036854775807 |
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
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE TypeFamilies #-} | |
class Bonkers b where | |
type Bonkers1 b :: * | |
type Bonkers2 b :: * | |
bonkersFrom :: Bonkers1 b -> Bonkers2 b | |
bonkers' :: Bonkers b => Bonkers1 b -> Bonkers2 b |
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 <stdio.h> | |
void b01_sums(int size, int* A) | |
{ | |
int sum0 = 0; | |
int sum1 = 0; | |
for (int i = 0; i != size; ++i) | |
{ | |
sum0 = sum0 + A[i]; | |
sum1 = sum1 + A[i]; |
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
#!/bin/sh -eu | |
# The version of Lucid Synchrone / Lucy on the website was built a long time ago, and only has bytecode available. | |
# It seems that between ocaml 4.00.1 and 4.00.2, the bytecode format changed, | |
# so you need to use that version. | |
# This should: | |
# install the right version of the compiler (assuming you have opam); | |
# download lucy; | |
# change the shebang of the binaries to point to the right version; | |
# and put lucyc in /usr/local/bin. |
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 haskell parts need to be in separate module, because of staging restriction. | |
-- Use GHC 8, since the VarI constructor changed between 7 and 8. | |
{-# LANGUAGE TemplateHaskell #-} | |
module THStuff where | |
import Language.Haskell.TH | |
-- Try to convert a name into its definition. | |
-- This would be really useful for forcing definitions to be inlined into a particular callsite. | |
get :: Name -> Q Exp | |
get nm = do |