Created
June 24, 2016 21:59
-
-
Save andrewor14/a9ed9d942029457a0f953e809ac26ee9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code generated by GenerateColumnarBatch.scala when building the column buffers | |
/* 001 */ import org.apache.spark.memory.MemoryMode; | |
/* 002 */ import org.apache.spark.sql.catalyst.InternalRow; | |
/* 003 */ import org.apache.spark.sql.execution.vectorized.ColumnarBatch; | |
/* 004 */ | |
/* 005 */ public GeneratedColumnarBatchIterator generate(Object[] references) { | |
/* 006 */ return new GeneratedColumnarBatchIterator(references); | |
/* 007 */ } | |
/* 008 */ | |
/* 009 */ class GeneratedColumnarBatchIterator extends org.apache.spark.sql.execution.columnar.ColumnarBatchIterator { | |
/* 010 */ private java.util.Iterator rowIterator; | |
/* 011 */ private org.apache.spark.sql.types.StructType schema; | |
/* 012 */ | |
/* 013 */ public GeneratedColumnarBatchIterator(Object[] references) { | |
/* 014 */ this.rowIterator = (java.util.Iterator) references[0]; | |
/* 015 */ this.schema = (org.apache.spark.sql.types.StructType) references[1]; | |
/* 016 */ } | |
/* 017 */ | |
/* 018 */ @Override | |
/* 019 */ public boolean hasNext() { | |
/* 020 */ return rowIterator.hasNext(); | |
/* 021 */ } | |
/* 022 */ | |
/* 023 */ @Override | |
/* 024 */ public ColumnarBatch next() { | |
/* 025 */ ColumnarBatch columnarBatch = | |
/* 026 */ ColumnarBatch.allocate(schema, MemoryMode.ON_HEAP, 10000); | |
/* 027 */ int rowNum = 0; | |
/* 028 */ long bytesInBatch = 0; | |
/* 029 */ while (rowIterator.hasNext() && rowNum < 10000 && bytesInBatch < 4194304) { | |
/* 030 */ InternalRow row = (InternalRow) rowIterator.next(); | |
/* 031 */ columnarBatch.column(0).putLong(rowNum, row.getLong(0)); | |
/* 032 */ bytesInBatch += 8; | |
/* 033 */ columnarBatch.column(1).putLong(rowNum, row.getLong(1)); | |
/* 034 */ bytesInBatch += 8; | |
/* 035 */ rowNum += 1; | |
/* 036 */ } | |
/* 037 */ columnarBatch.setNumRows(rowNum); | |
/* 038 */ return columnarBatch; | |
/* 039 */ } | |
/* 040 */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment