Skip to content

Instantly share code, notes, and snippets.

Verifying my Blockstack ID is secured with the address 15S9Wded5wQfvppmoBMT4Yd2Dj5n9XMVsY https://explorer.blockstack.org/address/15S9Wded5wQfvppmoBMT4Yd2Dj5n9XMVsY
package net.abhinavsarkar.util;
import java.util.Iterator;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
@kevinweil
kevinweil / ProtobufFileScanner.scala
Created November 26, 2009 11:03
A Scala class for reading a file of protobufs, serialized as repeated blocks of byte length, byte blob pairs. Based on @al3x's Thrift version of the same at http://gracelessfailures.com/a-generic-thrift-deserializer-in-scala
import com.google.protobuf.Message
import java.io.{BufferedReader, BufferedInputStream, DataInputStream, File, FileInputStream, InputStream, InputStreamReader}
import java.util.zip.GZIPInputStream
import scala.reflect.Manifest
class ProtobufFileScanner[M <: Message](implicit man: Manifest[M]) {
var file: File = null
var bufferedIn: BufferedInputStream = null
// ensure we're not at EOF