Skip to content

Instantly share code, notes, and snippets.

@ib84
ib84 / RoundRobinJedis
Created July 11, 2011 18:32
Simple Jedis Round Robin
import org.apache.commons.pool.impl.GenericObjectPool;
import redis.clients.jedis.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class RoundRobinJedis {
@ib84
ib84 / RoundRobinPool
Created July 15, 2011 07:51
RoundRobinPool
package redis.clients.jedis;
import org.apache.commons.pool.BasePoolableObjectFactory;
import org.apache.commons.pool.PoolableObjectFactory;
import org.apache.commons.pool.impl.GenericObjectPool;
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.util.Pool;
import java.util.Iterator;
@ib84
ib84 / UniJedis.java
Created August 21, 2011 01:58
UniJedis
package redis.clients.jedis;
import org.apache.commons.pool.impl.GenericObjectPool;
import redis.clients.util.Pool;
import redis.clients.util.SafeEncoder;
import java.util.*;
public class UniJedis2 implements JedisCommands, BinaryJedisCommands {
@ib84
ib84 / ChainableTransaction.java
Created September 8, 2011 12:48
a modified Transaction that is chainable, similar to Builder pattern. For use with UniJedis
package redis.clients.jedis;
import org.hypergraphdb.util.HGUtils;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.util.Pool;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ib84
ib84 / UnifiedJedisScala3.scala
Created October 6, 2011 08:46
UnifiedJedisScala3 - testing scala to remove massive code duplication of previous versions
package test
import redis.clients.util.Pool
import redis.clients.jedis._
class UnifiedJedisScala3 {
val readPool: Pool[Jedis]
val masterPool: Pool[Jedis]
val currentDB: Int = 0;
val redundancySwitch: Int = 3;
@ib84
ib84 / Text.scala
Created February 29, 2012 11:36
recursive text type
package test
import scala.annotation.tailrec
import scala.collection.JavaConversions._
import scala.reflect.BeanProperty
sealed abstract class Text{
override def toString():String
//ToDo -- checkout Type bounds
@ib84
ib84 / HGDBTextApp.scala
Created March 11, 2012 15:35
hypergraphDB Text Experiments
import test.JHGDB.TestCommons._
import org.hypergraphdb.HGQuery.hg
import scala.collection.JavaConversions._
import org.hypergraphdb.query.AtomTypeCondition
import test.Text.Word3
import java.util.ArrayList
import org.hypergraphdb.indexing.{ByTargetIndexer, ByPartIndexer}
import org.hypergraphdb.{HyperGraph, HGHandle, HGPlainLink}
object HGDBRecursiveTextTest {
@ib84
ib84 / gist:3002452
Created June 27, 2012 08:32
little hypergraphdb demo
package hgtest.storage
import org.hypergraphdb._
import collection.JavaConversions._
import org.hypergraphdb.HGQuery.hg
import org.hypergraphdb.query.AtomTypeCondition
import org.hypergraphdb.util.HGUtils
import storage.bje.BJEStorageImplementation
@ib84
ib84 / HyperGraphDBScalaHacks.scala
Created July 24, 2012 08:12
Implicit conversions of HGHandle for improved usability of HyperGraphDB
object HGHandleHacks {
implicit def richHandle(handle: HGHandle)(implicit graph: HyperGraph) = new {
// DEREFERENCING
// dereference and type cast - may throw ClassCastException
def d[T](implicit graph: HyperGraph): T =
graph.get(handle).asInstanceOf[T]
@ib84
ib84 / BAWrapper.java
Created October 6, 2012 16:35
This Gist contains all classes of an alpha version of a HyperGraphDB storage implementation using Hazelcast
package org.hypergraphdb.storage;
import java.util.Arrays;
import java.io.Serializable;
public class BAWrapper implements Serializable{
private final byte[] data;
public BAWrapper(byte[] data)
{