Skip to content

Instantly share code, notes, and snippets.

View ayende's full-sized avatar

Ayende Rahien ayende

View GitHub Profile
public IEnumerable<Tuple<long, NameValueCollection>> GetEdgesFor(string type, long id)
{
using(var tx = _env.ReadTransaction())
{
var edgesDataTable = new Table(_emptySchema, "EdgesData", tx);
var edgeTypeTree = tx.CreateTree("Edges_"+ type);
var fixedSizeTree = edgeTypeTree.FixedTreeFor(from, valSize: 8);
using(var it = fixedSizeTree.Iterate())
{
if(it.Seek(Slices.BeforeAllKeys) == false)
public IEnumerable<NameValueCollection> DepthFirstSearch(
long start,
string edgeType,
Func<long, NameValueCollection, bool> nodePredicate,
Func<long, NameValueCollection, bool> edgePredicate)
{
var seen = new HashSet<long>();
var stack = new Stack<long>();
stack.Push(start);
while(stack.Count > 0)
func readRandomDocs(opts BenchOpts) {
if opts.clients > opts.reads {
opts.clients = opts.reads
}
done.Add(opts.clients) // sync.WaitGroup
fmt.Printf("%s random doc reads from %s with %s clients\n",
humanize.Comma(int64(opts.reads)),
baseUrl,
func writeNewDocs(opts BenchOpts) {
if opts.clients > opts.reads {
opts.clients = opts.reads
}
done.Add(opts.clients) // sync.WaitGroup
data, err := ioutil.ReadFile("data.json")
if err != nil {
color.Set(color.FgMagenta, color.Bold)
using (var s1 = store1.OpenSession())
{
s1.Advanced.WaitForReplicationAfterSaveChanges(
timeout: TimeSpan.FromSeconds(30),
throwOnTimeout: true,
replicas: 2,
);
s1.Store(new User {Name = "Oren"}, "users/1");
using (var s = store.OpenSession())
{
s.Advanced.WaitForIndexesAfterSaveChanges(
timeout: TimeSpan.FromSeconds(30)
);
s.Store(new User {Name = "Oren"});
s.SaveChanges();
}
var requestExecuter = _requestExecuters.GetOrAdd(databaseName,
new RequestExecuter(Url, databaseName, ApiKey));
var requestExecuter = _requestExecuters.GetOrAdd(databaseName,
ignored => new RequestExecuter(Url, databaseName, ApiKey)));
var requestExecuter = _requestExecuters.GetOrAdd(databaseName,
dbName => new RequestExecuter(Url, dbName, ApiKey)));
var requestExecuter = _requestExecuters.GetOrAdd(databaseName,
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@ayende
ayende / Program.cs
Last active September 29, 2016 20:46
using System.Linq;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Text;
using System.Threading;
public unsafe class LazyStringParser
{
public enum Result
{
Failed,
DateTime,
DateTimeOffset
}
public static Result TryParseDateTime(byte* buffer, int len, out DateTime dt, out DateTimeOffset dto)