object Asn1Indexer
Builds and reads a sidecar record-offset index for BER/DER files, enabling Spark to split large files across multiple tasks.
Index file format (<original>.asn1idx):
- 8-byte header: 7-byte magic "ASN1IDX" + 1-byte version (0x01)
- 8 bytes per record: big-endian Long byte offset of the record's first tag byte
Only definite-length BER (and all DER) can be indexed. Indefinite-length constructions stop the scan early and produce a partial index.
Reading efficiency
readIndexSlice uses HDFS positioned reads (pread) to binary-search the index
file for the split boundaries, then reads only the matching slice sequentially.
For a 100 M-record index (~800 MB), this costs ~27 pread round-trips per task
plus a small sequential read — the full index is never loaded into memory.
- Source
- Asn1Indexer.scala
- Alphabetic
- By Inheritance
- Asn1Indexer
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val INDEX_SUFFIX: String
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def buildIndex(filePath: Path, conf: Configuration): (Path, Long)
Scan
filePathsequentially and write a sidecar index next to it.Scan
filePathsequentially and write a sidecar index next to it. Returns(indexPath, recordCount).Safe to call on a file that already has an index — the existing index is overwritten. Use
buildIndexesto skip already-indexed files. - def buildIndexes(spark: SparkSession, glob: String, overwrite: Boolean = false): DataFrame
Index all BER/DER files matched by
globin parallel, one Spark task per file.Index all BER/DER files matched by
globin parallel, one Spark task per file. Tasks run on executors co-located with the HDFS data blocks, so the sequential scan is local I/O on each node.- spark
active SparkSession
- glob
HDFS glob or directory path, e.g.
"/data/cdrs/file.ber"or a glob- overwrite
if false (default), files that already have a
.asn1idxsidecar are skipped- returns
a DataFrame with one row per file: (path: String, records: Long, skipped: Boolean)
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def readIndexSlice(indexPath: Path, conf: Configuration, fromByte: Long, toExclByte: Long): Array[Long]
Return the byte offsets of all records whose start falls within [fromByte, toExclByte).
Return the byte offsets of all records whose start falls within [fromByte, toExclByte).
Uses two binary searches (O(log N) positioned reads) on the index file, then one sequential read of only the matching slice.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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()
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)