-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pulling in changes which were developed during the file format development. #2
Open
animeshtrivedi
wants to merge
8
commits into
zrlio:master
Choose a base branch
from
animeshtrivedi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
973c879
new generator logic
animeshtrivedi a7e4532
new code with primitive schemas
animeshtrivedi a10bf08
default ORC compression is now set to null
animeshtrivedi bd4e880
setting up compression codecs for ORC and Parquet
animeshtrivedi 8669fc2
Support to generate 100 column int test
animeshtrivedi 6baa991
Support for 100c int test + moving all for to while
animeshtrivedi 752f907
Using a faster java ThreadLocal random var
animeshtrivedi 36304ec
support for setting the block size
animeshtrivedi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
98 changes: 98 additions & 0 deletions
98
src/main/scala/com/ibm/crail/spark/tools/DataGeneratorV2.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.ibm.crail.spark.tools | ||
|
||
import java.nio.ByteBuffer | ||
|
||
import scala.collection.mutable.StringBuilder | ||
import scala.util.Random | ||
|
||
/** | ||
* Created by atr on 28.11.17. | ||
*/ | ||
class DataGeneratorV2 extends Serializable { | ||
val random = new Random(System.nanoTime()) | ||
|
||
/* affix payload variables */ | ||
var affixStringBuilder:StringBuilder = null | ||
var affixByteArray:Array[Byte] = null | ||
|
||
val poolOfRandomStuff:Array[Byte] = new Array[Byte](1024*1024) | ||
random.nextBytes(poolOfRandomStuff) | ||
val bb:ByteBuffer = ByteBuffer.wrap(poolOfRandomStuff) | ||
bb.clear() | ||
|
||
def getNextString(size: Int, affix: Boolean):String = { | ||
if(affix){ | ||
this.synchronized { | ||
if (affixStringBuilder == null) { | ||
affixStringBuilder = new StringBuilder( | ||
random.alphanumeric.take(size).mkString) | ||
} | ||
} | ||
/* just randomly change 1 byte - this is to make sure parquet | ||
* does not ignore the data */ | ||
affixStringBuilder.setCharAt(random.nextInt(size), | ||
random.nextPrintableChar()) | ||
affixStringBuilder.mkString | ||
} else { | ||
random.alphanumeric.take(size).mkString | ||
} | ||
} | ||
|
||
def getNextByteArray(size: Int, affix: Boolean):Array[Byte] = { | ||
val toReturn = new Array[Byte](size) | ||
if(!affix){ | ||
/* if not affix, then return completely new values in a new array */ | ||
random.nextBytes(toReturn) | ||
} else { | ||
this.synchronized{ | ||
if(affixByteArray == null){ | ||
affixByteArray = new Array[Byte](size) | ||
/* initialize */ | ||
random.nextBytes(affixByteArray) | ||
} | ||
} | ||
/* just randomly change 1 byte - this is to make sure parquet | ||
* does not ignore the data - char will be casted to byte */ | ||
affixByteArray(random.nextInt(size)) = random.nextPrintableChar().toByte | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
/* now we copy affix array */ | ||
Array.copy(affixByteArray, 0, toReturn, 0, size) | ||
} | ||
toReturn | ||
} | ||
|
||
def getNextInt:Int = { | ||
if(bb.remaining() < 4) { | ||
bb.clear() | ||
} | ||
bb.getInt() | ||
} | ||
|
||
def getNextInt(max:Int):Int = { | ||
getNextInt % max | ||
} | ||
|
||
def getNextLong:Long= { | ||
if(bb.remaining() < 8) { | ||
bb.clear() | ||
} | ||
bb.getLong | ||
} | ||
|
||
def getNextDouble:Double= { | ||
if(bb.remaining() < 8) { | ||
bb.clear() | ||
} | ||
bb.getDouble | ||
} | ||
|
||
def getNextFloat: Float = { | ||
if(bb.remaining() < 4) | ||
bb.clear() | ||
bb.getFloat() | ||
} | ||
|
||
def getNextValue(s:String, size: Int, affix:Boolean): String ={ | ||
getNextString(size, affix) | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we randomly get the same byte? shouldn't we try until it changes?