abstract class BagReader[T] extends Iterator[(T, Long)]
A reader of binary SiLK Bag files. This is usable as an Iterator over a pair representing the key and counter in the Bag. Depending on the contents of the Bag file, the key is either an IPAddress or an Int. The counter is always a Long.
Since a Bag file may contain different key types, the BagReader factory methods return a BagResult wrapper over BagReader.
The keyType
and counterType
methods return a BagDataType
that specifies the type of the key and the counter that were
specified in the Bag file's header.
This example uses the single argument form of the companion object's
ofInputStream()
method to read the Bag file "example.bag". This code may be used outside of Hadoop when it is known that the Bag's key is an IPAddress.val stream = new java.io.FileInputStream("example.bag") val bagresult = BagReader.ofInputStream(stream) val bag = bagresult match { case BagResult.IPAddressBag(iter) => iter case _ => null } bag.hasNext val (ipaddr, counter) = bag.next()
- Note
While the SiLK command lines tools display an unspecified key type as an IPv4 address, the BagReader class treats an unspecified key type as an integer.
- See also
the companion object for more details.
- Alphabetic
- By Inheritance
- BagReader
- Iterator
- IterableOnceOps
- IterableOnce
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class GroupedIterator[B >: A] extends AbstractIterator[Seq[B]]
- Definition Classes
- Iterator
Abstract Value Members
- abstract def next(): (T, Long)
Produces the next (key, counter) pair of this iterator.
Produces the next (key, counter) pair of this iterator.
- returns
the next pair of this iterator if
hasNext
is true
- Definition Classes
- BagReader → Iterator
- Exceptions thrown
java.util.NoSuchElementException
when the iterator is depleted
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ++[B >: (T, Long)](xs: => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def addString(b: StringBuilder): StringBuilder
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- final def addString(b: StringBuilder, sep: String): StringBuilder
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder
- Definition Classes
- IterableOnceOps
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- var bufOffset: Int
Current position (octet offset) in the current buffer.
Current position (octet offset) in the current buffer.
- Attributes
- protected[this]
- var buffer: Array[Byte]
Current buffer of bytes being processed
Current buffer of bytes being processed
- Attributes
- protected[this]
- def buffered: BufferedIterator[(T, Long)]
- Definition Classes
- Iterator
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[B](pf: PartialFunction[(T, Long), B]): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def collectFirst[B](pf: PartialFunction[(T, Long), B]): Option[B]
- Definition Classes
- IterableOnceOps
- def concat[B >: (T, Long)](xs: => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator
- def contains(elem: Any): Boolean
- Definition Classes
- Iterator
- def copyToArray[B >: (T, Long)](xs: Array[B], start: Int, len: Int): Int
- Definition Classes
- IterableOnceOps
- def copyToArray[B >: (T, Long)](xs: Array[B], start: Int): Int
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecatedOverriding()
- def copyToArray[B >: (T, Long)](xs: Array[B]): Int
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecatedOverriding()
- def corresponds[B](that: IterableOnce[B])(p: ((T, Long), B) => Boolean): Boolean
- Definition Classes
- IterableOnceOps
- def count(p: ((T, Long)) => Boolean): Int
- Definition Classes
- IterableOnceOps
- def counterType: Option[BagDataType]
Provides the data type of the counter that was specified in the Bag file's header, if any.
Provides the data type of the counter that was specified in the Bag file's header, if any.
- returns
the type of data in the Counter field of the Bag or
None
if no header was present
- def distinct: Iterator[(T, Long)]
- Definition Classes
- Iterator
- def distinctBy[B](f: ((T, Long)) => B): Iterator[(T, Long)]
- Definition Classes
- Iterator
- def drop(n: Int): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def dropWhile(p: ((T, Long)) => Boolean): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def duplicate: (Iterator[(T, Long)], Iterator[(T, Long)])
- Definition Classes
- Iterator
- var endOfFile: Boolean
Whether the end of the input stream has been reached.
Whether the end of the input stream has been reached.
- Attributes
- protected[this]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def exists(p: ((T, Long)) => Boolean): Boolean
- Definition Classes
- IterableOnceOps
- def fillBuffer(): Unit
Read a new buffer into memory if needed.
Read a new buffer into memory if needed. Does no work if the current buffer still has unread records, or if the reader is at end of file. Sets endOfFile to true if the EOF is reached.
- Attributes
- protected[this]
- def filter(p: ((T, Long)) => Boolean): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def filterNot(p: ((T, Long)) => Boolean): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def find(p: ((T, Long)) => Boolean): Option[(T, Long)]
- Definition Classes
- IterableOnceOps
- def flatMap[B](f: ((T, Long)) => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def flatten[B](implicit ev: ((T, Long)) => IterableOnce[B]): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def fold[A1 >: (T, Long)](z: A1)(op: (A1, A1) => A1): A1
- Definition Classes
- IterableOnceOps
- def foldLeft[B](z: B)(op: (B, (T, Long)) => B): B
- Definition Classes
- IterableOnceOps
- def foldRight[B](z: B)(op: ((T, Long), B) => B): B
- Definition Classes
- IterableOnceOps
- def forall(p: ((T, Long)) => Boolean): Boolean
- Definition Classes
- IterableOnceOps
- def foreach[U](f: ((T, Long)) => U): Unit
- Definition Classes
- IterableOnceOps
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def grouped[B >: (T, Long)](size: Int): GroupedIterator[B]
- Definition Classes
- Iterator
- def hasNext: Boolean
Tests whether this iterator can provide another (key, counter) pair.
Tests whether this iterator can provide another (key, counter) pair.
- returns
true
if a subsequent call tonext()
will yield an element,false
otherwise.
- Definition Classes
- BagReader → Iterator
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- val header: Header
- Attributes
- protected[this]
- def indexOf[B >: (T, Long)](elem: B, from: Int): Int
- Definition Classes
- Iterator
- def indexOf[B >: (T, Long)](elem: B): Int
- Definition Classes
- Iterator
- def indexWhere(p: ((T, Long)) => Boolean, from: Int): Int
- Definition Classes
- Iterator
- def isEmpty: Boolean
- Definition Classes
- Iterator → IterableOnceOps
- Annotations
- @deprecatedOverriding()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTraversableAgain: Boolean
- Definition Classes
- IterableOnceOps
- final def iterator: Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnce
- Annotations
- @inline()
- def keyType: Option[BagDataType]
Provides the data type of the key that was specified in the Bag file's header, if any.
Provides the data type of the key that was specified in the Bag file's header, if any.
- returns
the type of data in the Key field of the Bag or
None
if no header was present
- def knownSize: Int
- Definition Classes
- IterableOnce
- final def length: Int
- Definition Classes
- Iterator
- Annotations
- @inline()
- def map[B](f: ((T, Long)) => B): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def max[B >: (T, Long)](implicit ord: Ordering[B]): (T, Long)
- Definition Classes
- IterableOnceOps
- def maxBy[B](f: ((T, Long)) => B)(implicit cmp: Ordering[B]): (T, Long)
- Definition Classes
- IterableOnceOps
- def maxByOption[B](f: ((T, Long)) => B)(implicit cmp: Ordering[B]): Option[(T, Long)]
- Definition Classes
- IterableOnceOps
- def maxOption[B >: (T, Long)](implicit ord: Ordering[B]): Option[(T, Long)]
- Definition Classes
- IterableOnceOps
- def min[B >: (T, Long)](implicit ord: Ordering[B]): (T, Long)
- Definition Classes
- IterableOnceOps
- def minBy[B](f: ((T, Long)) => B)(implicit cmp: Ordering[B]): (T, Long)
- Definition Classes
- IterableOnceOps
- def minByOption[B](f: ((T, Long)) => B)(implicit cmp: Ordering[B]): Option[(T, Long)]
- Definition Classes
- IterableOnceOps
- def minOption[B >: (T, Long)](implicit ord: Ordering[B]): Option[(T, Long)]
- Definition Classes
- IterableOnceOps
- final def mkString: String
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- final def mkString(sep: String): String
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- final def mkString(start: String, sep: String, end: String): String
- Definition Classes
- IterableOnceOps
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def nextOption(): Option[(T, Long)]
- Definition Classes
- Iterator
- def nonEmpty: Boolean
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecatedOverriding()
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def padTo[B >: (T, Long)](len: Int, elem: B): Iterator[B]
- Definition Classes
- Iterator
- def partition(p: ((T, Long)) => Boolean): (Iterator[(T, Long)], Iterator[(T, Long)])
- Definition Classes
- Iterator
- def patch[B >: (T, Long)](from: Int, patchElems: Iterator[B], replaced: Int): Iterator[B]
- Definition Classes
- Iterator
- def product[B >: (T, Long)](implicit num: Numeric[B]): B
- Definition Classes
- IterableOnceOps
- val reader: BufferReader
- Attributes
- protected[this]
- val recordLength: Short
Record length
Record length
- Attributes
- protected[this]
- def reduce[B >: (T, Long)](op: (B, B) => B): B
- Definition Classes
- IterableOnceOps
- def reduceLeft[B >: (T, Long)](op: (B, (T, Long)) => B): B
- Definition Classes
- IterableOnceOps
- def reduceLeftOption[B >: (T, Long)](op: (B, (T, Long)) => B): Option[B]
- Definition Classes
- IterableOnceOps
- def reduceOption[B >: (T, Long)](op: (B, B) => B): Option[B]
- Definition Classes
- IterableOnceOps
- def reduceRight[B >: (T, Long)](op: ((T, Long), B) => B): B
- Definition Classes
- IterableOnceOps
- def reduceRightOption[B >: (T, Long)](op: ((T, Long), B) => B): Option[B]
- Definition Classes
- IterableOnceOps
- def reversed: Iterable[(T, Long)]
- Attributes
- protected
- Definition Classes
- IterableOnceOps
- def sameElements[B >: (T, Long)](that: IterableOnce[B]): Boolean
- Definition Classes
- Iterator
- def scanLeft[B](z: B)(op: (B, (T, Long)) => B): Iterator[B]
- Definition Classes
- Iterator → IterableOnceOps
- def size: Int
- Definition Classes
- IterableOnceOps
- def slice(from: Int, until: Int): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def sliceIterator(from: Int, until: Int): Iterator[(T, Long)]
- Attributes
- protected
- Definition Classes
- Iterator
- def sliding[B >: (T, Long)](size: Int, step: Int): GroupedIterator[B]
- Definition Classes
- Iterator
- def span(p: ((T, Long)) => Boolean): (Iterator[(T, Long)], Iterator[(T, Long)])
- Definition Classes
- Iterator → IterableOnceOps
- def splitAt(n: Int): (Iterator[(T, Long)], Iterator[(T, Long)])
- Definition Classes
- IterableOnceOps
- def stepper[S <: Stepper[_]](implicit shape: StepperShape[(T, Long), S]): S
- Definition Classes
- IterableOnce
- def sum[B >: (T, Long)](implicit num: Numeric[B]): B
- Definition Classes
- IterableOnceOps
- val swap: Boolean
Whether to byte-swap the bytes as they are read from the buffer
Whether to byte-swap the bytes as they are read from the buffer
- Attributes
- protected[this]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def take(n: Int): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def takeWhile(p: ((T, Long)) => Boolean): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def tapEach[U](f: ((T, Long)) => U): Iterator[(T, Long)]
- Definition Classes
- Iterator → IterableOnceOps
- def to[C1](factory: Factory[(T, Long), C1]): C1
- Definition Classes
- IterableOnceOps
- def toArray[B >: (T, Long)](implicit arg0: ClassTag[B]): Array[B]
- Definition Classes
- IterableOnceOps
- final def toBuffer[B >: (T, Long)]: Buffer[B]
- Definition Classes
- IterableOnceOps
- Annotations
- @inline()
- def toIndexedSeq: IndexedSeq[(T, Long)]
- Definition Classes
- IterableOnceOps
- def toList: List[(T, Long)]
- Definition Classes
- IterableOnceOps
- def toMap[K, V](implicit ev: <:<[(T, Long), (K, V)]): Map[K, V]
- Definition Classes
- IterableOnceOps
- def toSeq: Seq[(T, Long)]
- Definition Classes
- IterableOnceOps
- def toSet[B >: (T, Long)]: Set[B]
- Definition Classes
- IterableOnceOps
- def toString(): String
- Definition Classes
- Iterator → AnyRef → Any
- def toVector: Vector[(T, Long)]
- Definition Classes
- IterableOnceOps
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withFilter(p: ((T, Long)) => Boolean): Iterator[(T, Long)]
- Definition Classes
- Iterator
- def zip[B](that: IterableOnce[B]): Iterator[((T, Long), B)]
- Definition Classes
- Iterator
- def zipAll[A1 >: (T, Long), B](that: IterableOnce[B], thisElem: A1, thatElem: B): Iterator[(A1, B)]
- Definition Classes
- Iterator
- def zipWithIndex: Iterator[((T, Long), Int)]
- Definition Classes
- Iterator → IterableOnceOps
Deprecated Value Members
- final def /:[B](z: B)(op: (B, (T, Long)) => B): B
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use foldLeft instead of /:
- final def :\[B](z: B)(op: ((T, Long), B) => B): B
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use foldRight instead of :\
- def aggregate[B](z: => B)(seqop: (B, (T, Long)) => B, combop: (B, B) => B): B
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0)
aggregate
is not relevant for sequential collections. UsefoldLeft(z)(seqop)
instead.
- final def copyToBuffer[B >: (T, Long)](dest: Buffer[B]): Unit
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use
dest ++= coll
instead
- final def hasDefiniteSize: Boolean
- Definition Classes
- Iterator → IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) hasDefiniteSize on Iterator is the same as isEmpty
- def scanRight[B](z: B)(op: ((T, Long), B) => B): Iterator[B]
- Definition Classes
- Iterator
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Call scanRight on an Iterable instead.
- def seq: BagReader.this.type
- Definition Classes
- Iterator
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Iterator.seq always returns the iterator itself
- final def toIterator: Iterator[(T, Long)]
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use .iterator instead of .toIterator
- final def toStream: Stream[(T, Long)]
- Definition Classes
- IterableOnceOps
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.13.0) Use .to(LazyList) instead of .toStream
This is documentation for Mothra, a collection of Scala and Spark library functions for working with Internet-related data. Some modules contain APIs of general use to Scala programmers. Some modules make those tools more useful on Spark data-processing systems.
Please see the documentation for the individual packages for more details on their use.
Scala Packages
These packages are useful in Scala code without involving Spark:
org.cert.netsa.data
This package, which is collected as the
netsa-data
library, provides types for working with various kinds of information:org.cert.netsa.data.net
- types for working with network dataorg.cert.netsa.data.time
- types for working with time dataorg.cert.netsa.data.unsigned
- types for working with unsigned integral valuesorg.cert.netsa.io.ipfix
The
netsa-io-ipfix
library provides tools for reading and writing IETF IPFIX data from various connections and files.org.cert.netsa.io.silk
To read and write CERT NetSA SiLK file formats and configuration files, use the
netsa-io-silk
library.org.cert.netsa.util
The "junk drawer" of
netsa-util
so far provides only two features: First, a method for equipping Scala scala.collection.Iterators with exception handling. And second, a way to query the versions of NetSA libraries present in a JVM at runtime.Spark Packages
These packages require the use of Apache Spark:
org.cert.netsa.mothra.datasources
Spark datasources for CERT file types. This package contains utility features which add methods to Apache Spark DataFrameReader objects, allowing IPFIX and SiLK flows to be opened using simple
spark.read...
calls.The
mothra-datasources
library contains both IPFIX and SiLK functionality, whilemothra-datasources-ipfix
andmothra-datasources-silk
contain only what's needed for the named datasource.org.cert.netsa.mothra.analysis
A grab-bag of analysis helper functions and example analyses.
org.cert.netsa.mothra.functions
This single Scala object provides Spark SQL functions for working with network data. It is the entirety of the
mothra-functions
library.