id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
3,800
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/WindDirection.java
WindDirection.setPointer2Type
public void setPointer2Type(final PointerType POINTER2_TYPE) { pointer2Type = POINTER2_TYPE; init(getInnerBounds().width, getInnerBounds().height); repaint(getInnerBounds()); }
java
public void setPointer2Type(final PointerType POINTER2_TYPE) { pointer2Type = POINTER2_TYPE; init(getInnerBounds().width, getInnerBounds().height); repaint(getInnerBounds()); }
[ "public", "void", "setPointer2Type", "(", "final", "PointerType", "POINTER2_TYPE", ")", "{", "pointer2Type", "=", "POINTER2_TYPE", ";", "init", "(", "getInnerBounds", "(", ")", ".", "width", ",", "getInnerBounds", "(", ")", ".", "height", ")", ";", "repaint", "(", "getInnerBounds", "(", ")", ")", ";", "}" ]
Sets the pointertype of the second pointer @param POINTER2_TYPE
[ "Sets", "the", "pointertype", "of", "the", "second", "pointer" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/WindDirection.java#L445-L449
3,801
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/WindDirection.java
WindDirection.setCustomPointer2Color
public void setCustomPointer2Color(final Color COLOR) { this.customPointer2Color = new CustomColorDef(COLOR); init(getInnerBounds().width, getInnerBounds().height); repaint(getInnerBounds()); }
java
public void setCustomPointer2Color(final Color COLOR) { this.customPointer2Color = new CustomColorDef(COLOR); init(getInnerBounds().width, getInnerBounds().height); repaint(getInnerBounds()); }
[ "public", "void", "setCustomPointer2Color", "(", "final", "Color", "COLOR", ")", "{", "this", ".", "customPointer2Color", "=", "new", "CustomColorDef", "(", "COLOR", ")", ";", "init", "(", "getInnerBounds", "(", ")", ".", "width", ",", "getInnerBounds", "(", ")", ".", "height", ")", ";", "repaint", "(", "getInnerBounds", "(", ")", ")", ";", "}" ]
Sets the color from which the custom pointer2 color is calculated @param COLOR
[ "Sets", "the", "color", "from", "which", "the", "custom", "pointer2", "color", "is", "calculated" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/WindDirection.java#L463-L467
3,802
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/AbstractLinear.java
AbstractLinear.create_BACKGROUND_Image
protected BufferedImage create_BACKGROUND_Image(final int WIDTH, final int HEIGHT, BufferedImage image) { if (WIDTH <= 0 || HEIGHT <= 0) { return UTIL.createImage(1, 1, Transparency.TRANSLUCENT); } if (image == null) { image = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT); } final Graphics2D G2 = image.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int IMAGE_WIDTH = image.getWidth(); final int IMAGE_HEIGHT = image.getHeight(); // Draw the background image BACKGROUND_FACTORY.createLinearBackground(WIDTH, HEIGHT, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image); // Draw the custom layer if selected if (isCustomLayerVisible()) { G2.drawImage(UTIL.getScaledInstance(getCustomLayer(), IMAGE_WIDTH, IMAGE_HEIGHT, RenderingHints.VALUE_INTERPOLATION_BICUBIC), 0, 0, null); } G2.dispose(); return image; }
java
protected BufferedImage create_BACKGROUND_Image(final int WIDTH, final int HEIGHT, BufferedImage image) { if (WIDTH <= 0 || HEIGHT <= 0) { return UTIL.createImage(1, 1, Transparency.TRANSLUCENT); } if (image == null) { image = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT); } final Graphics2D G2 = image.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int IMAGE_WIDTH = image.getWidth(); final int IMAGE_HEIGHT = image.getHeight(); // Draw the background image BACKGROUND_FACTORY.createLinearBackground(WIDTH, HEIGHT, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image); // Draw the custom layer if selected if (isCustomLayerVisible()) { G2.drawImage(UTIL.getScaledInstance(getCustomLayer(), IMAGE_WIDTH, IMAGE_HEIGHT, RenderingHints.VALUE_INTERPOLATION_BICUBIC), 0, 0, null); } G2.dispose(); return image; }
[ "protected", "BufferedImage", "create_BACKGROUND_Image", "(", "final", "int", "WIDTH", ",", "final", "int", "HEIGHT", ",", "BufferedImage", "image", ")", "{", "if", "(", "WIDTH", "<=", "0", "||", "HEIGHT", "<=", "0", ")", "{", "return", "UTIL", ".", "createImage", "(", "1", ",", "1", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "}", "if", "(", "image", "==", "null", ")", "{", "image", "=", "UTIL", ".", "createImage", "(", "WIDTH", ",", "HEIGHT", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "}", "final", "Graphics2D", "G2", "=", "image", ".", "createGraphics", "(", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_STROKE_CONTROL", ",", "RenderingHints", ".", "VALUE_STROKE_NORMALIZE", ")", ";", "final", "int", "IMAGE_WIDTH", "=", "image", ".", "getWidth", "(", ")", ";", "final", "int", "IMAGE_HEIGHT", "=", "image", ".", "getHeight", "(", ")", ";", "// Draw the background image", "BACKGROUND_FACTORY", ".", "createLinearBackground", "(", "WIDTH", ",", "HEIGHT", ",", "getBackgroundColor", "(", ")", ",", "getModel", "(", ")", ".", "getCustomBackground", "(", ")", ",", "getModel", "(", ")", ".", "getTextureColor", "(", ")", ",", "image", ")", ";", "// Draw the custom layer if selected", "if", "(", "isCustomLayerVisible", "(", ")", ")", "{", "G2", ".", "drawImage", "(", "UTIL", ".", "getScaledInstance", "(", "getCustomLayer", "(", ")", ",", "IMAGE_WIDTH", ",", "IMAGE_HEIGHT", ",", "RenderingHints", ".", "VALUE_INTERPOLATION_BICUBIC", ")", ",", "0", ",", "0", ",", "null", ")", ";", "}", "G2", ".", "dispose", "(", ")", ";", "return", "image", ";", "}" ]
Returns the background image with the currently active backgroundcolor with the given width and height. @param WIDTH @param HEIGHT @param image @return buffered image containing the background with the selected background design
[ "Returns", "the", "background", "image", "with", "the", "currently", "active", "backgroundcolor", "with", "the", "given", "width", "and", "height", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/AbstractLinear.java#L917-L943
3,803
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/AbstractLinear.java
AbstractLinear.create_MEASURED_VALUE_Image
protected BufferedImage create_MEASURED_VALUE_Image(final int WIDTH, final int HEIGHT, final Color COLOR) { if (WIDTH <= 20 || HEIGHT <= 20) // 20 is needed otherwise the image size could be smaller than 1 { return UTIL.createImage(1, 1, Transparency.TRANSLUCENT); } final int IMAGE_WIDTH; final int IMAGE_HEIGHT; if (getOrientation() == Orientation.VERTICAL) { // Vertical orientation IMAGE_WIDTH = (int) (WIDTH * 0.05); IMAGE_HEIGHT = IMAGE_WIDTH; } else { // Horizontal orientation IMAGE_HEIGHT = (int) (HEIGHT * 0.05); IMAGE_WIDTH = IMAGE_HEIGHT; } final BufferedImage IMAGE = UTIL.createImage(IMAGE_WIDTH, IMAGE_HEIGHT, Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final GeneralPath INDICATOR = new GeneralPath(); INDICATOR.setWindingRule(Path2D.WIND_EVEN_ODD); if (getOrientation() == Orientation.VERTICAL) { INDICATOR.moveTo(IMAGE_WIDTH, IMAGE_HEIGHT * 0.5); INDICATOR.lineTo(0.0, 0.0); INDICATOR.lineTo(0.0, IMAGE_HEIGHT); INDICATOR.closePath(); } else { INDICATOR.moveTo(IMAGE_WIDTH * 0.5, 0.0); INDICATOR.lineTo(IMAGE_WIDTH, IMAGE_HEIGHT); INDICATOR.lineTo(0.0, IMAGE_HEIGHT); INDICATOR.closePath(); } G2.setColor(COLOR); G2.fill(INDICATOR); G2.dispose(); return IMAGE; }
java
protected BufferedImage create_MEASURED_VALUE_Image(final int WIDTH, final int HEIGHT, final Color COLOR) { if (WIDTH <= 20 || HEIGHT <= 20) // 20 is needed otherwise the image size could be smaller than 1 { return UTIL.createImage(1, 1, Transparency.TRANSLUCENT); } final int IMAGE_WIDTH; final int IMAGE_HEIGHT; if (getOrientation() == Orientation.VERTICAL) { // Vertical orientation IMAGE_WIDTH = (int) (WIDTH * 0.05); IMAGE_HEIGHT = IMAGE_WIDTH; } else { // Horizontal orientation IMAGE_HEIGHT = (int) (HEIGHT * 0.05); IMAGE_WIDTH = IMAGE_HEIGHT; } final BufferedImage IMAGE = UTIL.createImage(IMAGE_WIDTH, IMAGE_HEIGHT, Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final GeneralPath INDICATOR = new GeneralPath(); INDICATOR.setWindingRule(Path2D.WIND_EVEN_ODD); if (getOrientation() == Orientation.VERTICAL) { INDICATOR.moveTo(IMAGE_WIDTH, IMAGE_HEIGHT * 0.5); INDICATOR.lineTo(0.0, 0.0); INDICATOR.lineTo(0.0, IMAGE_HEIGHT); INDICATOR.closePath(); } else { INDICATOR.moveTo(IMAGE_WIDTH * 0.5, 0.0); INDICATOR.lineTo(IMAGE_WIDTH, IMAGE_HEIGHT); INDICATOR.lineTo(0.0, IMAGE_HEIGHT); INDICATOR.closePath(); } G2.setColor(COLOR); G2.fill(INDICATOR); G2.dispose(); return IMAGE; }
[ "protected", "BufferedImage", "create_MEASURED_VALUE_Image", "(", "final", "int", "WIDTH", ",", "final", "int", "HEIGHT", ",", "final", "Color", "COLOR", ")", "{", "if", "(", "WIDTH", "<=", "20", "||", "HEIGHT", "<=", "20", ")", "// 20 is needed otherwise the image size could be smaller than 1", "{", "return", "UTIL", ".", "createImage", "(", "1", ",", "1", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "}", "final", "int", "IMAGE_WIDTH", ";", "final", "int", "IMAGE_HEIGHT", ";", "if", "(", "getOrientation", "(", ")", "==", "Orientation", ".", "VERTICAL", ")", "{", "// Vertical orientation", "IMAGE_WIDTH", "=", "(", "int", ")", "(", "WIDTH", "*", "0.05", ")", ";", "IMAGE_HEIGHT", "=", "IMAGE_WIDTH", ";", "}", "else", "{", "// Horizontal orientation", "IMAGE_HEIGHT", "=", "(", "int", ")", "(", "HEIGHT", "*", "0.05", ")", ";", "IMAGE_WIDTH", "=", "IMAGE_HEIGHT", ";", "}", "final", "BufferedImage", "IMAGE", "=", "UTIL", ".", "createImage", "(", "IMAGE_WIDTH", ",", "IMAGE_HEIGHT", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "final", "Graphics2D", "G2", "=", "IMAGE", ".", "createGraphics", "(", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "final", "GeneralPath", "INDICATOR", "=", "new", "GeneralPath", "(", ")", ";", "INDICATOR", ".", "setWindingRule", "(", "Path2D", ".", "WIND_EVEN_ODD", ")", ";", "if", "(", "getOrientation", "(", ")", "==", "Orientation", ".", "VERTICAL", ")", "{", "INDICATOR", ".", "moveTo", "(", "IMAGE_WIDTH", ",", "IMAGE_HEIGHT", "*", "0.5", ")", ";", "INDICATOR", ".", "lineTo", "(", "0.0", ",", "0.0", ")", ";", "INDICATOR", ".", "lineTo", "(", "0.0", ",", "IMAGE_HEIGHT", ")", ";", "INDICATOR", ".", "closePath", "(", ")", ";", "}", "else", "{", "INDICATOR", ".", "moveTo", "(", "IMAGE_WIDTH", "*", "0.5", ",", "0.0", ")", ";", "INDICATOR", ".", "lineTo", "(", "IMAGE_WIDTH", ",", "IMAGE_HEIGHT", ")", ";", "INDICATOR", ".", "lineTo", "(", "0.0", ",", "IMAGE_HEIGHT", ")", ";", "INDICATOR", ".", "closePath", "(", ")", ";", "}", "G2", ".", "setColor", "(", "COLOR", ")", ";", "G2", ".", "fill", "(", "INDICATOR", ")", ";", "G2", ".", "dispose", "(", ")", ";", "return", "IMAGE", ";", "}" ]
Returns the image of the MinMeasuredValue and MaxMeasuredValue dependend on the given color @param WIDTH @param HEIGHT @param COLOR @return a buffered image of either the min measured value or the max measured value indicator
[ "Returns", "the", "image", "of", "the", "MinMeasuredValue", "and", "MaxMeasuredValue", "dependend", "on", "the", "given", "color" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/AbstractLinear.java#L1293-L1334
3,804
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.init
private void init(final int WIDTH, final int HEIGHT) { if (WIDTH <= 1 || HEIGHT <= 1) { return; } final double CORNER_RADIUS = WIDTH > HEIGHT ? (HEIGHT * 0.095) : (WIDTH * 0.095); if (recreateImages) { if (sparkLineBackgroundImage != null) { sparkLineBackgroundImage.flush(); } sparkLineBackgroundImage = create_SPARK_LINE_BACKGROUND_Image(WIDTH, HEIGHT); // set the clip shape CLIP_SHAPE.setRoundRect(1, 1, WIDTH - 2, HEIGHT - 2, CORNER_RADIUS - 1, CORNER_RADIUS - 1); if (startIndicatorImage != null) { startIndicatorImage.flush(); } //startIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY); startIndicatorImage = create_START_STOP_INDICATOR_Image(WIDTH); if (stopIndicatorImage != null) { stopIndicatorImage.flush(); } //stopIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY); stopIndicatorImage = create_START_STOP_INDICATOR_Image(WIDTH); if (loIndicatorImage != null) { loIndicatorImage.flush(); } //loIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.BLUE); loIndicatorImage = create_LO_INDICATOR_Image(WIDTH); if (hiIndicatorImage != null) { hiIndicatorImage.flush(); } //hiIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.RED); hiIndicatorImage = create_HI_INDICATOR_Image(WIDTH); } recreateImages = false; disabledShape = new java.awt.geom.RoundRectangle2D.Double(0, 0, WIDTH, HEIGHT, CORNER_RADIUS, CORNER_RADIUS); // Calculation and creation of sparkline itself pixelResolution = INNER_BOUNDS.getWidth() / (double) timeFrame; //offset = (int)(0.015 * WIDTH) < 4 ? 4 : (int)(0.015 * WIDTH); offset = (int) (0.06 * WIDTH) < 8 ? 8 : (int) (0.06 * WIDTH); baseLineY = INNER_BOUNDS.y + INNER_BOUNDS.height - ((0 - lo) * (1 / scaleY) + offset); if (!DATA_LIST.isEmpty()) { calculate(WIDTH, HEIGHT); } if (sparkLineImage != null) { sparkLineImage.flush(); } sparkLineImage = createSparkLineImage(WIDTH, HEIGHT); }
java
private void init(final int WIDTH, final int HEIGHT) { if (WIDTH <= 1 || HEIGHT <= 1) { return; } final double CORNER_RADIUS = WIDTH > HEIGHT ? (HEIGHT * 0.095) : (WIDTH * 0.095); if (recreateImages) { if (sparkLineBackgroundImage != null) { sparkLineBackgroundImage.flush(); } sparkLineBackgroundImage = create_SPARK_LINE_BACKGROUND_Image(WIDTH, HEIGHT); // set the clip shape CLIP_SHAPE.setRoundRect(1, 1, WIDTH - 2, HEIGHT - 2, CORNER_RADIUS - 1, CORNER_RADIUS - 1); if (startIndicatorImage != null) { startIndicatorImage.flush(); } //startIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY); startIndicatorImage = create_START_STOP_INDICATOR_Image(WIDTH); if (stopIndicatorImage != null) { stopIndicatorImage.flush(); } //stopIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY); stopIndicatorImage = create_START_STOP_INDICATOR_Image(WIDTH); if (loIndicatorImage != null) { loIndicatorImage.flush(); } //loIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.BLUE); loIndicatorImage = create_LO_INDICATOR_Image(WIDTH); if (hiIndicatorImage != null) { hiIndicatorImage.flush(); } //hiIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.RED); hiIndicatorImage = create_HI_INDICATOR_Image(WIDTH); } recreateImages = false; disabledShape = new java.awt.geom.RoundRectangle2D.Double(0, 0, WIDTH, HEIGHT, CORNER_RADIUS, CORNER_RADIUS); // Calculation and creation of sparkline itself pixelResolution = INNER_BOUNDS.getWidth() / (double) timeFrame; //offset = (int)(0.015 * WIDTH) < 4 ? 4 : (int)(0.015 * WIDTH); offset = (int) (0.06 * WIDTH) < 8 ? 8 : (int) (0.06 * WIDTH); baseLineY = INNER_BOUNDS.y + INNER_BOUNDS.height - ((0 - lo) * (1 / scaleY) + offset); if (!DATA_LIST.isEmpty()) { calculate(WIDTH, HEIGHT); } if (sparkLineImage != null) { sparkLineImage.flush(); } sparkLineImage = createSparkLineImage(WIDTH, HEIGHT); }
[ "private", "void", "init", "(", "final", "int", "WIDTH", ",", "final", "int", "HEIGHT", ")", "{", "if", "(", "WIDTH", "<=", "1", "||", "HEIGHT", "<=", "1", ")", "{", "return", ";", "}", "final", "double", "CORNER_RADIUS", "=", "WIDTH", ">", "HEIGHT", "?", "(", "HEIGHT", "*", "0.095", ")", ":", "(", "WIDTH", "*", "0.095", ")", ";", "if", "(", "recreateImages", ")", "{", "if", "(", "sparkLineBackgroundImage", "!=", "null", ")", "{", "sparkLineBackgroundImage", ".", "flush", "(", ")", ";", "}", "sparkLineBackgroundImage", "=", "create_SPARK_LINE_BACKGROUND_Image", "(", "WIDTH", ",", "HEIGHT", ")", ";", "// set the clip shape", "CLIP_SHAPE", ".", "setRoundRect", "(", "1", ",", "1", ",", "WIDTH", "-", "2", ",", "HEIGHT", "-", "2", ",", "CORNER_RADIUS", "-", "1", ",", "CORNER_RADIUS", "-", "1", ")", ";", "if", "(", "startIndicatorImage", "!=", "null", ")", "{", "startIndicatorImage", ".", "flush", "(", ")", ";", "}", "//startIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY);", "startIndicatorImage", "=", "create_START_STOP_INDICATOR_Image", "(", "WIDTH", ")", ";", "if", "(", "stopIndicatorImage", "!=", "null", ")", "{", "stopIndicatorImage", ".", "flush", "(", ")", ";", "}", "//stopIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY);", "stopIndicatorImage", "=", "create_START_STOP_INDICATOR_Image", "(", "WIDTH", ")", ";", "if", "(", "loIndicatorImage", "!=", "null", ")", "{", "loIndicatorImage", ".", "flush", "(", ")", ";", "}", "//loIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.BLUE);", "loIndicatorImage", "=", "create_LO_INDICATOR_Image", "(", "WIDTH", ")", ";", "if", "(", "hiIndicatorImage", "!=", "null", ")", "{", "hiIndicatorImage", ".", "flush", "(", ")", ";", "}", "//hiIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.RED);", "hiIndicatorImage", "=", "create_HI_INDICATOR_Image", "(", "WIDTH", ")", ";", "}", "recreateImages", "=", "false", ";", "disabledShape", "=", "new", "java", ".", "awt", ".", "geom", ".", "RoundRectangle2D", ".", "Double", "(", "0", ",", "0", ",", "WIDTH", ",", "HEIGHT", ",", "CORNER_RADIUS", ",", "CORNER_RADIUS", ")", ";", "// Calculation and creation of sparkline itself", "pixelResolution", "=", "INNER_BOUNDS", ".", "getWidth", "(", ")", "/", "(", "double", ")", "timeFrame", ";", "//offset = (int)(0.015 * WIDTH) < 4 ? 4 : (int)(0.015 * WIDTH);", "offset", "=", "(", "int", ")", "(", "0.06", "*", "WIDTH", ")", "<", "8", "?", "8", ":", "(", "int", ")", "(", "0.06", "*", "WIDTH", ")", ";", "baseLineY", "=", "INNER_BOUNDS", ".", "y", "+", "INNER_BOUNDS", ".", "height", "-", "(", "(", "0", "-", "lo", ")", "*", "(", "1", "/", "scaleY", ")", "+", "offset", ")", ";", "if", "(", "!", "DATA_LIST", ".", "isEmpty", "(", ")", ")", "{", "calculate", "(", "WIDTH", ",", "HEIGHT", ")", ";", "}", "if", "(", "sparkLineImage", "!=", "null", ")", "{", "sparkLineImage", ".", "flush", "(", ")", ";", "}", "sparkLineImage", "=", "createSparkLineImage", "(", "WIDTH", ",", "HEIGHT", ")", ";", "}" ]
Initializes the sparkline component with the given width and height @param WIDTH @param HEIGHT
[ "Initializes", "the", "sparkline", "component", "with", "the", "given", "width", "and", "height" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L201-L259
3,805
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.addDataPoint
public void addDataPoint(final double DATA) { for (DataPoint dataPoint : DATA_LIST) { if (System.currentTimeMillis() - dataPoint.getTimeStamp() > timeFrame) { trashList.add(dataPoint); } } for (DataPoint dataPoint : trashList) { DATA_LIST.remove(dataPoint); } trashList.clear(); DATA_LIST.add(new DataPoint(System.currentTimeMillis(), DATA)); init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void addDataPoint(final double DATA) { for (DataPoint dataPoint : DATA_LIST) { if (System.currentTimeMillis() - dataPoint.getTimeStamp() > timeFrame) { trashList.add(dataPoint); } } for (DataPoint dataPoint : trashList) { DATA_LIST.remove(dataPoint); } trashList.clear(); DATA_LIST.add(new DataPoint(System.currentTimeMillis(), DATA)); init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "addDataPoint", "(", "final", "double", "DATA", ")", "{", "for", "(", "DataPoint", "dataPoint", ":", "DATA_LIST", ")", "{", "if", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "dataPoint", ".", "getTimeStamp", "(", ")", ">", "timeFrame", ")", "{", "trashList", ".", "add", "(", "dataPoint", ")", ";", "}", "}", "for", "(", "DataPoint", "dataPoint", ":", "trashList", ")", "{", "DATA_LIST", ".", "remove", "(", "dataPoint", ")", ";", "}", "trashList", ".", "clear", "(", ")", ";", "DATA_LIST", ".", "add", "(", "new", "DataPoint", "(", "System", ".", "currentTimeMillis", "(", ")", ",", "DATA", ")", ")", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Adds a new value to the DATA_LIST of the sparkline @param DATA
[ "Adds", "a", "new", "value", "to", "the", "DATA_LIST", "of", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L328-L342
3,806
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.getDataList
public List<DataPoint> getDataList() { List<DataPoint> dataListCopy = new LinkedList<eu.hansolo.steelseries.tools.DataPoint>(); dataListCopy.addAll(DATA_LIST); return dataListCopy; }
java
public List<DataPoint> getDataList() { List<DataPoint> dataListCopy = new LinkedList<eu.hansolo.steelseries.tools.DataPoint>(); dataListCopy.addAll(DATA_LIST); return dataListCopy; }
[ "public", "List", "<", "DataPoint", ">", "getDataList", "(", ")", "{", "List", "<", "DataPoint", ">", "dataListCopy", "=", "new", "LinkedList", "<", "eu", ".", "hansolo", ".", "steelseries", ".", "tools", ".", "DataPoint", ">", "(", ")", ";", "dataListCopy", ".", "addAll", "(", "DATA_LIST", ")", ";", "return", "dataListCopy", ";", "}" ]
Returns the linked list that contains the current data of the sparkline @return the linked list that contains the current data of the sparkline
[ "Returns", "the", "linked", "list", "that", "contains", "the", "current", "data", "of", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L369-L373
3,807
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setDataList
public void setDataList(LinkedList<DataPoint> dataList) { DATA_LIST.clear(); DATA_LIST.addAll(dataList); repaint(INNER_BOUNDS); }
java
public void setDataList(LinkedList<DataPoint> dataList) { DATA_LIST.clear(); DATA_LIST.addAll(dataList); repaint(INNER_BOUNDS); }
[ "public", "void", "setDataList", "(", "LinkedList", "<", "DataPoint", ">", "dataList", ")", "{", "DATA_LIST", ".", "clear", "(", ")", ";", "DATA_LIST", ".", "addAll", "(", "dataList", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Clears the existing DATA_LIST and adds all elements from the given LinkedList to it @param dataList
[ "Clears", "the", "existing", "DATA_LIST", "and", "adds", "all", "elements", "from", "the", "given", "LinkedList", "to", "it" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L379-L383
3,808
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.getVariance
public double getVariance() { if (!DATA_LIST.isEmpty()) { double sum = 0; double sumOfSquares = 0; double average = 0; for (DataPoint dataPoint : DATA_LIST) { sumOfSquares += (dataPoint.getValue() * dataPoint.getValue()); sum += dataPoint.getValue(); } average = sum / DATA_LIST.size(); return (sumOfSquares / DATA_LIST.size()) - average * average; } return 0; }
java
public double getVariance() { if (!DATA_LIST.isEmpty()) { double sum = 0; double sumOfSquares = 0; double average = 0; for (DataPoint dataPoint : DATA_LIST) { sumOfSquares += (dataPoint.getValue() * dataPoint.getValue()); sum += dataPoint.getValue(); } average = sum / DATA_LIST.size(); return (sumOfSquares / DATA_LIST.size()) - average * average; } return 0; }
[ "public", "double", "getVariance", "(", ")", "{", "if", "(", "!", "DATA_LIST", ".", "isEmpty", "(", ")", ")", "{", "double", "sum", "=", "0", ";", "double", "sumOfSquares", "=", "0", ";", "double", "average", "=", "0", ";", "for", "(", "DataPoint", "dataPoint", ":", "DATA_LIST", ")", "{", "sumOfSquares", "+=", "(", "dataPoint", ".", "getValue", "(", ")", "*", "dataPoint", ".", "getValue", "(", ")", ")", ";", "sum", "+=", "dataPoint", ".", "getValue", "(", ")", ";", "}", "average", "=", "sum", "/", "DATA_LIST", ".", "size", "(", ")", ";", "return", "(", "sumOfSquares", "/", "DATA_LIST", ".", "size", "(", ")", ")", "-", "average", "*", "average", ";", "}", "return", "0", ";", "}" ]
Returns the calculated varianz of the current data @return the calculated varianz of the current data
[ "Returns", "the", "calculated", "varianz", "of", "the", "current", "data" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L421-L434
3,809
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.getAverage
public double getAverage() { if (!DATA_LIST.isEmpty()) { double sum = 0; for (DataPoint dataPoint : DATA_LIST) { sum += dataPoint.getValue(); } return sum / DATA_LIST.size(); } return 0; }
java
public double getAverage() { if (!DATA_LIST.isEmpty()) { double sum = 0; for (DataPoint dataPoint : DATA_LIST) { sum += dataPoint.getValue(); } return sum / DATA_LIST.size(); } return 0; }
[ "public", "double", "getAverage", "(", ")", "{", "if", "(", "!", "DATA_LIST", ".", "isEmpty", "(", ")", ")", "{", "double", "sum", "=", "0", ";", "for", "(", "DataPoint", "dataPoint", ":", "DATA_LIST", ")", "{", "sum", "+=", "dataPoint", ".", "getValue", "(", ")", ";", "}", "return", "sum", "/", "DATA_LIST", ".", "size", "(", ")", ";", "}", "return", "0", ";", "}" ]
Returns the calculated average of the current data @return the calculated average of the current data
[ "Returns", "the", "calculated", "average", "of", "the", "current", "data" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L440-L449
3,810
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.getMedian
public double getMedian() { if (DATA_LIST.size() > 2) { sortData(); if (sortedList.size() % 2 != 0) { return sortedList.get((sortedList.size() / 2)); } else { return (sortedList.get(sortedList.size() / 2 - 1) + sortedList.get(sortedList.size() / 2)) / 2.0; } } return 0; }
java
public double getMedian() { if (DATA_LIST.size() > 2) { sortData(); if (sortedList.size() % 2 != 0) { return sortedList.get((sortedList.size() / 2)); } else { return (sortedList.get(sortedList.size() / 2 - 1) + sortedList.get(sortedList.size() / 2)) / 2.0; } } return 0; }
[ "public", "double", "getMedian", "(", ")", "{", "if", "(", "DATA_LIST", ".", "size", "(", ")", ">", "2", ")", "{", "sortData", "(", ")", ";", "if", "(", "sortedList", ".", "size", "(", ")", "%", "2", "!=", "0", ")", "{", "return", "sortedList", ".", "get", "(", "(", "sortedList", ".", "size", "(", ")", "/", "2", ")", ")", ";", "}", "else", "{", "return", "(", "sortedList", ".", "get", "(", "sortedList", ".", "size", "(", ")", "/", "2", "-", "1", ")", "+", "sortedList", ".", "get", "(", "sortedList", ".", "size", "(", ")", "/", "2", ")", ")", "/", "2.0", ";", "}", "}", "return", "0", ";", "}" ]
Returns the median of the measured values @return the median of the measured values
[ "Returns", "the", "median", "of", "the", "measured", "values" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L498-L509
3,811
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setTimeFrame
public void setTimeFrame(final long TIME_FRAME) { this.timeFrame = TIME_FRAME; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setTimeFrame(final long TIME_FRAME) { this.timeFrame = TIME_FRAME; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setTimeFrame", "(", "final", "long", "TIME_FRAME", ")", "{", "this", ".", "timeFrame", "=", "TIME_FRAME", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Defines the current timeframe of the sparkline in milliseconds @param TIME_FRAME
[ "Defines", "the", "current", "timeframe", "of", "the", "sparkline", "in", "milliseconds" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L523-L527
3,812
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setFilled
public void setFilled(final boolean FILLED) { this.filled = FILLED; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setFilled(final boolean FILLED) { this.filled = FILLED; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setFilled", "(", "final", "boolean", "FILLED", ")", "{", "this", ".", "filled", "=", "FILLED", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Enables or disables the filling of the area below the sparkline @param FILLED
[ "Enables", "or", "disables", "the", "filling", "of", "the", "area", "below", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L565-L569
3,813
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setSmoothing
public void setSmoothing(final boolean SMOOTHING) { this.smoothing = SMOOTHING; if (SMOOTHING) { hiLoIndicatorVisible = false; } init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setSmoothing(final boolean SMOOTHING) { this.smoothing = SMOOTHING; if (SMOOTHING) { hiLoIndicatorVisible = false; } init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setSmoothing", "(", "final", "boolean", "SMOOTHING", ")", "{", "this", ".", "smoothing", "=", "SMOOTHING", ";", "if", "(", "SMOOTHING", ")", "{", "hiLoIndicatorVisible", "=", "false", ";", "}", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Enables or disables the smoothing of the POINT_LIST and so of the sparkline @param SMOOTHING
[ "Enables", "or", "disables", "the", "smoothing", "of", "the", "POINT_LIST", "and", "so", "of", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L583-L590
3,814
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setSparkLineColor
public void setSparkLineColor(final LcdColor LCD_COLOR) { this.lineColor = LCD_COLOR.TEXT_COLOR; this.sparkLineColor = LCD_COLOR; recreateImages = true; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setSparkLineColor(final LcdColor LCD_COLOR) { this.lineColor = LCD_COLOR.TEXT_COLOR; this.sparkLineColor = LCD_COLOR; recreateImages = true; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setSparkLineColor", "(", "final", "LcdColor", "LCD_COLOR", ")", "{", "this", ".", "lineColor", "=", "LCD_COLOR", ".", "TEXT_COLOR", ";", "this", ".", "sparkLineColor", "=", "LCD_COLOR", ";", "recreateImages", "=", "true", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Sets the color theme for the sparkline. @param LCD_COLOR
[ "Sets", "the", "color", "theme", "for", "the", "sparkline", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L604-L610
3,815
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setLineColor
public void setLineColor(final Color LINE_COLOR) { this.lineColor = LINE_COLOR; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setLineColor(final Color LINE_COLOR) { this.lineColor = LINE_COLOR; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setLineColor", "(", "final", "Color", "LINE_COLOR", ")", "{", "this", ".", "lineColor", "=", "LINE_COLOR", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Sets the color of the sparkline @param LINE_COLOR
[ "Sets", "the", "color", "of", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L640-L644
3,816
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setAreaFill
public void setAreaFill(final ColorDef AREA_FILL_COLOR) { this.areaFill = AREA_FILL_COLOR; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setAreaFill(final ColorDef AREA_FILL_COLOR) { this.areaFill = AREA_FILL_COLOR; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setAreaFill", "(", "final", "ColorDef", "AREA_FILL_COLOR", ")", "{", "this", ".", "areaFill", "=", "AREA_FILL_COLOR", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Sets the colordefinition of the area below the sparkline @param AREA_FILL_COLOR
[ "Sets", "the", "colordefinition", "of", "the", "area", "below", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L658-L662
3,817
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setCustomAreaFillTop
public void setCustomAreaFillTop(final Color CUSTOM_AREA_FILL_COLOR_TOP) { customAreaFillTop = CUSTOM_AREA_FILL_COLOR_TOP; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setCustomAreaFillTop(final Color CUSTOM_AREA_FILL_COLOR_TOP) { customAreaFillTop = CUSTOM_AREA_FILL_COLOR_TOP; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setCustomAreaFillTop", "(", "final", "Color", "CUSTOM_AREA_FILL_COLOR_TOP", ")", "{", "customAreaFillTop", "=", "CUSTOM_AREA_FILL_COLOR_TOP", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Sets the color that will be used for a custom area gradient at top @param CUSTOM_AREA_FILL_COLOR_TOP
[ "Sets", "the", "color", "that", "will", "be", "used", "for", "a", "custom", "area", "gradient", "at", "top" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L676-L680
3,818
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setCustomAreaFillBottom
public void setCustomAreaFillBottom(final Color CUSTOM_AREA_FILL_COLOR_BOTTOM) { customAreaFillBottom = CUSTOM_AREA_FILL_COLOR_BOTTOM; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setCustomAreaFillBottom(final Color CUSTOM_AREA_FILL_COLOR_BOTTOM) { customAreaFillBottom = CUSTOM_AREA_FILL_COLOR_BOTTOM; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setCustomAreaFillBottom", "(", "final", "Color", "CUSTOM_AREA_FILL_COLOR_BOTTOM", ")", "{", "customAreaFillBottom", "=", "CUSTOM_AREA_FILL_COLOR_BOTTOM", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Sets the color that will be used for a custom area gradient at bottom @param CUSTOM_AREA_FILL_COLOR_BOTTOM
[ "Sets", "the", "color", "that", "will", "be", "used", "for", "a", "custom", "area", "gradient", "at", "bottom" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L694-L698
3,819
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setLineWidth
public void setLineWidth(final float LINE_WIDTH) { lineWidth = LINE_WIDTH; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setLineWidth(final float LINE_WIDTH) { lineWidth = LINE_WIDTH; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setLineWidth", "(", "final", "float", "LINE_WIDTH", ")", "{", "lineWidth", "=", "LINE_WIDTH", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Defines the width of the sparkline @param LINE_WIDTH
[ "Defines", "the", "width", "of", "the", "sparkline" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L712-L716
3,820
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setLineShadow
public void setLineShadow(final boolean LINE_SHADOW_VISIBLE) { lineShadowVisible = LINE_SHADOW_VISIBLE; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setLineShadow(final boolean LINE_SHADOW_VISIBLE) { lineShadowVisible = LINE_SHADOW_VISIBLE; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setLineShadow", "(", "final", "boolean", "LINE_SHADOW_VISIBLE", ")", "{", "lineShadowVisible", "=", "LINE_SHADOW_VISIBLE", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Enables or disables the visibility of the sparkline shadow @param LINE_SHADOW_VISIBLE
[ "Enables", "or", "disables", "the", "visibility", "of", "the", "sparkline", "shadow" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L730-L734
3,821
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.setSmoothFunction
public void setSmoothFunction(final SmoothingFunction SMOOTHING_FUNCTION) { this.smoothFunction = SMOOTHING_FUNCTION; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
java
public void setSmoothFunction(final SmoothingFunction SMOOTHING_FUNCTION) { this.smoothFunction = SMOOTHING_FUNCTION; init(INNER_BOUNDS.width, INNER_BOUNDS.height); repaint(INNER_BOUNDS); }
[ "public", "void", "setSmoothFunction", "(", "final", "SmoothingFunction", "SMOOTHING_FUNCTION", ")", "{", "this", ".", "smoothFunction", "=", "SMOOTHING_FUNCTION", ";", "init", "(", "INNER_BOUNDS", ".", "width", ",", "INNER_BOUNDS", ".", "height", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Defines the smoothing function that will be applied to the data if selected @param SMOOTHING_FUNCTION
[ "Defines", "the", "smoothing", "function", "that", "will", "be", "applied", "to", "the", "data", "if", "selected" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L821-L825
3,822
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.calculate
private void calculate(final int WIDTH, final int HEIGHT) { // Set start and stop values start = DATA_LIST.getFirst().getValue(); stop = DATA_LIST.getLast().getValue(); // Find min and max values lo = DATA_LIST.getFirst().getValue(); hi = DATA_LIST.getFirst().getValue(); loIndex = 0; hiIndex = 0; final int SIZE = DATA_LIST.size(); double y; for (int index = 0; index < SIZE; index++) { y = DATA_LIST.get(index).getValue(); calcHiLoValues(y, index); } // Calculate the range from min to max rangeY = hi - lo; // Calculate the offset between the graph and the border //offset = (double) HEIGHT * OFFSET_FACTOR; // Calculate the scaling in x- and y-direction scaleY = rangeY / ((double) HEIGHT - (offset * 2)); // Fill the pointlist with smoothing if possible pointList.clear(); if (DATA_LIST.size() > 5 && smoothing) { smoothData(); } else { for (int index = 0; index < SIZE; index++) { pointList.add(new Point2D.Double((DATA_LIST.get(index).getTimeStamp() - DATA_LIST.getFirst().getTimeStamp()) * pixelResolution, ((DATA_LIST.get(index).getValue() - lo) * (1 / scaleY) + offset))); } } // Calculate average and normal area if one of them is visible if (averageVisible || normalAreaVisible) { final double AVERAGE = (getAverage() - lo) * (1 / scaleY) + offset; final double STANDARD_DEVIATION = (getStandardDeviation() * (1 / scaleY)); NORMAL_AREA.setRect(INNER_BOUNDS.x, AVERAGE - STANDARD_DEVIATION, INNER_BOUNDS.width, 2 * STANDARD_DEVIATION); AVERAGE_LINE.setLine(INNER_BOUNDS.x, AVERAGE, INNER_BOUNDS.x + INNER_BOUNDS.width, AVERAGE); } }
java
private void calculate(final int WIDTH, final int HEIGHT) { // Set start and stop values start = DATA_LIST.getFirst().getValue(); stop = DATA_LIST.getLast().getValue(); // Find min and max values lo = DATA_LIST.getFirst().getValue(); hi = DATA_LIST.getFirst().getValue(); loIndex = 0; hiIndex = 0; final int SIZE = DATA_LIST.size(); double y; for (int index = 0; index < SIZE; index++) { y = DATA_LIST.get(index).getValue(); calcHiLoValues(y, index); } // Calculate the range from min to max rangeY = hi - lo; // Calculate the offset between the graph and the border //offset = (double) HEIGHT * OFFSET_FACTOR; // Calculate the scaling in x- and y-direction scaleY = rangeY / ((double) HEIGHT - (offset * 2)); // Fill the pointlist with smoothing if possible pointList.clear(); if (DATA_LIST.size() > 5 && smoothing) { smoothData(); } else { for (int index = 0; index < SIZE; index++) { pointList.add(new Point2D.Double((DATA_LIST.get(index).getTimeStamp() - DATA_LIST.getFirst().getTimeStamp()) * pixelResolution, ((DATA_LIST.get(index).getValue() - lo) * (1 / scaleY) + offset))); } } // Calculate average and normal area if one of them is visible if (averageVisible || normalAreaVisible) { final double AVERAGE = (getAverage() - lo) * (1 / scaleY) + offset; final double STANDARD_DEVIATION = (getStandardDeviation() * (1 / scaleY)); NORMAL_AREA.setRect(INNER_BOUNDS.x, AVERAGE - STANDARD_DEVIATION, INNER_BOUNDS.width, 2 * STANDARD_DEVIATION); AVERAGE_LINE.setLine(INNER_BOUNDS.x, AVERAGE, INNER_BOUNDS.x + INNER_BOUNDS.width, AVERAGE); } }
[ "private", "void", "calculate", "(", "final", "int", "WIDTH", ",", "final", "int", "HEIGHT", ")", "{", "// Set start and stop values", "start", "=", "DATA_LIST", ".", "getFirst", "(", ")", ".", "getValue", "(", ")", ";", "stop", "=", "DATA_LIST", ".", "getLast", "(", ")", ".", "getValue", "(", ")", ";", "// Find min and max values", "lo", "=", "DATA_LIST", ".", "getFirst", "(", ")", ".", "getValue", "(", ")", ";", "hi", "=", "DATA_LIST", ".", "getFirst", "(", ")", ".", "getValue", "(", ")", ";", "loIndex", "=", "0", ";", "hiIndex", "=", "0", ";", "final", "int", "SIZE", "=", "DATA_LIST", ".", "size", "(", ")", ";", "double", "y", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "SIZE", ";", "index", "++", ")", "{", "y", "=", "DATA_LIST", ".", "get", "(", "index", ")", ".", "getValue", "(", ")", ";", "calcHiLoValues", "(", "y", ",", "index", ")", ";", "}", "// Calculate the range from min to max", "rangeY", "=", "hi", "-", "lo", ";", "// Calculate the offset between the graph and the border", "//offset = (double) HEIGHT * OFFSET_FACTOR;", "// Calculate the scaling in x- and y-direction", "scaleY", "=", "rangeY", "/", "(", "(", "double", ")", "HEIGHT", "-", "(", "offset", "*", "2", ")", ")", ";", "// Fill the pointlist with smoothing if possible", "pointList", ".", "clear", "(", ")", ";", "if", "(", "DATA_LIST", ".", "size", "(", ")", ">", "5", "&&", "smoothing", ")", "{", "smoothData", "(", ")", ";", "}", "else", "{", "for", "(", "int", "index", "=", "0", ";", "index", "<", "SIZE", ";", "index", "++", ")", "{", "pointList", ".", "add", "(", "new", "Point2D", ".", "Double", "(", "(", "DATA_LIST", ".", "get", "(", "index", ")", ".", "getTimeStamp", "(", ")", "-", "DATA_LIST", ".", "getFirst", "(", ")", ".", "getTimeStamp", "(", ")", ")", "*", "pixelResolution", ",", "(", "(", "DATA_LIST", ".", "get", "(", "index", ")", ".", "getValue", "(", ")", "-", "lo", ")", "*", "(", "1", "/", "scaleY", ")", "+", "offset", ")", ")", ")", ";", "}", "}", "// Calculate average and normal area if one of them is visible", "if", "(", "averageVisible", "||", "normalAreaVisible", ")", "{", "final", "double", "AVERAGE", "=", "(", "getAverage", "(", ")", "-", "lo", ")", "*", "(", "1", "/", "scaleY", ")", "+", "offset", ";", "final", "double", "STANDARD_DEVIATION", "=", "(", "getStandardDeviation", "(", ")", "*", "(", "1", "/", "scaleY", ")", ")", ";", "NORMAL_AREA", ".", "setRect", "(", "INNER_BOUNDS", ".", "x", ",", "AVERAGE", "-", "STANDARD_DEVIATION", ",", "INNER_BOUNDS", ".", "width", ",", "2", "*", "STANDARD_DEVIATION", ")", ";", "AVERAGE_LINE", ".", "setLine", "(", "INNER_BOUNDS", ".", "x", ",", "AVERAGE", ",", "INNER_BOUNDS", ".", "x", "+", "INNER_BOUNDS", ".", "width", ",", "AVERAGE", ")", ";", "}", "}" ]
Calculates the sparkline with all it's parameters. This methods will be called everytime a new value was added to the DATA_LIST @param WIDTH @param HEIGHT
[ "Calculates", "the", "sparkline", "with", "all", "it", "s", "parameters", ".", "This", "methods", "will", "be", "called", "everytime", "a", "new", "value", "was", "added", "to", "the", "DATA_LIST" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L936-L979
3,823
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.calcHiLoValues
private void calcHiLoValues(double y, int index) { if (y < lo) { lo = y; loIndex = index; } if (y > hi) { hi = y; hiIndex = index; } }
java
private void calcHiLoValues(double y, int index) { if (y < lo) { lo = y; loIndex = index; } if (y > hi) { hi = y; hiIndex = index; } }
[ "private", "void", "calcHiLoValues", "(", "double", "y", ",", "int", "index", ")", "{", "if", "(", "y", "<", "lo", ")", "{", "lo", "=", "y", ";", "loIndex", "=", "index", ";", "}", "if", "(", "y", ">", "hi", ")", "{", "hi", "=", "y", ";", "hiIndex", "=", "index", ";", "}", "}" ]
Calculates the max and min measured values and stores the index of the related values in in loIndex and hiIndex. @param y @param index
[ "Calculates", "the", "max", "and", "min", "measured", "values", "and", "stores", "the", "index", "of", "the", "related", "values", "in", "in", "loIndex", "and", "hiIndex", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1036-L1046
3,824
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.sortData
private void sortData() { sortedList.clear(); for (DataPoint dataPoint : DATA_LIST) { sortedList.add(dataPoint.getValue()); } Collections.sort(sortedList); }
java
private void sortData() { sortedList.clear(); for (DataPoint dataPoint : DATA_LIST) { sortedList.add(dataPoint.getValue()); } Collections.sort(sortedList); }
[ "private", "void", "sortData", "(", ")", "{", "sortedList", ".", "clear", "(", ")", ";", "for", "(", "DataPoint", "dataPoint", ":", "DATA_LIST", ")", "{", "sortedList", ".", "add", "(", "dataPoint", ".", "getValue", "(", ")", ")", ";", "}", "Collections", ".", "sort", "(", "sortedList", ")", ";", "}" ]
Puts all values in a ArrayList and sorts them
[ "Puts", "all", "values", "in", "a", "ArrayList", "and", "sorts", "them" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1051-L1057
3,825
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.continuousAverage
private double continuousAverage(final double Y0, final double Y1, final double Y2) { final double A = 1; final double B = 1; final double C = 1; return ((A * Y0) + (B * Y1) + (C * Y2)) / (A + B + C); }
java
private double continuousAverage(final double Y0, final double Y1, final double Y2) { final double A = 1; final double B = 1; final double C = 1; return ((A * Y0) + (B * Y1) + (C * Y2)) / (A + B + C); }
[ "private", "double", "continuousAverage", "(", "final", "double", "Y0", ",", "final", "double", "Y1", ",", "final", "double", "Y2", ")", "{", "final", "double", "A", "=", "1", ";", "final", "double", "B", "=", "1", ";", "final", "double", "C", "=", "1", ";", "return", "(", "(", "A", "*", "Y0", ")", "+", "(", "B", "*", "Y1", ")", "+", "(", "C", "*", "Y2", ")", ")", "/", "(", "A", "+", "B", "+", "C", ")", ";", "}" ]
Returns the value smoothed by a continuous average function @param Y0 @param Y1 @param Y2 @return the value smoothed by a continous average function
[ "Returns", "the", "value", "smoothed", "by", "a", "continuous", "average", "function" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1068-L1074
3,826
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.cubicInterpolate
private double cubicInterpolate(final double Y0, final double Y1, final double Y2, final double Y3, final double MU) { final double A0; final double A1; final double A2; final double A3; final double MU2; MU2 = MU * MU; A0 = Y3 - Y2 - Y0 + Y1; A1 = Y0 - Y1 - A0; A2 = Y2 - Y0; A3 = Y1; return ((A0 * MU * MU2) + (A1 * MU2) + (A2 * MU) + A3); }
java
private double cubicInterpolate(final double Y0, final double Y1, final double Y2, final double Y3, final double MU) { final double A0; final double A1; final double A2; final double A3; final double MU2; MU2 = MU * MU; A0 = Y3 - Y2 - Y0 + Y1; A1 = Y0 - Y1 - A0; A2 = Y2 - Y0; A3 = Y1; return ((A0 * MU * MU2) + (A1 * MU2) + (A2 * MU) + A3); }
[ "private", "double", "cubicInterpolate", "(", "final", "double", "Y0", ",", "final", "double", "Y1", ",", "final", "double", "Y2", ",", "final", "double", "Y3", ",", "final", "double", "MU", ")", "{", "final", "double", "A0", ";", "final", "double", "A1", ";", "final", "double", "A2", ";", "final", "double", "A3", ";", "final", "double", "MU2", ";", "MU2", "=", "MU", "*", "MU", ";", "A0", "=", "Y3", "-", "Y2", "-", "Y0", "+", "Y1", ";", "A1", "=", "Y0", "-", "Y1", "-", "A0", ";", "A2", "=", "Y2", "-", "Y0", ";", "A3", "=", "Y1", ";", "return", "(", "(", "A0", "*", "MU", "*", "MU2", ")", "+", "(", "A1", "*", "MU2", ")", "+", "(", "A2", "*", "MU", ")", "+", "A3", ")", ";", "}" ]
Returns the value smoothed by a cubic spline interpolation function @param Y0 @param Y1 @param Y2 @param Y3 @param MU @return the value smoothed by a cubic spline interpolation function
[ "Returns", "the", "value", "smoothed", "by", "a", "cubic", "spline", "interpolation", "function" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1085-L1099
3,827
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.cosInterpolate
private double cosInterpolate(final double Y1, final double Y2, final double MU) { final double MU2; MU2 = (1 - Math.cos(MU * Math.PI)) / 2; return (Y1 * (1 - MU2) + Y2 * MU2); }
java
private double cosInterpolate(final double Y1, final double Y2, final double MU) { final double MU2; MU2 = (1 - Math.cos(MU * Math.PI)) / 2; return (Y1 * (1 - MU2) + Y2 * MU2); }
[ "private", "double", "cosInterpolate", "(", "final", "double", "Y1", ",", "final", "double", "Y2", ",", "final", "double", "MU", ")", "{", "final", "double", "MU2", ";", "MU2", "=", "(", "1", "-", "Math", ".", "cos", "(", "MU", "*", "Math", ".", "PI", ")", ")", "/", "2", ";", "return", "(", "Y1", "*", "(", "1", "-", "MU2", ")", "+", "Y2", "*", "MU2", ")", ";", "}" ]
Returns the value smoothed by a cosinus interpolation function @param Y1 @param Y2 @param MU @return the value smoothed by a cosinus interpolation function
[ "Returns", "the", "value", "smoothed", "by", "a", "cosinus", "interpolation", "function" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1108-L1113
3,828
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.hermiteInterpolate
private double hermiteInterpolate(final double Y0, final double Y1, final double Y2, final double Y3, final double MU, final double TENSION, final double BIAS) { double m0; double m1; final double MU2; final double Mu3; final double A0; final double A1; final double A2; final double A3; MU2 = MU * MU; Mu3 = MU2 * MU; m0 = (Y1 - Y0) * (1 + BIAS) * (1 - TENSION) / 2; m0 += (Y2 - Y1) * (1 - BIAS) * (1 - TENSION) / 2; m1 = (Y2 - Y1) * (1 + BIAS) * (1 - TENSION) / 2; m1 += (Y3 - Y2) * (1 - BIAS) * (1 - TENSION) / 2; A0 = (2 * Mu3) - (3 * MU2) + 1; A1 = Mu3 - (2 * MU2) + MU; A2 = Mu3 - MU2; A3 = (-2 * Mu3) + (3 * MU2); return ((A0 * Y1) + (A1 * m0) + (A2 * m1) + (A3 * Y2)); }
java
private double hermiteInterpolate(final double Y0, final double Y1, final double Y2, final double Y3, final double MU, final double TENSION, final double BIAS) { double m0; double m1; final double MU2; final double Mu3; final double A0; final double A1; final double A2; final double A3; MU2 = MU * MU; Mu3 = MU2 * MU; m0 = (Y1 - Y0) * (1 + BIAS) * (1 - TENSION) / 2; m0 += (Y2 - Y1) * (1 - BIAS) * (1 - TENSION) / 2; m1 = (Y2 - Y1) * (1 + BIAS) * (1 - TENSION) / 2; m1 += (Y3 - Y2) * (1 - BIAS) * (1 - TENSION) / 2; A0 = (2 * Mu3) - (3 * MU2) + 1; A1 = Mu3 - (2 * MU2) + MU; A2 = Mu3 - MU2; A3 = (-2 * Mu3) + (3 * MU2); return ((A0 * Y1) + (A1 * m0) + (A2 * m1) + (A3 * Y2)); }
[ "private", "double", "hermiteInterpolate", "(", "final", "double", "Y0", ",", "final", "double", "Y1", ",", "final", "double", "Y2", ",", "final", "double", "Y3", ",", "final", "double", "MU", ",", "final", "double", "TENSION", ",", "final", "double", "BIAS", ")", "{", "double", "m0", ";", "double", "m1", ";", "final", "double", "MU2", ";", "final", "double", "Mu3", ";", "final", "double", "A0", ";", "final", "double", "A1", ";", "final", "double", "A2", ";", "final", "double", "A3", ";", "MU2", "=", "MU", "*", "MU", ";", "Mu3", "=", "MU2", "*", "MU", ";", "m0", "=", "(", "Y1", "-", "Y0", ")", "*", "(", "1", "+", "BIAS", ")", "*", "(", "1", "-", "TENSION", ")", "/", "2", ";", "m0", "+=", "(", "Y2", "-", "Y1", ")", "*", "(", "1", "-", "BIAS", ")", "*", "(", "1", "-", "TENSION", ")", "/", "2", ";", "m1", "=", "(", "Y2", "-", "Y1", ")", "*", "(", "1", "+", "BIAS", ")", "*", "(", "1", "-", "TENSION", ")", "/", "2", ";", "m1", "+=", "(", "Y3", "-", "Y2", ")", "*", "(", "1", "-", "BIAS", ")", "*", "(", "1", "-", "TENSION", ")", "/", "2", ";", "A0", "=", "(", "2", "*", "Mu3", ")", "-", "(", "3", "*", "MU2", ")", "+", "1", ";", "A1", "=", "Mu3", "-", "(", "2", "*", "MU2", ")", "+", "MU", ";", "A2", "=", "Mu3", "-", "MU2", ";", "A3", "=", "(", "-", "2", "*", "Mu3", ")", "+", "(", "3", "*", "MU2", ")", ";", "return", "(", "(", "A0", "*", "Y1", ")", "+", "(", "A1", "*", "m0", ")", "+", "(", "A2", "*", "m1", ")", "+", "(", "A3", "*", "Y2", ")", ")", ";", "}" ]
Returns the value smoothed by a hermite interpolation function @param Y0 @param Y1 @param Y2 @param Y3 @param MU @param TENSION @param BIAS @return the value smoothed by a hermite interpolation function
[ "Returns", "the", "value", "smoothed", "by", "a", "hermite", "interpolation", "function" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1126-L1149
3,829
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java
SparkLine.create_HI_INDICATOR_Image
private BufferedImage create_HI_INDICATOR_Image(final int WIDTH) { if (WIDTH <= 0) { return null; } // Define the size of the indicator int indicatorSize = (int) (0.015 * WIDTH); if (indicatorSize < 4) { indicatorSize = 4; } if (indicatorSize > 8) { indicatorSize = 8; } final BufferedImage IMAGE = UTIL.createImage(indicatorSize, indicatorSize, Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); G2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); final int IMAGE_WIDTH = IMAGE.getWidth(); final int IMAGE_HEIGHT = IMAGE.getHeight(); final GeneralPath THRESHOLD_TRIANGLE = new GeneralPath(); THRESHOLD_TRIANGLE.setWindingRule(Path2D.WIND_EVEN_ODD); THRESHOLD_TRIANGLE.moveTo(IMAGE_WIDTH * 0.5, 0); THRESHOLD_TRIANGLE.lineTo(0, IMAGE_HEIGHT); THRESHOLD_TRIANGLE.lineTo(IMAGE_WIDTH, IMAGE_HEIGHT); THRESHOLD_TRIANGLE.lineTo(IMAGE_WIDTH * 0.5, 0); THRESHOLD_TRIANGLE.closePath(); final Point2D THRESHOLD_TRIANGLE_START = new Point2D.Double(0, THRESHOLD_TRIANGLE.getBounds2D().getMinY()); final Point2D THRESHOLD_TRIANGLE_STOP = new Point2D.Double(0, THRESHOLD_TRIANGLE.getBounds2D().getMaxY()); final float[] THRESHOLD_TRIANGLE_FRACTIONS = { 0.0f, 0.3f, 0.59f, 1.0f }; final Color[] THRESHOLD_TRIANGLE_COLORS = { new Color(82, 0, 0, 255), new Color(252, 29, 0, 255), new Color(252, 29, 0, 255), new Color(82, 0, 0, 255) }; final LinearGradientPaint THRESHOLD_TRIANGLE_GRADIENT = new LinearGradientPaint(THRESHOLD_TRIANGLE_START, THRESHOLD_TRIANGLE_STOP, THRESHOLD_TRIANGLE_FRACTIONS, THRESHOLD_TRIANGLE_COLORS); G2.setPaint(THRESHOLD_TRIANGLE_GRADIENT); G2.fill(THRESHOLD_TRIANGLE); G2.setColor(Color.RED); G2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); G2.draw(THRESHOLD_TRIANGLE); G2.dispose(); return IMAGE; }
java
private BufferedImage create_HI_INDICATOR_Image(final int WIDTH) { if (WIDTH <= 0) { return null; } // Define the size of the indicator int indicatorSize = (int) (0.015 * WIDTH); if (indicatorSize < 4) { indicatorSize = 4; } if (indicatorSize > 8) { indicatorSize = 8; } final BufferedImage IMAGE = UTIL.createImage(indicatorSize, indicatorSize, Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); G2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); final int IMAGE_WIDTH = IMAGE.getWidth(); final int IMAGE_HEIGHT = IMAGE.getHeight(); final GeneralPath THRESHOLD_TRIANGLE = new GeneralPath(); THRESHOLD_TRIANGLE.setWindingRule(Path2D.WIND_EVEN_ODD); THRESHOLD_TRIANGLE.moveTo(IMAGE_WIDTH * 0.5, 0); THRESHOLD_TRIANGLE.lineTo(0, IMAGE_HEIGHT); THRESHOLD_TRIANGLE.lineTo(IMAGE_WIDTH, IMAGE_HEIGHT); THRESHOLD_TRIANGLE.lineTo(IMAGE_WIDTH * 0.5, 0); THRESHOLD_TRIANGLE.closePath(); final Point2D THRESHOLD_TRIANGLE_START = new Point2D.Double(0, THRESHOLD_TRIANGLE.getBounds2D().getMinY()); final Point2D THRESHOLD_TRIANGLE_STOP = new Point2D.Double(0, THRESHOLD_TRIANGLE.getBounds2D().getMaxY()); final float[] THRESHOLD_TRIANGLE_FRACTIONS = { 0.0f, 0.3f, 0.59f, 1.0f }; final Color[] THRESHOLD_TRIANGLE_COLORS = { new Color(82, 0, 0, 255), new Color(252, 29, 0, 255), new Color(252, 29, 0, 255), new Color(82, 0, 0, 255) }; final LinearGradientPaint THRESHOLD_TRIANGLE_GRADIENT = new LinearGradientPaint(THRESHOLD_TRIANGLE_START, THRESHOLD_TRIANGLE_STOP, THRESHOLD_TRIANGLE_FRACTIONS, THRESHOLD_TRIANGLE_COLORS); G2.setPaint(THRESHOLD_TRIANGLE_GRADIENT); G2.fill(THRESHOLD_TRIANGLE); G2.setColor(Color.RED); G2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); G2.draw(THRESHOLD_TRIANGLE); G2.dispose(); return IMAGE; }
[ "private", "BufferedImage", "create_HI_INDICATOR_Image", "(", "final", "int", "WIDTH", ")", "{", "if", "(", "WIDTH", "<=", "0", ")", "{", "return", "null", ";", "}", "// Define the size of the indicator", "int", "indicatorSize", "=", "(", "int", ")", "(", "0.015", "*", "WIDTH", ")", ";", "if", "(", "indicatorSize", "<", "4", ")", "{", "indicatorSize", "=", "4", ";", "}", "if", "(", "indicatorSize", ">", "8", ")", "{", "indicatorSize", "=", "8", ";", "}", "final", "BufferedImage", "IMAGE", "=", "UTIL", ".", "createImage", "(", "indicatorSize", ",", "indicatorSize", ",", "Transparency", ".", "TRANSLUCENT", ")", ";", "final", "Graphics2D", "G2", "=", "IMAGE", ".", "createGraphics", "(", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_RENDERING", ",", "RenderingHints", ".", "VALUE_RENDER_QUALITY", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_DITHERING", ",", "RenderingHints", ".", "VALUE_DITHER_ENABLE", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_ALPHA_INTERPOLATION", ",", "RenderingHints", ".", "VALUE_ALPHA_INTERPOLATION_QUALITY", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_COLOR_RENDERING", ",", "RenderingHints", ".", "VALUE_COLOR_RENDER_QUALITY", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_STROKE_CONTROL", ",", "RenderingHints", ".", "VALUE_STROKE_NORMALIZE", ")", ";", "G2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_TEXT_ANTIALIASING", ",", "RenderingHints", ".", "VALUE_TEXT_ANTIALIAS_ON", ")", ";", "final", "int", "IMAGE_WIDTH", "=", "IMAGE", ".", "getWidth", "(", ")", ";", "final", "int", "IMAGE_HEIGHT", "=", "IMAGE", ".", "getHeight", "(", ")", ";", "final", "GeneralPath", "THRESHOLD_TRIANGLE", "=", "new", "GeneralPath", "(", ")", ";", "THRESHOLD_TRIANGLE", ".", "setWindingRule", "(", "Path2D", ".", "WIND_EVEN_ODD", ")", ";", "THRESHOLD_TRIANGLE", ".", "moveTo", "(", "IMAGE_WIDTH", "*", "0.5", ",", "0", ")", ";", "THRESHOLD_TRIANGLE", ".", "lineTo", "(", "0", ",", "IMAGE_HEIGHT", ")", ";", "THRESHOLD_TRIANGLE", ".", "lineTo", "(", "IMAGE_WIDTH", ",", "IMAGE_HEIGHT", ")", ";", "THRESHOLD_TRIANGLE", ".", "lineTo", "(", "IMAGE_WIDTH", "*", "0.5", ",", "0", ")", ";", "THRESHOLD_TRIANGLE", ".", "closePath", "(", ")", ";", "final", "Point2D", "THRESHOLD_TRIANGLE_START", "=", "new", "Point2D", ".", "Double", "(", "0", ",", "THRESHOLD_TRIANGLE", ".", "getBounds2D", "(", ")", ".", "getMinY", "(", ")", ")", ";", "final", "Point2D", "THRESHOLD_TRIANGLE_STOP", "=", "new", "Point2D", ".", "Double", "(", "0", ",", "THRESHOLD_TRIANGLE", ".", "getBounds2D", "(", ")", ".", "getMaxY", "(", ")", ")", ";", "final", "float", "[", "]", "THRESHOLD_TRIANGLE_FRACTIONS", "=", "{", "0.0f", ",", "0.3f", ",", "0.59f", ",", "1.0f", "}", ";", "final", "Color", "[", "]", "THRESHOLD_TRIANGLE_COLORS", "=", "{", "new", "Color", "(", "82", ",", "0", ",", "0", ",", "255", ")", ",", "new", "Color", "(", "252", ",", "29", ",", "0", ",", "255", ")", ",", "new", "Color", "(", "252", ",", "29", ",", "0", ",", "255", ")", ",", "new", "Color", "(", "82", ",", "0", ",", "0", ",", "255", ")", "}", ";", "final", "LinearGradientPaint", "THRESHOLD_TRIANGLE_GRADIENT", "=", "new", "LinearGradientPaint", "(", "THRESHOLD_TRIANGLE_START", ",", "THRESHOLD_TRIANGLE_STOP", ",", "THRESHOLD_TRIANGLE_FRACTIONS", ",", "THRESHOLD_TRIANGLE_COLORS", ")", ";", "G2", ".", "setPaint", "(", "THRESHOLD_TRIANGLE_GRADIENT", ")", ";", "G2", ".", "fill", "(", "THRESHOLD_TRIANGLE", ")", ";", "G2", ".", "setColor", "(", "Color", ".", "RED", ")", ";", "G2", ".", "setStroke", "(", "new", "BasicStroke", "(", "1.0f", ",", "BasicStroke", ".", "CAP_BUTT", ",", "BasicStroke", ".", "JOIN_MITER", ")", ")", ";", "G2", ".", "draw", "(", "THRESHOLD_TRIANGLE", ")", ";", "G2", ".", "dispose", "(", ")", ";", "return", "IMAGE", ";", "}" ]
Returns a buffered image that contains the hi value indicator @param WIDTH @return a buffered image that contains the hi value indicator
[ "Returns", "a", "buffered", "image", "that", "contains", "the", "hi", "value", "indicator" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/SparkLine.java#L1447-L1505
3,830
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Clock.java
Clock.setHour
public void setHour(final int HOUR) { hour = HOUR % 12; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
java
public void setHour(final int HOUR) { hour = HOUR % 12; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
[ "public", "void", "setHour", "(", "final", "int", "HOUR", ")", "{", "hour", "=", "HOUR", "%", "12", ";", "calculateAngles", "(", "hour", ",", "minute", ",", "second", ")", ";", "repaint", "(", "getInnerBounds", "(", ")", ")", ";", "}" ]
Sets the current hour of the clock @param HOUR
[ "Sets", "the", "current", "hour", "of", "the", "clock" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Clock.java#L322-L326
3,831
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Clock.java
Clock.setMinute
public void setMinute(final int MINUTE) { minute = MINUTE % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
java
public void setMinute(final int MINUTE) { minute = MINUTE % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
[ "public", "void", "setMinute", "(", "final", "int", "MINUTE", ")", "{", "minute", "=", "MINUTE", "%", "60", ";", "calculateAngles", "(", "hour", ",", "minute", ",", "second", ")", ";", "repaint", "(", "getInnerBounds", "(", ")", ")", ";", "}" ]
Sets the current minute of the clock @param MINUTE
[ "Sets", "the", "current", "minute", "of", "the", "clock" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Clock.java#L340-L344
3,832
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Clock.java
Clock.setSecond
public void setSecond(final int SECOND) { second = SECOND % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
java
public void setSecond(final int SECOND) { second = SECOND % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
[ "public", "void", "setSecond", "(", "final", "int", "SECOND", ")", "{", "second", "=", "SECOND", "%", "60", ";", "calculateAngles", "(", "hour", ",", "minute", ",", "second", ")", ";", "repaint", "(", "getInnerBounds", "(", ")", ")", ";", "}" ]
Sets the current second of the clock @param SECOND
[ "Sets", "the", "current", "second", "of", "the", "clock" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Clock.java#L358-L362
3,833
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Poi.java
Poi.setLocation
public void setLocation(final Point2D LOCATION) { this.lon = LOCATION.getX(); this.lat = LOCATION.getY(); this.LOCATION.setLocation(LOCATION); this.LOCATION_XY.setLocation(toXY(this.lat, this.lon)); adjustDirection(); }
java
public void setLocation(final Point2D LOCATION) { this.lon = LOCATION.getX(); this.lat = LOCATION.getY(); this.LOCATION.setLocation(LOCATION); this.LOCATION_XY.setLocation(toXY(this.lat, this.lon)); adjustDirection(); }
[ "public", "void", "setLocation", "(", "final", "Point2D", "LOCATION", ")", "{", "this", ".", "lon", "=", "LOCATION", ".", "getX", "(", ")", ";", "this", ".", "lat", "=", "LOCATION", ".", "getY", "(", ")", ";", "this", ".", "LOCATION", ".", "setLocation", "(", "LOCATION", ")", ";", "this", ".", "LOCATION_XY", ".", "setLocation", "(", "toXY", "(", "this", ".", "lat", ",", "this", ".", "lon", ")", ")", ";", "adjustDirection", "(", ")", ";", "}" ]
Sets the location of the poi by the given Point2D @param LOCATION
[ "Sets", "the", "location", "of", "the", "poi", "by", "the", "given", "Point2D" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Poi.java#L321-L327
3,834
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Poi.java
Poi.setLocation
public final void setLocation(final double LAT, final double LON) { this.lon = LON; // X this.lat = LAT; // Y this.LOCATION.setLocation(LON, LAT); this.LOCATION_XY.setLocation(toXY(LAT, LON)); adjustDirection(); }
java
public final void setLocation(final double LAT, final double LON) { this.lon = LON; // X this.lat = LAT; // Y this.LOCATION.setLocation(LON, LAT); this.LOCATION_XY.setLocation(toXY(LAT, LON)); adjustDirection(); }
[ "public", "final", "void", "setLocation", "(", "final", "double", "LAT", ",", "final", "double", "LON", ")", "{", "this", ".", "lon", "=", "LON", ";", "// X", "this", ".", "lat", "=", "LAT", ";", "// Y", "this", ".", "LOCATION", ".", "setLocation", "(", "LON", ",", "LAT", ")", ";", "this", ".", "LOCATION_XY", ".", "setLocation", "(", "toXY", "(", "LAT", ",", "LON", ")", ")", ";", "adjustDirection", "(", ")", ";", "}" ]
Sets the location of the poi by the given latitude and longitude values @param LAT @param LON
[ "Sets", "the", "location", "of", "the", "poi", "by", "the", "given", "latitude", "and", "longitude", "values" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Poi.java#L335-L341
3,835
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Poi.java
Poi.distanceTo
public double distanceTo(final double LAT, final double LON) { final double EARTH_RADIUS = 6371000.0; // m return Math.abs(Math.acos(Math.sin(Math.toRadians(LAT)) * Math.sin(Math.toRadians(this.lat)) + Math.cos(Math.toRadians(LAT)) * Math.cos(Math.toRadians(this.lat)) * Math.cos(Math.toRadians(LON - this.lon))) * EARTH_RADIUS); }
java
public double distanceTo(final double LAT, final double LON) { final double EARTH_RADIUS = 6371000.0; // m return Math.abs(Math.acos(Math.sin(Math.toRadians(LAT)) * Math.sin(Math.toRadians(this.lat)) + Math.cos(Math.toRadians(LAT)) * Math.cos(Math.toRadians(this.lat)) * Math.cos(Math.toRadians(LON - this.lon))) * EARTH_RADIUS); }
[ "public", "double", "distanceTo", "(", "final", "double", "LAT", ",", "final", "double", "LON", ")", "{", "final", "double", "EARTH_RADIUS", "=", "6371000.0", ";", "// m", "return", "Math", ".", "abs", "(", "Math", ".", "acos", "(", "Math", ".", "sin", "(", "Math", ".", "toRadians", "(", "LAT", ")", ")", "*", "Math", ".", "sin", "(", "Math", ".", "toRadians", "(", "this", ".", "lat", ")", ")", "+", "Math", ".", "cos", "(", "Math", ".", "toRadians", "(", "LAT", ")", ")", "*", "Math", ".", "cos", "(", "Math", ".", "toRadians", "(", "this", ".", "lat", ")", ")", "*", "Math", ".", "cos", "(", "Math", ".", "toRadians", "(", "LON", "-", "this", ".", "lon", ")", ")", ")", "*", "EARTH_RADIUS", ")", ";", "}" ]
Returns the distance in meters of the poi to the coordinate defined by the given latitude and longitude. The calculation takes the earth radius into account. @param LAT @param LON @return the distance in meters to the given coordinate
[ "Returns", "the", "distance", "in", "meters", "of", "the", "poi", "to", "the", "coordinate", "defined", "by", "the", "given", "latitude", "and", "longitude", ".", "The", "calculation", "takes", "the", "earth", "radius", "into", "account", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Poi.java#L371-L374
3,836
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Poi.java
Poi.shiftTo
public Point2D shiftTo(final double DISTANCE, final double ANGLE) { final double EARTH_RADIUS = 6371000.0; // m final double LON1 = Math.toRadians(this.lon); final double LAT1 = Math.toRadians(this.lat); final double LAT2 = Math.asin(Math.sin(LAT1) * Math.cos(DISTANCE / EARTH_RADIUS) + Math.cos(LAT1) * Math.sin(DISTANCE / EARTH_RADIUS) * Math.cos(Math.toRadians(ANGLE))); final double LON2 = LON1 + Math.atan2(Math.sin(Math.toRadians(ANGLE)) * Math.sin(DISTANCE / EARTH_RADIUS) * Math.cos(LAT1), Math.cos(DISTANCE / EARTH_RADIUS) - Math.sin(LAT1) * Math.sin(LAT2)); final double LON2_CORRECTED = (LON2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI; //normalise to -180...+180 setLocation(Math.toDegrees(LAT2), Math.toDegrees(LON2_CORRECTED)); return getLocation(); }
java
public Point2D shiftTo(final double DISTANCE, final double ANGLE) { final double EARTH_RADIUS = 6371000.0; // m final double LON1 = Math.toRadians(this.lon); final double LAT1 = Math.toRadians(this.lat); final double LAT2 = Math.asin(Math.sin(LAT1) * Math.cos(DISTANCE / EARTH_RADIUS) + Math.cos(LAT1) * Math.sin(DISTANCE / EARTH_RADIUS) * Math.cos(Math.toRadians(ANGLE))); final double LON2 = LON1 + Math.atan2(Math.sin(Math.toRadians(ANGLE)) * Math.sin(DISTANCE / EARTH_RADIUS) * Math.cos(LAT1), Math.cos(DISTANCE / EARTH_RADIUS) - Math.sin(LAT1) * Math.sin(LAT2)); final double LON2_CORRECTED = (LON2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI; //normalise to -180...+180 setLocation(Math.toDegrees(LAT2), Math.toDegrees(LON2_CORRECTED)); return getLocation(); }
[ "public", "Point2D", "shiftTo", "(", "final", "double", "DISTANCE", ",", "final", "double", "ANGLE", ")", "{", "final", "double", "EARTH_RADIUS", "=", "6371000.0", ";", "// m", "final", "double", "LON1", "=", "Math", ".", "toRadians", "(", "this", ".", "lon", ")", ";", "final", "double", "LAT1", "=", "Math", ".", "toRadians", "(", "this", ".", "lat", ")", ";", "final", "double", "LAT2", "=", "Math", ".", "asin", "(", "Math", ".", "sin", "(", "LAT1", ")", "*", "Math", ".", "cos", "(", "DISTANCE", "/", "EARTH_RADIUS", ")", "+", "Math", ".", "cos", "(", "LAT1", ")", "*", "Math", ".", "sin", "(", "DISTANCE", "/", "EARTH_RADIUS", ")", "*", "Math", ".", "cos", "(", "Math", ".", "toRadians", "(", "ANGLE", ")", ")", ")", ";", "final", "double", "LON2", "=", "LON1", "+", "Math", ".", "atan2", "(", "Math", ".", "sin", "(", "Math", ".", "toRadians", "(", "ANGLE", ")", ")", "*", "Math", ".", "sin", "(", "DISTANCE", "/", "EARTH_RADIUS", ")", "*", "Math", ".", "cos", "(", "LAT1", ")", ",", "Math", ".", "cos", "(", "DISTANCE", "/", "EARTH_RADIUS", ")", "-", "Math", ".", "sin", "(", "LAT1", ")", "*", "Math", ".", "sin", "(", "LAT2", ")", ")", ";", "final", "double", "LON2_CORRECTED", "=", "(", "LON2", "+", "3", "*", "Math", ".", "PI", ")", "%", "(", "2", "*", "Math", ".", "PI", ")", "-", "Math", ".", "PI", ";", "//normalise to -180...+180", "setLocation", "(", "Math", ".", "toDegrees", "(", "LAT2", ")", ",", "Math", ".", "toDegrees", "(", "LON2_CORRECTED", ")", ")", ";", "return", "getLocation", "(", ")", ";", "}" ]
Moves the poi to the position defined by the given distance and angle @param DISTANCE @param ANGLE @return the poi moved by the given distance and angle
[ "Moves", "the", "poi", "to", "the", "position", "defined", "by", "the", "given", "distance", "and", "angle" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Poi.java#L382-L393
3,837
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Poi.java
Poi.toXY
public final Point2D toXY(final double LAT, final double LON) { final double LATITUDE = (LAT * (-1)) + 90.0; final double LONGITUDE = LON + 180.0; final double X = Math.round(LONGITUDE * (WORLD_MAP.getWidth() / 360)); final double Y = Math.round(LATITUDE * (WORLD_MAP.getHeight() / 180)); return new java.awt.geom.Point2D.Double(X, Y); }
java
public final Point2D toXY(final double LAT, final double LON) { final double LATITUDE = (LAT * (-1)) + 90.0; final double LONGITUDE = LON + 180.0; final double X = Math.round(LONGITUDE * (WORLD_MAP.getWidth() / 360)); final double Y = Math.round(LATITUDE * (WORLD_MAP.getHeight() / 180)); return new java.awt.geom.Point2D.Double(X, Y); }
[ "public", "final", "Point2D", "toXY", "(", "final", "double", "LAT", ",", "final", "double", "LON", ")", "{", "final", "double", "LATITUDE", "=", "(", "LAT", "*", "(", "-", "1", ")", ")", "+", "90.0", ";", "final", "double", "LONGITUDE", "=", "LON", "+", "180.0", ";", "final", "double", "X", "=", "Math", ".", "round", "(", "LONGITUDE", "*", "(", "WORLD_MAP", ".", "getWidth", "(", ")", "/", "360", ")", ")", ";", "final", "double", "Y", "=", "Math", ".", "round", "(", "LATITUDE", "*", "(", "WORLD_MAP", ".", "getHeight", "(", ")", "/", "180", ")", ")", ";", "return", "new", "java", ".", "awt", ".", "geom", ".", "Point2D", ".", "Double", "(", "X", ",", "Y", ")", ";", "}" ]
Converts the given latitude and longitude to x,y values @param LAT @param LON @return Point2D with the location of the given lat, lon
[ "Converts", "the", "given", "latitude", "and", "longitude", "to", "x", "y", "values" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Poi.java#L439-L447
3,838
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Poi.java
Poi.create_POI_Image
private BufferedImage create_POI_Image(final int WIDTH) { if (WIDTH <= 0) { return null; } final java.awt.image.BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, java.awt.Transparency.TRANSLUCENT); final java.awt.Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); //G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY); //G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE); //G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); //G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY); G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_NORMALIZE); //G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON); final java.awt.geom.Ellipse2D BLIP = new java.awt.geom.Ellipse2D.Double(0, 0, WIDTH, WIDTH); final java.awt.geom.Point2D CENTER = new java.awt.geom.Point2D.Double(BLIP.getCenterX(), BLIP.getCenterY()); final float[] FRACTIONS = { 0.0f, 1.0f }; final Color[] COLORS = { new Color(1.0f, 1.0f, 1.0f, 0.9f), new Color(1.0f, 1.0f, 1.0f, 0.0f) }; final java.awt.RadialGradientPaint GRADIENT = new java.awt.RadialGradientPaint(CENTER, (int) (WIDTH / 2.0), FRACTIONS, COLORS); G2.setPaint(GRADIENT); G2.fill(BLIP); G2.dispose(); return IMAGE; }
java
private BufferedImage create_POI_Image(final int WIDTH) { if (WIDTH <= 0) { return null; } final java.awt.image.BufferedImage IMAGE = UTIL.createImage(WIDTH, WIDTH, java.awt.Transparency.TRANSLUCENT); final java.awt.Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); //G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY); //G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE); //G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); //G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY); G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_NORMALIZE); //G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON); final java.awt.geom.Ellipse2D BLIP = new java.awt.geom.Ellipse2D.Double(0, 0, WIDTH, WIDTH); final java.awt.geom.Point2D CENTER = new java.awt.geom.Point2D.Double(BLIP.getCenterX(), BLIP.getCenterY()); final float[] FRACTIONS = { 0.0f, 1.0f }; final Color[] COLORS = { new Color(1.0f, 1.0f, 1.0f, 0.9f), new Color(1.0f, 1.0f, 1.0f, 0.0f) }; final java.awt.RadialGradientPaint GRADIENT = new java.awt.RadialGradientPaint(CENTER, (int) (WIDTH / 2.0), FRACTIONS, COLORS); G2.setPaint(GRADIENT); G2.fill(BLIP); G2.dispose(); return IMAGE; }
[ "private", "BufferedImage", "create_POI_Image", "(", "final", "int", "WIDTH", ")", "{", "if", "(", "WIDTH", "<=", "0", ")", "{", "return", "null", ";", "}", "final", "java", ".", "awt", ".", "image", ".", "BufferedImage", "IMAGE", "=", "UTIL", ".", "createImage", "(", "WIDTH", ",", "WIDTH", ",", "java", ".", "awt", ".", "Transparency", ".", "TRANSLUCENT", ")", ";", "final", "java", ".", "awt", ".", "Graphics2D", "G2", "=", "IMAGE", ".", "createGraphics", "(", ")", ";", "G2", ".", "setRenderingHint", "(", "java", ".", "awt", ".", "RenderingHints", ".", "KEY_ANTIALIASING", ",", "java", ".", "awt", ".", "RenderingHints", ".", "VALUE_ANTIALIAS_ON", ")", ";", "//G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY);", "//G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE);", "//G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);", "//G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);", "G2", ".", "setRenderingHint", "(", "java", ".", "awt", ".", "RenderingHints", ".", "KEY_STROKE_CONTROL", ",", "java", ".", "awt", ".", "RenderingHints", ".", "VALUE_STROKE_NORMALIZE", ")", ";", "//G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);", "final", "java", ".", "awt", ".", "geom", ".", "Ellipse2D", "BLIP", "=", "new", "java", ".", "awt", ".", "geom", ".", "Ellipse2D", ".", "Double", "(", "0", ",", "0", ",", "WIDTH", ",", "WIDTH", ")", ";", "final", "java", ".", "awt", ".", "geom", ".", "Point2D", "CENTER", "=", "new", "java", ".", "awt", ".", "geom", ".", "Point2D", ".", "Double", "(", "BLIP", ".", "getCenterX", "(", ")", ",", "BLIP", ".", "getCenterY", "(", ")", ")", ";", "final", "float", "[", "]", "FRACTIONS", "=", "{", "0.0f", ",", "1.0f", "}", ";", "final", "Color", "[", "]", "COLORS", "=", "{", "new", "Color", "(", "1.0f", ",", "1.0f", ",", "1.0f", ",", "0.9f", ")", ",", "new", "Color", "(", "1.0f", ",", "1.0f", ",", "1.0f", ",", "0.0f", ")", "}", ";", "final", "java", ".", "awt", ".", "RadialGradientPaint", "GRADIENT", "=", "new", "java", ".", "awt", ".", "RadialGradientPaint", "(", "CENTER", ",", "(", "int", ")", "(", "WIDTH", "/", "2.0", ")", ",", "FRACTIONS", ",", "COLORS", ")", ";", "G2", ".", "setPaint", "(", "GRADIENT", ")", ";", "G2", ".", "fill", "(", "BLIP", ")", ";", "G2", ".", "dispose", "(", ")", ";", "return", "IMAGE", ";", "}" ]
Creates the image of the poi @param WIDTH @return buffered image of the poi
[ "Creates", "the", "image", "of", "the", "poi" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Poi.java#L456-L488
3,839
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.setRange
public void setRange(final double RANGE) { this.range = RANGE; checkForBlips(); init(getInnerBounds().width, getInnerBounds().height); repaint(); }
java
public void setRange(final double RANGE) { this.range = RANGE; checkForBlips(); init(getInnerBounds().width, getInnerBounds().height); repaint(); }
[ "public", "void", "setRange", "(", "final", "double", "RANGE", ")", "{", "this", ".", "range", "=", "RANGE", ";", "checkForBlips", "(", ")", ";", "init", "(", "getInnerBounds", "(", ")", ".", "width", ",", "getInnerBounds", "(", ")", ".", "height", ")", ";", "repaint", "(", ")", ";", "}" ]
Sets the range of the radar in meters which means the distance from the center of the radar to it's outer circle @param RANGE
[ "Sets", "the", "range", "of", "the", "radar", "in", "meters", "which", "means", "the", "distance", "from", "the", "center", "of", "the", "radar", "to", "it", "s", "outer", "circle" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L237-L242
3,840
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.setMyLocation
public void setMyLocation(final double LON, final double LAT) { this.MY_LOCATION.setLocation(LON, LAT); checkForBlips(); init(getInnerBounds().width, getInnerBounds().height); repaint(); }
java
public void setMyLocation(final double LON, final double LAT) { this.MY_LOCATION.setLocation(LON, LAT); checkForBlips(); init(getInnerBounds().width, getInnerBounds().height); repaint(); }
[ "public", "void", "setMyLocation", "(", "final", "double", "LON", ",", "final", "double", "LAT", ")", "{", "this", ".", "MY_LOCATION", ".", "setLocation", "(", "LON", ",", "LAT", ")", ";", "checkForBlips", "(", ")", ";", "init", "(", "getInnerBounds", "(", ")", ".", "width", ",", "getInnerBounds", "(", ")", ".", "height", ")", ";", "repaint", "(", ")", ";", "}" ]
Defines the position of the center of the radar by the given coordinates as latitude and longitude @param LON @param LAT
[ "Defines", "the", "position", "of", "the", "center", "of", "the", "radar", "by", "the", "given", "coordinates", "as", "latitude", "and", "longitude" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L273-L278
3,841
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.addPoi
public void addPoi(final Poi BLIP) { if (pois.keySet().contains(BLIP.getName())) { updatePoi(BLIP.getName(), BLIP.getLocation()); } else { pois.put(BLIP.getName(), BLIP); } checkForBlips(); }
java
public void addPoi(final Poi BLIP) { if (pois.keySet().contains(BLIP.getName())) { updatePoi(BLIP.getName(), BLIP.getLocation()); } else { pois.put(BLIP.getName(), BLIP); } checkForBlips(); }
[ "public", "void", "addPoi", "(", "final", "Poi", "BLIP", ")", "{", "if", "(", "pois", ".", "keySet", "(", ")", ".", "contains", "(", "BLIP", ".", "getName", "(", ")", ")", ")", "{", "updatePoi", "(", "BLIP", ".", "getName", "(", ")", ",", "BLIP", ".", "getLocation", "(", ")", ")", ";", "}", "else", "{", "pois", ".", "put", "(", "BLIP", ".", "getName", "(", ")", ",", "BLIP", ")", ";", "}", "checkForBlips", "(", ")", ";", "}" ]
Adds a new point of interest to the list of poi's of the radar Keep in mind that only the poi's are visible as blips that are in the range of the radar. @param BLIP
[ "Adds", "a", "new", "point", "of", "interest", "to", "the", "list", "of", "poi", "s", "of", "the", "radar", "Keep", "in", "mind", "that", "only", "the", "poi", "s", "are", "visible", "as", "blips", "that", "are", "in", "the", "range", "of", "the", "radar", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L286-L293
3,842
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.removePoi
public void removePoi(Poi BLIP) { if (pois.keySet().contains(BLIP.getName())) { pois.remove(BLIP.getName()); checkForBlips(); } }
java
public void removePoi(Poi BLIP) { if (pois.keySet().contains(BLIP.getName())) { pois.remove(BLIP.getName()); checkForBlips(); } }
[ "public", "void", "removePoi", "(", "Poi", "BLIP", ")", "{", "if", "(", "pois", ".", "keySet", "(", ")", ".", "contains", "(", "BLIP", ".", "getName", "(", ")", ")", ")", "{", "pois", ".", "remove", "(", "BLIP", ".", "getName", "(", ")", ")", ";", "checkForBlips", "(", ")", ";", "}", "}" ]
Removes a point of interest from the radar Keep in mind that only the poi's are visible as blips that are in the range of the radar. @param BLIP
[ "Removes", "a", "point", "of", "interest", "from", "the", "radar", "Keep", "in", "mind", "that", "only", "the", "poi", "s", "are", "visible", "as", "blips", "that", "are", "in", "the", "range", "of", "the", "radar", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L316-L321
3,843
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.getPoi
public Poi getPoi(final String NAME) { final Poi POINT_OF_INTEREST; if (pois.keySet().contains(NAME)) { POINT_OF_INTEREST = pois.get(NAME); } else { POINT_OF_INTEREST = null; } return POINT_OF_INTEREST; }
java
public Poi getPoi(final String NAME) { final Poi POINT_OF_INTEREST; if (pois.keySet().contains(NAME)) { POINT_OF_INTEREST = pois.get(NAME); } else { POINT_OF_INTEREST = null; } return POINT_OF_INTEREST; }
[ "public", "Poi", "getPoi", "(", "final", "String", "NAME", ")", "{", "final", "Poi", "POINT_OF_INTEREST", ";", "if", "(", "pois", ".", "keySet", "(", ")", ".", "contains", "(", "NAME", ")", ")", "{", "POINT_OF_INTEREST", "=", "pois", ".", "get", "(", "NAME", ")", ";", "}", "else", "{", "POINT_OF_INTEREST", "=", "null", ";", "}", "return", "POINT_OF_INTEREST", ";", "}" ]
Returns the point of interest given by it's name Keep in mind that only the poi's are visible as blips that are in the range of the radar. @param NAME @return the point of interest given by it's name
[ "Returns", "the", "point", "of", "interest", "given", "by", "it", "s", "name", "Keep", "in", "mind", "that", "only", "the", "poi", "s", "are", "visible", "as", "blips", "that", "are", "in", "the", "range", "of", "the", "radar", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L330-L339
3,844
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.animate
public void animate(final boolean RUN) { if (isEnabled()) { if (RUN) { if (timeline.getState() != Timeline.TimelineState.PLAYING_FORWARD && timeline.getState() != Timeline.TimelineState.SUSPENDED) { timeline = new Timeline(this); timeline.addPropertyToInterpolate("rotationAngle", this.rotationAngle, 2 * Math.PI); timeline.setEase(new org.pushingpixels.trident.ease.Linear()); timeline.setDuration((long) (5000)); timeline.playLoop(Timeline.RepeatBehavior.LOOP); } else if (timeline.getState() == Timeline.TimelineState.SUSPENDED) { timeline.resume(); } } else { timeline.suspend(); } } }
java
public void animate(final boolean RUN) { if (isEnabled()) { if (RUN) { if (timeline.getState() != Timeline.TimelineState.PLAYING_FORWARD && timeline.getState() != Timeline.TimelineState.SUSPENDED) { timeline = new Timeline(this); timeline.addPropertyToInterpolate("rotationAngle", this.rotationAngle, 2 * Math.PI); timeline.setEase(new org.pushingpixels.trident.ease.Linear()); timeline.setDuration((long) (5000)); timeline.playLoop(Timeline.RepeatBehavior.LOOP); } else if (timeline.getState() == Timeline.TimelineState.SUSPENDED) { timeline.resume(); } } else { timeline.suspend(); } } }
[ "public", "void", "animate", "(", "final", "boolean", "RUN", ")", "{", "if", "(", "isEnabled", "(", ")", ")", "{", "if", "(", "RUN", ")", "{", "if", "(", "timeline", ".", "getState", "(", ")", "!=", "Timeline", ".", "TimelineState", ".", "PLAYING_FORWARD", "&&", "timeline", ".", "getState", "(", ")", "!=", "Timeline", ".", "TimelineState", ".", "SUSPENDED", ")", "{", "timeline", "=", "new", "Timeline", "(", "this", ")", ";", "timeline", ".", "addPropertyToInterpolate", "(", "\"rotationAngle\"", ",", "this", ".", "rotationAngle", ",", "2", "*", "Math", ".", "PI", ")", ";", "timeline", ".", "setEase", "(", "new", "org", ".", "pushingpixels", ".", "trident", ".", "ease", ".", "Linear", "(", ")", ")", ";", "timeline", ".", "setDuration", "(", "(", "long", ")", "(", "5000", ")", ")", ";", "timeline", ".", "playLoop", "(", "Timeline", ".", "RepeatBehavior", ".", "LOOP", ")", ";", "}", "else", "if", "(", "timeline", ".", "getState", "(", ")", "==", "Timeline", ".", "TimelineState", ".", "SUSPENDED", ")", "{", "timeline", ".", "resume", "(", ")", ";", "}", "}", "else", "{", "timeline", ".", "suspend", "(", ")", ";", "}", "}", "}" ]
Animates the radar beam of the component. This has no effect on the functionality but is only eye candy. @param RUN enables/disables the animation of the beam
[ "Animates", "the", "radar", "beam", "of", "the", "component", ".", "This", "has", "no", "effect", "on", "the", "functionality", "but", "is", "only", "eye", "candy", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L346-L362
3,845
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Radar.java
Radar.checkForBlips
private void checkForBlips() { blips.clear(); for (Poi poi : pois.values()) { if (poi.distanceTo(MY_LOCATION) < this.range) { if (!blips.keySet().contains(poi.getName())) { blips.put(poi.getName(), poi); } } } }
java
private void checkForBlips() { blips.clear(); for (Poi poi : pois.values()) { if (poi.distanceTo(MY_LOCATION) < this.range) { if (!blips.keySet().contains(poi.getName())) { blips.put(poi.getName(), poi); } } } }
[ "private", "void", "checkForBlips", "(", ")", "{", "blips", ".", "clear", "(", ")", ";", "for", "(", "Poi", "poi", ":", "pois", ".", "values", "(", ")", ")", "{", "if", "(", "poi", ".", "distanceTo", "(", "MY_LOCATION", ")", "<", "this", ".", "range", ")", "{", "if", "(", "!", "blips", ".", "keySet", "(", ")", ".", "contains", "(", "poi", ".", "getName", "(", ")", ")", ")", "{", "blips", ".", "put", "(", "poi", ".", "getName", "(", ")", ",", "poi", ")", ";", "}", "}", "}", "}" ]
Checks for poi's in the range of the radar
[ "Checks", "for", "poi", "s", "in", "the", "range", "of", "the", "radar" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Radar.java#L367-L376
3,846
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Battery.java
Battery.setValue
public void setValue(final int VALUE) { value = VALUE < 0 ? 0 : (VALUE > 100 ? 100 : VALUE); init(getWidth(), getHeight()); repaint(INNER_BOUNDS); }
java
public void setValue(final int VALUE) { value = VALUE < 0 ? 0 : (VALUE > 100 ? 100 : VALUE); init(getWidth(), getHeight()); repaint(INNER_BOUNDS); }
[ "public", "void", "setValue", "(", "final", "int", "VALUE", ")", "{", "value", "=", "VALUE", "<", "0", "?", "0", ":", "(", "VALUE", ">", "100", "?", "100", ":", "VALUE", ")", ";", "init", "(", "getWidth", "(", ")", ",", "getHeight", "(", ")", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Sets the current charge of the battery as integer from 0 - 100 @param VALUE
[ "Sets", "the", "current", "charge", "of", "the", "battery", "as", "integer", "from", "0", "-", "100" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Battery.java#L160-L164
3,847
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Battery.java
Battery.setLightPosition
public void setLightPosition(final Orientation LIGHT_POSITION) { lightPosition = LIGHT_POSITION; init(getWidth(), getHeight()); repaint(INNER_BOUNDS); }
java
public void setLightPosition(final Orientation LIGHT_POSITION) { lightPosition = LIGHT_POSITION; init(getWidth(), getHeight()); repaint(INNER_BOUNDS); }
[ "public", "void", "setLightPosition", "(", "final", "Orientation", "LIGHT_POSITION", ")", "{", "lightPosition", "=", "LIGHT_POSITION", ";", "init", "(", "getWidth", "(", ")", ",", "getHeight", "(", ")", ")", ";", "repaint", "(", "INNER_BOUNDS", ")", ";", "}" ]
Set the position of the light that affects the gradient of the battery frame @param LIGHT_POSITION
[ "Set", "the", "position", "of", "the", "light", "that", "affects", "the", "gradient", "of", "the", "battery", "frame" ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Battery.java#L178-L182
3,848
HanSolo/SteelSeries-Swing
src/main/java/eu/hansolo/steelseries/extras/Battery.java
Battery.calcInnerBounds
private void calcInnerBounds() { final java.awt.Insets INSETS = getInsets(); INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, (getWidth() - INSETS.left - INSETS.right), (getHeight() - INSETS.top - INSETS.bottom)); }
java
private void calcInnerBounds() { final java.awt.Insets INSETS = getInsets(); INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, (getWidth() - INSETS.left - INSETS.right), (getHeight() - INSETS.top - INSETS.bottom)); }
[ "private", "void", "calcInnerBounds", "(", ")", "{", "final", "java", ".", "awt", ".", "Insets", "INSETS", "=", "getInsets", "(", ")", ";", "INNER_BOUNDS", ".", "setBounds", "(", "INSETS", ".", "left", ",", "INSETS", ".", "top", ",", "(", "getWidth", "(", ")", "-", "INSETS", ".", "left", "-", "INSETS", ".", "right", ")", ",", "(", "getHeight", "(", ")", "-", "INSETS", ".", "top", "-", "INSETS", ".", "bottom", ")", ")", ";", "}" ]
Calculates the rectangle that specifies the area that is available for painting the gauge. This means that if the component has insets that are larger than 0, these will be taken into account.
[ "Calculates", "the", "rectangle", "that", "specifies", "the", "area", "that", "is", "available", "for", "painting", "the", "gauge", ".", "This", "means", "that", "if", "the", "component", "has", "insets", "that", "are", "larger", "than", "0", "these", "will", "be", "taken", "into", "account", "." ]
c2f7b45a477757ef21bbb6a1174ddedb2250ae57
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/extras/Battery.java#L373-L376
3,849
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/reader/MongoReader.java
MongoReader.init
public void init(Partition partition) { try { List<ServerAddress> addressList = new ArrayList<>(); for (String s : (List<String>) ((DeepPartition) partition).splitWrapper().getReplicas()) { addressList.add(new ServerAddress(s)); } //Credentials List<MongoCredential> mongoCredentials = new ArrayList<>(); if (mongoDeepJobConfig.getUsername() != null && mongoDeepJobConfig.getPassword() != null) { MongoCredential credential = MongoCredential.createMongoCRCredential(mongoDeepJobConfig.getUsername(), mongoDeepJobConfig.getDatabase(), mongoDeepJobConfig.getPassword().toCharArray()); mongoCredentials.add(credential); } mongoClient = new MongoClient(addressList, mongoCredentials); mongoClient.setReadPreference(ReadPreference.valueOf(mongoDeepJobConfig.getReadPreference())); db = mongoClient.getDB(mongoDeepJobConfig.getDatabase()); collection = db.getCollection(mongoDeepJobConfig.getCollection()); dbCursor = collection.find(generateFilterQuery((MongoPartition) partition), mongoDeepJobConfig.getDBFields()); } catch (UnknownHostException e) { throw new DeepExtractorInitializationException(e); } }
java
public void init(Partition partition) { try { List<ServerAddress> addressList = new ArrayList<>(); for (String s : (List<String>) ((DeepPartition) partition).splitWrapper().getReplicas()) { addressList.add(new ServerAddress(s)); } //Credentials List<MongoCredential> mongoCredentials = new ArrayList<>(); if (mongoDeepJobConfig.getUsername() != null && mongoDeepJobConfig.getPassword() != null) { MongoCredential credential = MongoCredential.createMongoCRCredential(mongoDeepJobConfig.getUsername(), mongoDeepJobConfig.getDatabase(), mongoDeepJobConfig.getPassword().toCharArray()); mongoCredentials.add(credential); } mongoClient = new MongoClient(addressList, mongoCredentials); mongoClient.setReadPreference(ReadPreference.valueOf(mongoDeepJobConfig.getReadPreference())); db = mongoClient.getDB(mongoDeepJobConfig.getDatabase()); collection = db.getCollection(mongoDeepJobConfig.getCollection()); dbCursor = collection.find(generateFilterQuery((MongoPartition) partition), mongoDeepJobConfig.getDBFields()); } catch (UnknownHostException e) { throw new DeepExtractorInitializationException(e); } }
[ "public", "void", "init", "(", "Partition", "partition", ")", "{", "try", "{", "List", "<", "ServerAddress", ">", "addressList", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "s", ":", "(", "List", "<", "String", ">", ")", "(", "(", "DeepPartition", ")", "partition", ")", ".", "splitWrapper", "(", ")", ".", "getReplicas", "(", ")", ")", "{", "addressList", ".", "add", "(", "new", "ServerAddress", "(", "s", ")", ")", ";", "}", "//Credentials", "List", "<", "MongoCredential", ">", "mongoCredentials", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "mongoDeepJobConfig", ".", "getUsername", "(", ")", "!=", "null", "&&", "mongoDeepJobConfig", ".", "getPassword", "(", ")", "!=", "null", ")", "{", "MongoCredential", "credential", "=", "MongoCredential", ".", "createMongoCRCredential", "(", "mongoDeepJobConfig", ".", "getUsername", "(", ")", ",", "mongoDeepJobConfig", ".", "getDatabase", "(", ")", ",", "mongoDeepJobConfig", ".", "getPassword", "(", ")", ".", "toCharArray", "(", ")", ")", ";", "mongoCredentials", ".", "add", "(", "credential", ")", ";", "}", "mongoClient", "=", "new", "MongoClient", "(", "addressList", ",", "mongoCredentials", ")", ";", "mongoClient", ".", "setReadPreference", "(", "ReadPreference", ".", "valueOf", "(", "mongoDeepJobConfig", ".", "getReadPreference", "(", ")", ")", ")", ";", "db", "=", "mongoClient", ".", "getDB", "(", "mongoDeepJobConfig", ".", "getDatabase", "(", ")", ")", ";", "collection", "=", "db", ".", "getCollection", "(", "mongoDeepJobConfig", ".", "getCollection", "(", ")", ")", ";", "dbCursor", "=", "collection", ".", "find", "(", "generateFilterQuery", "(", "(", "MongoPartition", ")", "partition", ")", ",", "mongoDeepJobConfig", ".", "getDBFields", "(", ")", ")", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "throw", "new", "DeepExtractorInitializationException", "(", "e", ")", ";", "}", "}" ]
Init void. @param partition the partition
[ "Init", "void", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/reader/MongoReader.java#L120-L151
3,850
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/reader/MongoReader.java
MongoReader.createQueryPartition
private DBObject createQueryPartition(MongoPartition partition) { QueryBuilder queryBuilderMin = QueryBuilder.start(partition.getKey()); DBObject bsonObjectMin = queryBuilderMin.greaterThanEquals(partition.splitWrapper().getStartToken()).get(); QueryBuilder queryBuilderMax = QueryBuilder.start(partition.getKey()); DBObject bsonObjectMax = queryBuilderMax.lessThan(partition.splitWrapper().getEndToken()).get(); QueryBuilder queryBuilder = QueryBuilder.start(); if (partition.splitWrapper().getStartToken() != null) { queryBuilder.and(bsonObjectMin); } if (partition.splitWrapper().getEndToken() != null) { queryBuilder.and(bsonObjectMax); } LOG.debug("mongodb query "+queryBuilder.get()); return queryBuilder.get(); }
java
private DBObject createQueryPartition(MongoPartition partition) { QueryBuilder queryBuilderMin = QueryBuilder.start(partition.getKey()); DBObject bsonObjectMin = queryBuilderMin.greaterThanEquals(partition.splitWrapper().getStartToken()).get(); QueryBuilder queryBuilderMax = QueryBuilder.start(partition.getKey()); DBObject bsonObjectMax = queryBuilderMax.lessThan(partition.splitWrapper().getEndToken()).get(); QueryBuilder queryBuilder = QueryBuilder.start(); if (partition.splitWrapper().getStartToken() != null) { queryBuilder.and(bsonObjectMin); } if (partition.splitWrapper().getEndToken() != null) { queryBuilder.and(bsonObjectMax); } LOG.debug("mongodb query "+queryBuilder.get()); return queryBuilder.get(); }
[ "private", "DBObject", "createQueryPartition", "(", "MongoPartition", "partition", ")", "{", "QueryBuilder", "queryBuilderMin", "=", "QueryBuilder", ".", "start", "(", "partition", ".", "getKey", "(", ")", ")", ";", "DBObject", "bsonObjectMin", "=", "queryBuilderMin", ".", "greaterThanEquals", "(", "partition", ".", "splitWrapper", "(", ")", ".", "getStartToken", "(", ")", ")", ".", "get", "(", ")", ";", "QueryBuilder", "queryBuilderMax", "=", "QueryBuilder", ".", "start", "(", "partition", ".", "getKey", "(", ")", ")", ";", "DBObject", "bsonObjectMax", "=", "queryBuilderMax", ".", "lessThan", "(", "partition", ".", "splitWrapper", "(", ")", ".", "getEndToken", "(", ")", ")", ".", "get", "(", ")", ";", "QueryBuilder", "queryBuilder", "=", "QueryBuilder", ".", "start", "(", ")", ";", "if", "(", "partition", ".", "splitWrapper", "(", ")", ".", "getStartToken", "(", ")", "!=", "null", ")", "{", "queryBuilder", ".", "and", "(", "bsonObjectMin", ")", ";", "}", "if", "(", "partition", ".", "splitWrapper", "(", ")", ".", "getEndToken", "(", ")", "!=", "null", ")", "{", "queryBuilder", ".", "and", "(", "bsonObjectMax", ")", ";", "}", "LOG", ".", "debug", "(", "\"mongodb query \"", "+", "queryBuilder", ".", "get", "(", ")", ")", ";", "return", "queryBuilder", ".", "get", "(", ")", ";", "}" ]
Create query partition. @param partition the partition @return the dB object
[ "Create", "query", "partition", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/reader/MongoReader.java#L159-L179
3,851
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/reader/MongoReader.java
MongoReader.generateFilterQuery
private DBObject generateFilterQuery(MongoPartition partition) { if (mongoDeepJobConfig.getQuery() != null) { QueryBuilder queryBuilder = QueryBuilder.start(); queryBuilder.and(createQueryPartition(partition), mongoDeepJobConfig.getQuery()); LOG.debug("mongodb query "+queryBuilder.get()); return queryBuilder.get(); } return createQueryPartition(partition); }
java
private DBObject generateFilterQuery(MongoPartition partition) { if (mongoDeepJobConfig.getQuery() != null) { QueryBuilder queryBuilder = QueryBuilder.start(); queryBuilder.and(createQueryPartition(partition), mongoDeepJobConfig.getQuery()); LOG.debug("mongodb query "+queryBuilder.get()); return queryBuilder.get(); } return createQueryPartition(partition); }
[ "private", "DBObject", "generateFilterQuery", "(", "MongoPartition", "partition", ")", "{", "if", "(", "mongoDeepJobConfig", ".", "getQuery", "(", ")", "!=", "null", ")", "{", "QueryBuilder", "queryBuilder", "=", "QueryBuilder", ".", "start", "(", ")", ";", "queryBuilder", ".", "and", "(", "createQueryPartition", "(", "partition", ")", ",", "mongoDeepJobConfig", ".", "getQuery", "(", ")", ")", ";", "LOG", ".", "debug", "(", "\"mongodb query \"", "+", "queryBuilder", ".", "get", "(", ")", ")", ";", "return", "queryBuilder", ".", "get", "(", ")", ";", "}", "return", "createQueryPartition", "(", "partition", ")", ";", "}" ]
Generate filter query. @param partition the partition @return the dB object
[ "Generate", "filter", "query", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/reader/MongoReader.java#L187-L201
3,852
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/config/MongoDeepJobConfig.java
MongoDeepJobConfig.validate
private void validate() { if (host.isEmpty()) { throw new IllegalArgumentException("host cannot be null"); } if (catalog == null) { throw new IllegalArgumentException("database cannot be null"); } if (table == null) { throw new IllegalArgumentException("collection cannot be null"); } concantHostPort(); }
java
private void validate() { if (host.isEmpty()) { throw new IllegalArgumentException("host cannot be null"); } if (catalog == null) { throw new IllegalArgumentException("database cannot be null"); } if (table == null) { throw new IllegalArgumentException("collection cannot be null"); } concantHostPort(); }
[ "private", "void", "validate", "(", ")", "{", "if", "(", "host", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"host cannot be null\"", ")", ";", "}", "if", "(", "catalog", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"database cannot be null\"", ")", ";", "}", "if", "(", "table", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"collection cannot be null\"", ")", ";", "}", "concantHostPort", "(", ")", ";", "}" ]
validates connection parameters
[ "validates", "connection", "parameters" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/config/MongoDeepJobConfig.java#L428-L441
3,853
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/config/MongoDeepJobConfig.java
MongoDeepJobConfig.filterQuery
public MongoDeepJobConfig<T> filterQuery(Filter[] filters) { if (filters.length > 0) { List<BasicDBObject> list = new ArrayList<>(); QueryBuilder queryBuilder = QueryBuilder.start(); for (int i = 0; i < filters.length; i++) { BasicDBObject bsonObject = new BasicDBObject(); Filter filter = filters[i]; if (filter.getFilterType().equals(FilterType.EQ)) { bsonObject.put(filter.getField(), filter.getValue()); } else { bsonObject.put(filter.getField(), new BasicDBObject("$".concat(filter.getFilterType().getFilterTypeId().toLowerCase()), filter.getValue())); } list.add(bsonObject); } queryBuilder.and(list.toArray(new BasicDBObject[list.size()])); filterQuery(queryBuilder); } return this; }
java
public MongoDeepJobConfig<T> filterQuery(Filter[] filters) { if (filters.length > 0) { List<BasicDBObject> list = new ArrayList<>(); QueryBuilder queryBuilder = QueryBuilder.start(); for (int i = 0; i < filters.length; i++) { BasicDBObject bsonObject = new BasicDBObject(); Filter filter = filters[i]; if (filter.getFilterType().equals(FilterType.EQ)) { bsonObject.put(filter.getField(), filter.getValue()); } else { bsonObject.put(filter.getField(), new BasicDBObject("$".concat(filter.getFilterType().getFilterTypeId().toLowerCase()), filter.getValue())); } list.add(bsonObject); } queryBuilder.and(list.toArray(new BasicDBObject[list.size()])); filterQuery(queryBuilder); } return this; }
[ "public", "MongoDeepJobConfig", "<", "T", ">", "filterQuery", "(", "Filter", "[", "]", "filters", ")", "{", "if", "(", "filters", ".", "length", ">", "0", ")", "{", "List", "<", "BasicDBObject", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "QueryBuilder", "queryBuilder", "=", "QueryBuilder", ".", "start", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "filters", ".", "length", ";", "i", "++", ")", "{", "BasicDBObject", "bsonObject", "=", "new", "BasicDBObject", "(", ")", ";", "Filter", "filter", "=", "filters", "[", "i", "]", ";", "if", "(", "filter", ".", "getFilterType", "(", ")", ".", "equals", "(", "FilterType", ".", "EQ", ")", ")", "{", "bsonObject", ".", "put", "(", "filter", ".", "getField", "(", ")", ",", "filter", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "bsonObject", ".", "put", "(", "filter", ".", "getField", "(", ")", ",", "new", "BasicDBObject", "(", "\"$\"", ".", "concat", "(", "filter", ".", "getFilterType", "(", ")", ".", "getFilterTypeId", "(", ")", ".", "toLowerCase", "(", ")", ")", ",", "filter", ".", "getValue", "(", ")", ")", ")", ";", "}", "list", ".", "add", "(", "bsonObject", ")", ";", "}", "queryBuilder", ".", "and", "(", "list", ".", "toArray", "(", "new", "BasicDBObject", "[", "list", ".", "size", "(", ")", "]", ")", ")", ";", "filterQuery", "(", "queryBuilder", ")", ";", "}", "return", "this", ";", "}" ]
Filter query. @param filters the filters @return the mongo deep job config
[ "Filter", "query", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/config/MongoDeepJobConfig.java#L540-L566
3,854
Stratio/deep-spark
deep-elasticsearch/src/main/java/com/stratio/deep/es/config/ESConfigFactory.java
ESConfigFactory.createES
public static <T extends IDeepType> ESDeepJobConfig<T> createES(Class<T> entityClass) { return new ESDeepJobConfig<>(entityClass); }
java
public static <T extends IDeepType> ESDeepJobConfig<T> createES(Class<T> entityClass) { return new ESDeepJobConfig<>(entityClass); }
[ "public", "static", "<", "T", "extends", "IDeepType", ">", "ESDeepJobConfig", "<", "T", ">", "createES", "(", "Class", "<", "T", ">", "entityClass", ")", "{", "return", "new", "ESDeepJobConfig", "<>", "(", "entityClass", ")", ";", "}" ]
Creates a new entity-based ElasticSearch job configuration object. @param entityClass the class instance of the entity class that will be used to map db objects to Java objects. @param <T> the generic type of the entity object implementing IDeepType. @return a new entity-based ElasticSearch job configuration object.
[ "Creates", "a", "new", "entity", "-", "based", "ElasticSearch", "job", "configuration", "object", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-elasticsearch/src/main/java/com/stratio/deep/es/config/ESConfigFactory.java#L50-L52
3,855
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraDeepJobConfig.java
CassandraDeepJobConfig.fetchTableMetadata
public TableMetadata fetchTableMetadata() { Metadata metadata = getSession().getCluster().getMetadata(); KeyspaceMetadata ksMetadata = metadata.getKeyspace(quote(this.catalog)); if (ksMetadata != null) { return ksMetadata.getTable(quote(this.table)); } else { return null; } }
java
public TableMetadata fetchTableMetadata() { Metadata metadata = getSession().getCluster().getMetadata(); KeyspaceMetadata ksMetadata = metadata.getKeyspace(quote(this.catalog)); if (ksMetadata != null) { return ksMetadata.getTable(quote(this.table)); } else { return null; } }
[ "public", "TableMetadata", "fetchTableMetadata", "(", ")", "{", "Metadata", "metadata", "=", "getSession", "(", ")", ".", "getCluster", "(", ")", ".", "getMetadata", "(", ")", ";", "KeyspaceMetadata", "ksMetadata", "=", "metadata", ".", "getKeyspace", "(", "quote", "(", "this", ".", "catalog", ")", ")", ";", "if", "(", "ksMetadata", "!=", "null", ")", "{", "return", "ksMetadata", ".", "getTable", "(", "quote", "(", "this", ".", "table", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Fetches table metadata from the underlying datastore, using DataStax java driver. @return the table metadata as returned by the driver.
[ "Fetches", "table", "metadata", "from", "the", "underlying", "datastore", "using", "DataStax", "java", "driver", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraDeepJobConfig.java#L210-L220
3,856
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraDeepJobConfig.java
CassandraDeepJobConfig.waitForNewTableMetadata
private void waitForNewTableMetadata() { TableMetadata metadata; int retries = 0; final int waitTime = 100; do { metadata = getSession() .getCluster() .getMetadata() .getKeyspace(this.catalog) .getTable(quote(this.table)); if (metadata != null) { continue; } LOG.warn(String.format("Metadata for new table %s.%s NOT FOUND, waiting %d millis", this.catalog, this.table, waitTime)); try { Thread.sleep(waitTime); } catch (InterruptedException e) { LOG.error("Sleep interrupted", e); } retries++; if (retries >= 10) { throw new DeepIOException("Cannot retrieve metadata for the newly created CF "); } } while (metadata == null); }
java
private void waitForNewTableMetadata() { TableMetadata metadata; int retries = 0; final int waitTime = 100; do { metadata = getSession() .getCluster() .getMetadata() .getKeyspace(this.catalog) .getTable(quote(this.table)); if (metadata != null) { continue; } LOG.warn(String.format("Metadata for new table %s.%s NOT FOUND, waiting %d millis", this.catalog, this.table, waitTime)); try { Thread.sleep(waitTime); } catch (InterruptedException e) { LOG.error("Sleep interrupted", e); } retries++; if (retries >= 10) { throw new DeepIOException("Cannot retrieve metadata for the newly created CF "); } } while (metadata == null); }
[ "private", "void", "waitForNewTableMetadata", "(", ")", "{", "TableMetadata", "metadata", ";", "int", "retries", "=", "0", ";", "final", "int", "waitTime", "=", "100", ";", "do", "{", "metadata", "=", "getSession", "(", ")", ".", "getCluster", "(", ")", ".", "getMetadata", "(", ")", ".", "getKeyspace", "(", "this", ".", "catalog", ")", ".", "getTable", "(", "quote", "(", "this", ".", "table", ")", ")", ";", "if", "(", "metadata", "!=", "null", ")", "{", "continue", ";", "}", "LOG", ".", "warn", "(", "String", ".", "format", "(", "\"Metadata for new table %s.%s NOT FOUND, waiting %d millis\"", ",", "this", ".", "catalog", ",", "this", ".", "table", ",", "waitTime", ")", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "waitTime", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "LOG", ".", "error", "(", "\"Sleep interrupted\"", ",", "e", ")", ";", "}", "retries", "++", ";", "if", "(", "retries", ">=", "10", ")", "{", "throw", "new", "DeepIOException", "(", "\"Cannot retrieve metadata for the newly created CF \"", ")", ";", "}", "}", "while", "(", "metadata", "==", "null", ")", ";", "}" ]
waits until table metadata is not null
[ "waits", "until", "table", "metadata", "is", "not", "null" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/config/CassandraDeepJobConfig.java#L261-L290
3,857
Stratio/deep-spark
deep-jdbc/src/main/java/com/stratio/deep/jdbc/writer/JdbcWriter.java
JdbcWriter.save
public void save(Map<String, Object> row) throws Exception { Tuple2<List<String>, String> data = sqlFromRow(row); PreparedStatement statement = conn.prepareStatement(data._2()); int i = 1; for(String columnName:data._1()) { statement.setObject(i, row.get(columnName)); i++; } statement.executeUpdate(); }
java
public void save(Map<String, Object> row) throws Exception { Tuple2<List<String>, String> data = sqlFromRow(row); PreparedStatement statement = conn.prepareStatement(data._2()); int i = 1; for(String columnName:data._1()) { statement.setObject(i, row.get(columnName)); i++; } statement.executeUpdate(); }
[ "public", "void", "save", "(", "Map", "<", "String", ",", "Object", ">", "row", ")", "throws", "Exception", "{", "Tuple2", "<", "List", "<", "String", ">", ",", "String", ">", "data", "=", "sqlFromRow", "(", "row", ")", ";", "PreparedStatement", "statement", "=", "conn", ".", "prepareStatement", "(", "data", ".", "_2", "(", ")", ")", ";", "int", "i", "=", "1", ";", "for", "(", "String", "columnName", ":", "data", ".", "_1", "(", ")", ")", "{", "statement", ".", "setObject", "(", "i", ",", "row", ".", "get", "(", "columnName", ")", ")", ";", "i", "++", ";", "}", "statement", ".", "executeUpdate", "(", ")", ";", "}" ]
Saves data. @param row Data structure representing a row as a Map of column_name:column_value @throws SQLException
[ "Saves", "data", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/writer/JdbcWriter.java#L66-L75
3,858
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.newTypeInstance
@SuppressWarnings("unchecked") public static <T> T newTypeInstance(String className, Class<T> returnClass) { try { Class<T> clazz = (Class<T>) Class.forName(className); return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new DeepGenericException(e); } }
java
@SuppressWarnings("unchecked") public static <T> T newTypeInstance(String className, Class<T> returnClass) { try { Class<T> clazz = (Class<T>) Class.forName(className); return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new DeepGenericException(e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "newTypeInstance", "(", "String", "className", ",", "Class", "<", "T", ">", "returnClass", ")", "{", "try", "{", "Class", "<", "T", ">", "clazz", "=", "(", "Class", "<", "T", ">", ")", "Class", ".", "forName", "(", "className", ")", ";", "return", "clazz", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "|", "ClassNotFoundException", "e", ")", "{", "throw", "new", "DeepGenericException", "(", "e", ")", ";", "}", "}" ]
Creates a new instance of the given class name. @param <T> the type parameter @param className the class object for which a new instance should be created. @param returnClass the return class @return the new instance of class clazz.
[ "Creates", "a", "new", "instance", "of", "the", "given", "class", "name", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L96-L104
3,859
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.quote
public static String quote(String identifier) { if (StringUtils.isEmpty(identifier)) { return identifier; } String res = identifier.trim(); if (!res.startsWith("\"")) { res = "\"" + res; } if (!res.endsWith("\"")) { res = res + "\""; } return res; }
java
public static String quote(String identifier) { if (StringUtils.isEmpty(identifier)) { return identifier; } String res = identifier.trim(); if (!res.startsWith("\"")) { res = "\"" + res; } if (!res.endsWith("\"")) { res = res + "\""; } return res; }
[ "public", "static", "String", "quote", "(", "String", "identifier", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "identifier", ")", ")", "{", "return", "identifier", ";", "}", "String", "res", "=", "identifier", ".", "trim", "(", ")", ";", "if", "(", "!", "res", ".", "startsWith", "(", "\"\\\"\"", ")", ")", "{", "res", "=", "\"\\\"\"", "+", "res", ";", "}", "if", "(", "!", "res", ".", "endsWith", "(", "\"\\\"\"", ")", ")", "{", "res", "=", "res", "+", "\"\\\"\"", ";", "}", "return", "res", ";", "}" ]
Quoting for working with uppercase @param identifier the identifier @return the string
[ "Quoting", "for", "working", "with", "uppercase" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L112-L129
3,860
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.batchQueryGenerator
public static String batchQueryGenerator(List<String> statements) { StringBuilder sb = new StringBuilder("BEGIN BATCH \n"); for (String statement : statements) { sb.append(statement).append("\n"); } sb.append(" APPLY BATCH;"); return sb.toString(); }
java
public static String batchQueryGenerator(List<String> statements) { StringBuilder sb = new StringBuilder("BEGIN BATCH \n"); for (String statement : statements) { sb.append(statement).append("\n"); } sb.append(" APPLY BATCH;"); return sb.toString(); }
[ "public", "static", "String", "batchQueryGenerator", "(", "List", "<", "String", ">", "statements", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"BEGIN BATCH \\n\"", ")", ";", "for", "(", "String", "statement", ":", "statements", ")", "{", "sb", ".", "append", "(", "statement", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "sb", ".", "append", "(", "\" APPLY BATCH;\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns a CQL batch query wrapping the given statements. @param statements the list of statements to use to generate the batch statement. @return the batch statement.
[ "Returns", "a", "CQL", "batch", "query", "wrapping", "the", "given", "statements", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L161-L171
3,861
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.prepareTuple4CqlDriver
public static Tuple2<String[], Object[]> prepareTuple4CqlDriver(Tuple2<Cells, Cells> tuple) { Cells keys = tuple._1(); Cells columns = tuple._2(); String[] names = new String[keys.size() + columns.size()]; Object[] values = new Object[keys.size() + columns.size()]; for (int k = 0; k < keys.size(); k++) { Cell cell = keys.getCellByIdx(k); names[k] = quote(cell.getCellName()); values[k] = cell.getCellValue(); } for (int v = keys.size(); v < (keys.size() + columns.size()); v++) { Cell cell = columns.getCellByIdx(v - keys.size()); names[v] = quote(cell.getCellName()); values[v] = cell.getCellValue(); } return new Tuple2<>(names, values); }
java
public static Tuple2<String[], Object[]> prepareTuple4CqlDriver(Tuple2<Cells, Cells> tuple) { Cells keys = tuple._1(); Cells columns = tuple._2(); String[] names = new String[keys.size() + columns.size()]; Object[] values = new Object[keys.size() + columns.size()]; for (int k = 0; k < keys.size(); k++) { Cell cell = keys.getCellByIdx(k); names[k] = quote(cell.getCellName()); values[k] = cell.getCellValue(); } for (int v = keys.size(); v < (keys.size() + columns.size()); v++) { Cell cell = columns.getCellByIdx(v - keys.size()); names[v] = quote(cell.getCellName()); values[v] = cell.getCellValue(); } return new Tuple2<>(names, values); }
[ "public", "static", "Tuple2", "<", "String", "[", "]", ",", "Object", "[", "]", ">", "prepareTuple4CqlDriver", "(", "Tuple2", "<", "Cells", ",", "Cells", ">", "tuple", ")", "{", "Cells", "keys", "=", "tuple", ".", "_1", "(", ")", ";", "Cells", "columns", "=", "tuple", ".", "_2", "(", ")", ";", "String", "[", "]", "names", "=", "new", "String", "[", "keys", ".", "size", "(", ")", "+", "columns", ".", "size", "(", ")", "]", ";", "Object", "[", "]", "values", "=", "new", "Object", "[", "keys", ".", "size", "(", ")", "+", "columns", ".", "size", "(", ")", "]", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "keys", ".", "size", "(", ")", ";", "k", "++", ")", "{", "Cell", "cell", "=", "keys", ".", "getCellByIdx", "(", "k", ")", ";", "names", "[", "k", "]", "=", "quote", "(", "cell", ".", "getCellName", "(", ")", ")", ";", "values", "[", "k", "]", "=", "cell", ".", "getCellValue", "(", ")", ";", "}", "for", "(", "int", "v", "=", "keys", ".", "size", "(", ")", ";", "v", "<", "(", "keys", ".", "size", "(", ")", "+", "columns", ".", "size", "(", ")", ")", ";", "v", "++", ")", "{", "Cell", "cell", "=", "columns", ".", "getCellByIdx", "(", "v", "-", "keys", ".", "size", "(", ")", ")", ";", "names", "[", "v", "]", "=", "quote", "(", "cell", ".", "getCellName", "(", ")", ")", ";", "values", "[", "v", "]", "=", "cell", ".", "getCellValue", "(", ")", ";", "}", "return", "new", "Tuple2", "<>", "(", "names", ",", "values", ")", ";", "}" ]
Splits columns names and values as required by Datastax java driver to generate an Insert query. @param tuple an object containing the key Cell(s) as the first element and all the other columns as the second element. @return an object containing an array of column names as the first element and an array of column values as the second element.
[ "Splits", "columns", "names", "and", "values", "as", "required", "by", "Datastax", "java", "driver", "to", "generate", "an", "Insert", "query", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L179-L201
3,862
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.findSetter
@SuppressWarnings("unchecked") public static Method findSetter(String propertyName, Class entityClass, Class valueType) { Method setter; String setterName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); try { setter = entityClass.getMethod(setterName, valueType); } catch (NoSuchMethodException e) { // let's try with scala setter name try { setter = entityClass.getMethod(propertyName + "_$eq", valueType); } catch (NoSuchMethodException e1) { throw new DeepIOException(e1); } } return setter; }
java
@SuppressWarnings("unchecked") public static Method findSetter(String propertyName, Class entityClass, Class valueType) { Method setter; String setterName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); try { setter = entityClass.getMethod(setterName, valueType); } catch (NoSuchMethodException e) { // let's try with scala setter name try { setter = entityClass.getMethod(propertyName + "_$eq", valueType); } catch (NoSuchMethodException e1) { throw new DeepIOException(e1); } } return setter; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Method", "findSetter", "(", "String", "propertyName", ",", "Class", "entityClass", ",", "Class", "valueType", ")", "{", "Method", "setter", ";", "String", "setterName", "=", "\"set\"", "+", "propertyName", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "propertyName", ".", "substring", "(", "1", ")", ";", "try", "{", "setter", "=", "entityClass", ".", "getMethod", "(", "setterName", ",", "valueType", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "// let's try with scala setter name", "try", "{", "setter", "=", "entityClass", ".", "getMethod", "(", "propertyName", "+", "\"_$eq\"", ",", "valueType", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e1", ")", "{", "throw", "new", "DeepIOException", "(", "e1", ")", ";", "}", "}", "return", "setter", ";", "}" ]
Resolves the setter name for the property whose name is 'propertyName' whose type is 'valueType' in the entity bean whose class is 'entityClass'. If we don't find a setter following Java's naming conventions, before throwing an exception we try to resolve the setter following Scala's naming conventions. @param propertyName the field name of the property whose setter we want to resolve. @param entityClass the bean class object in which we want to search for the setter. @param valueType the class type of the object that we want to pass to the setter. @return the resolved setter.
[ "Resolves", "the", "setter", "name", "for", "the", "property", "whose", "name", "is", "propertyName", "whose", "type", "is", "valueType", "in", "the", "entity", "bean", "whose", "class", "is", "entityClass", ".", "If", "we", "don", "t", "find", "a", "setter", "following", "Java", "s", "naming", "conventions", "before", "throwing", "an", "exception", "we", "try", "to", "resolve", "the", "setter", "following", "Scala", "s", "naming", "conventions", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L214-L232
3,863
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.findGetter
@SuppressWarnings("unchecked") public static Method findGetter(String propertyName, Class entityClass) { Method getter; String getterName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); try { getter = entityClass.getMethod(getterName); } catch (NoSuchMethodException e) { // let's try with scala setter name try { getter = entityClass.getMethod(propertyName + "_$eq"); } catch (NoSuchMethodException e1) { throw new DeepIOException(e1); } } return getter; }
java
@SuppressWarnings("unchecked") public static Method findGetter(String propertyName, Class entityClass) { Method getter; String getterName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); try { getter = entityClass.getMethod(getterName); } catch (NoSuchMethodException e) { // let's try with scala setter name try { getter = entityClass.getMethod(propertyName + "_$eq"); } catch (NoSuchMethodException e1) { throw new DeepIOException(e1); } } return getter; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Method", "findGetter", "(", "String", "propertyName", ",", "Class", "entityClass", ")", "{", "Method", "getter", ";", "String", "getterName", "=", "\"get\"", "+", "propertyName", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "propertyName", ".", "substring", "(", "1", ")", ";", "try", "{", "getter", "=", "entityClass", ".", "getMethod", "(", "getterName", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "// let's try with scala setter name", "try", "{", "getter", "=", "entityClass", ".", "getMethod", "(", "propertyName", "+", "\"_$eq\"", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e1", ")", "{", "throw", "new", "DeepIOException", "(", "e1", ")", ";", "}", "}", "return", "getter", ";", "}" ]
Resolves the getter name for the property whose name is 'propertyName' whose type is 'valueType' in the entity bean whose class is 'entityClass'. If we don't find a setter following Java's naming conventions, before throwing an exception we try to resolve the setter following Scala's naming conventions. @param propertyName the field name of the property whose getter we want to resolve. @param entityClass the bean class object in which we want to search for the getter. @return the resolved getter.
[ "Resolves", "the", "getter", "name", "for", "the", "property", "whose", "name", "is", "propertyName", "whose", "type", "is", "valueType", "in", "the", "entity", "bean", "whose", "class", "is", "entityClass", ".", "If", "we", "don", "t", "find", "a", "setter", "following", "Java", "s", "naming", "conventions", "before", "throwing", "an", "exception", "we", "try", "to", "resolve", "the", "setter", "following", "Scala", "s", "naming", "conventions", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L267-L285
3,864
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.inetAddressFromLocation
public static InetAddress inetAddressFromLocation(String location) { try { return InetAddress.getByName(location); } catch (UnknownHostException e) { throw new DeepIOException(e); } }
java
public static InetAddress inetAddressFromLocation(String location) { try { return InetAddress.getByName(location); } catch (UnknownHostException e) { throw new DeepIOException(e); } }
[ "public", "static", "InetAddress", "inetAddressFromLocation", "(", "String", "location", ")", "{", "try", "{", "return", "InetAddress", ".", "getByName", "(", "location", ")", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "throw", "new", "DeepIOException", "(", "e", ")", ";", "}", "}" ]
Returns the inet address for the specified location. @param location the address as String @return the InetAddress object associated to the provided address.
[ "Returns", "the", "inet", "address", "for", "the", "specified", "location", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L293-L299
3,865
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.getAllFieldsRec
private static Field[] getAllFieldsRec(Class clazz, List<Field> fields) { Class superClazz = clazz.getSuperclass(); if (superClazz != null) { getAllFieldsRec(superClazz, fields); } fields.addAll(Arrays.asList(clazz.getDeclaredFields())); return fields.toArray(new Field[fields.size()]); }
java
private static Field[] getAllFieldsRec(Class clazz, List<Field> fields) { Class superClazz = clazz.getSuperclass(); if (superClazz != null) { getAllFieldsRec(superClazz, fields); } fields.addAll(Arrays.asList(clazz.getDeclaredFields())); return fields.toArray(new Field[fields.size()]); }
[ "private", "static", "Field", "[", "]", "getAllFieldsRec", "(", "Class", "clazz", ",", "List", "<", "Field", ">", "fields", ")", "{", "Class", "superClazz", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "if", "(", "superClazz", "!=", "null", ")", "{", "getAllFieldsRec", "(", "superClazz", ",", "fields", ")", ";", "}", "fields", ".", "addAll", "(", "Arrays", ".", "asList", "(", "clazz", ".", "getDeclaredFields", "(", ")", ")", ")", ";", "return", "fields", ".", "toArray", "(", "new", "Field", "[", "fields", ".", "size", "(", ")", "]", ")", ";", "}" ]
Get all fields rec. @param clazz the clazz @param fields the fields @return the field [ ]
[ "Get", "all", "fields", "rec", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L318-L326
3,866
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.removeAddressPort
public static List<String> removeAddressPort(List<String> stringList) { List<String> adresNoPort = new ArrayList<>(); for (String s : stringList) { int index = s.indexOf(":"); if (index > -1) { adresNoPort.add(s.substring(0, index)); continue; } adresNoPort.add(s); } return adresNoPort; }
java
public static List<String> removeAddressPort(List<String> stringList) { List<String> adresNoPort = new ArrayList<>(); for (String s : stringList) { int index = s.indexOf(":"); if (index > -1) { adresNoPort.add(s.substring(0, index)); continue; } adresNoPort.add(s); } return adresNoPort; }
[ "public", "static", "List", "<", "String", ">", "removeAddressPort", "(", "List", "<", "String", ">", "stringList", ")", "{", "List", "<", "String", ">", "adresNoPort", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "s", ":", "stringList", ")", "{", "int", "index", "=", "s", ".", "indexOf", "(", "\":\"", ")", ";", "if", "(", "index", ">", "-", "1", ")", "{", "adresNoPort", ".", "add", "(", "s", ".", "substring", "(", "0", ",", "index", ")", ")", ";", "continue", ";", "}", "adresNoPort", ".", "add", "(", "s", ")", ";", "}", "return", "adresNoPort", ";", "}" ]
Remove address port. @param stringList the string list @return the list
[ "Remove", "address", "port", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L341-L354
3,867
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.splitListByComma
public static String splitListByComma(List<String> hosts) { boolean firstHost = true; StringBuilder hostConnection = new StringBuilder(); for (String host : hosts) { if (!firstHost) { hostConnection.append(","); } hostConnection.append(host.trim()); firstHost = false; } return hostConnection.toString(); }
java
public static String splitListByComma(List<String> hosts) { boolean firstHost = true; StringBuilder hostConnection = new StringBuilder(); for (String host : hosts) { if (!firstHost) { hostConnection.append(","); } hostConnection.append(host.trim()); firstHost = false; } return hostConnection.toString(); }
[ "public", "static", "String", "splitListByComma", "(", "List", "<", "String", ">", "hosts", ")", "{", "boolean", "firstHost", "=", "true", ";", "StringBuilder", "hostConnection", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "host", ":", "hosts", ")", "{", "if", "(", "!", "firstHost", ")", "{", "hostConnection", ".", "append", "(", "\",\"", ")", ";", "}", "hostConnection", ".", "append", "(", "host", ".", "trim", "(", ")", ")", ";", "firstHost", "=", "false", ";", "}", "return", "hostConnection", ".", "toString", "(", ")", ";", "}" ]
Split list by comma. @param hosts the hosts @return string
[ "Split", "list", "by", "comma", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L362-L373
3,868
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.getExtractorInstance
public static <T, S extends BaseConfig> IExtractor<T, S> getExtractorInstance(S config) { try { Class<T> rdd = (Class<T>) config.getExtractorImplClass(); if (rdd == null) { rdd = (Class<T>) Class.forName(config.getExtractorImplClassName()); } Constructor<T> c; if (config.getEntityClass().isAssignableFrom(Cells.class)) { c = rdd.getConstructor(); return (IExtractor<T, S>) c.newInstance(); } else { c = rdd.getConstructor(Class.class); return (IExtractor<T, S>) c.newInstance(config.getEntityClass()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { String message = "A exception happens and we wrap with DeepExtractorInitializationException" + e.getMessage(); LOG.error(message); throw new DeepExtractorInitializationException(message,e); } }
java
public static <T, S extends BaseConfig> IExtractor<T, S> getExtractorInstance(S config) { try { Class<T> rdd = (Class<T>) config.getExtractorImplClass(); if (rdd == null) { rdd = (Class<T>) Class.forName(config.getExtractorImplClassName()); } Constructor<T> c; if (config.getEntityClass().isAssignableFrom(Cells.class)) { c = rdd.getConstructor(); return (IExtractor<T, S>) c.newInstance(); } else { c = rdd.getConstructor(Class.class); return (IExtractor<T, S>) c.newInstance(config.getEntityClass()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { String message = "A exception happens and we wrap with DeepExtractorInitializationException" + e.getMessage(); LOG.error(message); throw new DeepExtractorInitializationException(message,e); } }
[ "public", "static", "<", "T", ",", "S", "extends", "BaseConfig", ">", "IExtractor", "<", "T", ",", "S", ">", "getExtractorInstance", "(", "S", "config", ")", "{", "try", "{", "Class", "<", "T", ">", "rdd", "=", "(", "Class", "<", "T", ">", ")", "config", ".", "getExtractorImplClass", "(", ")", ";", "if", "(", "rdd", "==", "null", ")", "{", "rdd", "=", "(", "Class", "<", "T", ">", ")", "Class", ".", "forName", "(", "config", ".", "getExtractorImplClassName", "(", ")", ")", ";", "}", "Constructor", "<", "T", ">", "c", ";", "if", "(", "config", ".", "getEntityClass", "(", ")", ".", "isAssignableFrom", "(", "Cells", ".", "class", ")", ")", "{", "c", "=", "rdd", ".", "getConstructor", "(", ")", ";", "return", "(", "IExtractor", "<", "T", ",", "S", ">", ")", "c", ".", "newInstance", "(", ")", ";", "}", "else", "{", "c", "=", "rdd", ".", "getConstructor", "(", "Class", ".", "class", ")", ";", "return", "(", "IExtractor", "<", "T", ",", "S", ">", ")", "c", ".", "newInstance", "(", "config", ".", "getEntityClass", "(", ")", ")", ";", "}", "}", "catch", "(", "ClassNotFoundException", "|", "InstantiationException", "|", "IllegalAccessException", "|", "IllegalArgumentException", "|", "InvocationTargetException", "|", "NoSuchMethodException", "|", "SecurityException", "e", ")", "{", "String", "message", "=", "\"A exception happens and we wrap with DeepExtractorInitializationException\"", "+", "e", ".", "getMessage", "(", ")", ";", "LOG", ".", "error", "(", "message", ")", ";", "throw", "new", "DeepExtractorInitializationException", "(", "message", ",", "e", ")", ";", "}", "}" ]
Gets extractor instance. @param config the config @return the extractor instance
[ "Gets", "extractor", "instance", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L381-L403
3,869
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.castNumberType
public static Object castNumberType(Object object, Class clazz) { if (Number.class.isAssignableFrom(clazz)) { // AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short if (Double.class.isAssignableFrom(clazz)) { return ((Number) object).doubleValue(); } else if (Long.class.isAssignableFrom(clazz)) { return ((Number) object).longValue(); } else if (Float.class.isAssignableFrom(clazz)) { return ((Number) object).floatValue(); } else if (Integer.class.isAssignableFrom(clazz)) { return ((Number) object).intValue(); } else if (Short.class.isAssignableFrom(clazz)) { return ((Number) object).shortValue(); } else if (Byte.class.isAssignableFrom(clazz)) { return ((Number) object).byteValue(); } else if (BigInteger.class.isAssignableFrom(clazz)) { return BigInteger.valueOf(((Number) object).longValue()); } else if (BigDecimal.class.isAssignableFrom(clazz)) { return BigDecimal.valueOf(((Number) object).longValue()); } else if (AtomicLong.class.isAssignableFrom(clazz)) { return new AtomicLong(((Number) object).longValue()); } else if (AtomicInteger.class.isAssignableFrom(clazz)) { return new AtomicInteger(((Number) object).intValue()); } } throw new ClassCastException("it is not a Number Type" + object.getClass() + "|" + clazz); }
java
public static Object castNumberType(Object object, Class clazz) { if (Number.class.isAssignableFrom(clazz)) { // AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short if (Double.class.isAssignableFrom(clazz)) { return ((Number) object).doubleValue(); } else if (Long.class.isAssignableFrom(clazz)) { return ((Number) object).longValue(); } else if (Float.class.isAssignableFrom(clazz)) { return ((Number) object).floatValue(); } else if (Integer.class.isAssignableFrom(clazz)) { return ((Number) object).intValue(); } else if (Short.class.isAssignableFrom(clazz)) { return ((Number) object).shortValue(); } else if (Byte.class.isAssignableFrom(clazz)) { return ((Number) object).byteValue(); } else if (BigInteger.class.isAssignableFrom(clazz)) { return BigInteger.valueOf(((Number) object).longValue()); } else if (BigDecimal.class.isAssignableFrom(clazz)) { return BigDecimal.valueOf(((Number) object).longValue()); } else if (AtomicLong.class.isAssignableFrom(clazz)) { return new AtomicLong(((Number) object).longValue()); } else if (AtomicInteger.class.isAssignableFrom(clazz)) { return new AtomicInteger(((Number) object).intValue()); } } throw new ClassCastException("it is not a Number Type" + object.getClass() + "|" + clazz); }
[ "public", "static", "Object", "castNumberType", "(", "Object", "object", ",", "Class", "clazz", ")", "{", "if", "(", "Number", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "// AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short", "if", "(", "Double", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "(", "(", "Number", ")", "object", ")", ".", "doubleValue", "(", ")", ";", "}", "else", "if", "(", "Long", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "(", "(", "Number", ")", "object", ")", ".", "longValue", "(", ")", ";", "}", "else", "if", "(", "Float", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "(", "(", "Number", ")", "object", ")", ".", "floatValue", "(", ")", ";", "}", "else", "if", "(", "Integer", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "(", "(", "Number", ")", "object", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "Short", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "(", "(", "Number", ")", "object", ")", ".", "shortValue", "(", ")", ";", "}", "else", "if", "(", "Byte", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "(", "(", "Number", ")", "object", ")", ".", "byteValue", "(", ")", ";", "}", "else", "if", "(", "BigInteger", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "BigInteger", ".", "valueOf", "(", "(", "(", "Number", ")", "object", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "BigDecimal", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "BigDecimal", ".", "valueOf", "(", "(", "(", "Number", ")", "object", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "AtomicLong", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "new", "AtomicLong", "(", "(", "(", "Number", ")", "object", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "AtomicInteger", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "new", "AtomicInteger", "(", "(", "(", "Number", ")", "object", ")", ".", "intValue", "(", ")", ")", ";", "}", "}", "throw", "new", "ClassCastException", "(", "\"it is not a Number Type\"", "+", "object", ".", "getClass", "(", ")", "+", "\"|\"", "+", "clazz", ")", ";", "}" ]
Cast number type. @param object the object @param clazz the clazz @return object
[ "Cast", "number", "type", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L412-L447
3,870
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.cloneObjectWithParents
public static <T> T cloneObjectWithParents (T t) throws IllegalAccessException, InstantiationException { T clone = (T) t.getClass().newInstance(); List<Field> allFields = new ArrayList<>(); Class parentClass = t.getClass().getSuperclass(); while (parentClass != null) { Collections.addAll(allFields, parentClass.getDeclaredFields()); parentClass = parentClass.getSuperclass(); } Collections.addAll(allFields, t.getClass().getDeclaredFields()); for (Field field : allFields) { int modifiers = field.getModifiers(); //We skip final and static fields if ((Modifier.FINAL & modifiers) != 0 || (Modifier.STATIC & modifiers) != 0) { continue; } field.setAccessible(true); Object value = field.get(t); if (Collection.class.isAssignableFrom(field.getType())) { Collection collection = (Collection) field.get(clone); if (collection == null) { collection = (Collection) field.get(t).getClass().newInstance(); } collection.addAll((Collection) field.get(t)); value = collection; } else if (Map.class.isAssignableFrom(field.getType())) { Map clonMap = (Map) field.get(t).getClass().newInstance(); clonMap.putAll((Map) field.get(t)); value = clonMap; } field.set(clone, value); } return clone; }
java
public static <T> T cloneObjectWithParents (T t) throws IllegalAccessException, InstantiationException { T clone = (T) t.getClass().newInstance(); List<Field> allFields = new ArrayList<>(); Class parentClass = t.getClass().getSuperclass(); while (parentClass != null) { Collections.addAll(allFields, parentClass.getDeclaredFields()); parentClass = parentClass.getSuperclass(); } Collections.addAll(allFields, t.getClass().getDeclaredFields()); for (Field field : allFields) { int modifiers = field.getModifiers(); //We skip final and static fields if ((Modifier.FINAL & modifiers) != 0 || (Modifier.STATIC & modifiers) != 0) { continue; } field.setAccessible(true); Object value = field.get(t); if (Collection.class.isAssignableFrom(field.getType())) { Collection collection = (Collection) field.get(clone); if (collection == null) { collection = (Collection) field.get(t).getClass().newInstance(); } collection.addAll((Collection) field.get(t)); value = collection; } else if (Map.class.isAssignableFrom(field.getType())) { Map clonMap = (Map) field.get(t).getClass().newInstance(); clonMap.putAll((Map) field.get(t)); value = clonMap; } field.set(clone, value); } return clone; }
[ "public", "static", "<", "T", ">", "T", "cloneObjectWithParents", "(", "T", "t", ")", "throws", "IllegalAccessException", ",", "InstantiationException", "{", "T", "clone", "=", "(", "T", ")", "t", ".", "getClass", "(", ")", ".", "newInstance", "(", ")", ";", "List", "<", "Field", ">", "allFields", "=", "new", "ArrayList", "<>", "(", ")", ";", "Class", "parentClass", "=", "t", ".", "getClass", "(", ")", ".", "getSuperclass", "(", ")", ";", "while", "(", "parentClass", "!=", "null", ")", "{", "Collections", ".", "addAll", "(", "allFields", ",", "parentClass", ".", "getDeclaredFields", "(", ")", ")", ";", "parentClass", "=", "parentClass", ".", "getSuperclass", "(", ")", ";", "}", "Collections", ".", "addAll", "(", "allFields", ",", "t", ".", "getClass", "(", ")", ".", "getDeclaredFields", "(", ")", ")", ";", "for", "(", "Field", "field", ":", "allFields", ")", "{", "int", "modifiers", "=", "field", ".", "getModifiers", "(", ")", ";", "//We skip final and static fields", "if", "(", "(", "Modifier", ".", "FINAL", "&", "modifiers", ")", "!=", "0", "||", "(", "Modifier", ".", "STATIC", "&", "modifiers", ")", "!=", "0", ")", "{", "continue", ";", "}", "field", ".", "setAccessible", "(", "true", ")", ";", "Object", "value", "=", "field", ".", "get", "(", "t", ")", ";", "if", "(", "Collection", ".", "class", ".", "isAssignableFrom", "(", "field", ".", "getType", "(", ")", ")", ")", "{", "Collection", "collection", "=", "(", "Collection", ")", "field", ".", "get", "(", "clone", ")", ";", "if", "(", "collection", "==", "null", ")", "{", "collection", "=", "(", "Collection", ")", "field", ".", "get", "(", "t", ")", ".", "getClass", "(", ")", ".", "newInstance", "(", ")", ";", "}", "collection", ".", "addAll", "(", "(", "Collection", ")", "field", ".", "get", "(", "t", ")", ")", ";", "value", "=", "collection", ";", "}", "else", "if", "(", "Map", ".", "class", ".", "isAssignableFrom", "(", "field", ".", "getType", "(", ")", ")", ")", "{", "Map", "clonMap", "=", "(", "Map", ")", "field", ".", "get", "(", "t", ")", ".", "getClass", "(", ")", ".", "newInstance", "(", ")", ";", "clonMap", ".", "putAll", "(", "(", "Map", ")", "field", ".", "get", "(", "t", ")", ")", ";", "value", "=", "clonMap", ";", "}", "field", ".", "set", "(", "clone", ",", "value", ")", ";", "}", "return", "clone", ";", "}" ]
Returns an instance clone. this method gets every class property by reflection, including its parents properties @param t @param <T> @return T object.
[ "Returns", "an", "instance", "clone", ".", "this", "method", "gets", "every", "class", "property", "by", "reflection", "including", "its", "parents", "properties" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L498-L538
3,871
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java
Utils.newBlockingFixedThreadPoolExecutor
public static ExecutorService newBlockingFixedThreadPoolExecutor(int nThreads, int queueSize) { BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(queueSize); RejectedExecutionHandler blockingRejectedExecutionHandler = new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable task, ThreadPoolExecutor executor) { try { executor.getQueue().put(task); } catch (InterruptedException e) { } } }; return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, blockingQueue, blockingRejectedExecutionHandler); }
java
public static ExecutorService newBlockingFixedThreadPoolExecutor(int nThreads, int queueSize) { BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(queueSize); RejectedExecutionHandler blockingRejectedExecutionHandler = new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable task, ThreadPoolExecutor executor) { try { executor.getQueue().put(task); } catch (InterruptedException e) { } } }; return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, blockingQueue, blockingRejectedExecutionHandler); }
[ "public", "static", "ExecutorService", "newBlockingFixedThreadPoolExecutor", "(", "int", "nThreads", ",", "int", "queueSize", ")", "{", "BlockingQueue", "<", "Runnable", ">", "blockingQueue", "=", "new", "ArrayBlockingQueue", "<>", "(", "queueSize", ")", ";", "RejectedExecutionHandler", "blockingRejectedExecutionHandler", "=", "new", "RejectedExecutionHandler", "(", ")", "{", "@", "Override", "public", "void", "rejectedExecution", "(", "Runnable", "task", ",", "ThreadPoolExecutor", "executor", ")", "{", "try", "{", "executor", ".", "getQueue", "(", ")", ".", "put", "(", "task", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", ";", "return", "new", "ThreadPoolExecutor", "(", "nThreads", ",", "nThreads", ",", "0L", ",", "TimeUnit", ".", "MILLISECONDS", ",", "blockingQueue", ",", "blockingRejectedExecutionHandler", ")", ";", "}" ]
Returns an instance of ThreadPoolExecutor using an bounded queue and blocking when the worker queue is full. @param nThreads thread pool size @param queueSize workers queue size @return thread pool executor
[ "Returns", "an", "instance", "of", "ThreadPoolExecutor", "using", "an", "bounded", "queue", "and", "blocking", "when", "the", "worker", "queue", "is", "full", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L546-L562
3,872
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/config/DeepJobConfig.java
DeepJobConfig.getNameSpace
public String getNameSpace() { if (nameSpace == null) { nameSpace = new StringBuilder().append(catalog).append(".").append(table).toString(); } return nameSpace; }
java
public String getNameSpace() { if (nameSpace == null) { nameSpace = new StringBuilder().append(catalog).append(".").append(table).toString(); } return nameSpace; }
[ "public", "String", "getNameSpace", "(", ")", "{", "if", "(", "nameSpace", "==", "null", ")", "{", "nameSpace", "=", "new", "StringBuilder", "(", ")", ".", "append", "(", "catalog", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "table", ")", ".", "toString", "(", ")", ";", "}", "return", "nameSpace", ";", "}" ]
Get name space. @return the string
[ "Get", "name", "space", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/config/DeepJobConfig.java#L129-L135
3,873
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/config/DeepJobConfig.java
DeepJobConfig.initialize
public S initialize(ExtractorConfig extractorConfig) { setExtractorImplClassName(extractorConfig.getExtractorImplClassName()); setEntityClass(extractorConfig.getEntityClass()); setRddId(extractorConfig.getRddId()); setPartitionId(extractorConfig.getPartitionId()); Map<String, Serializable> values = extractorConfig.getValues(); if (values.get(USERNAME) != null) { username(extractorConfig.getString(USERNAME)); } if (values.get(PASSWORD) != null) { password(extractorConfig.getString(PASSWORD)); } if (values.get(HOST) != null) { host((extractorConfig.getStringArray(HOST))); } if (values.get(ES_REST_PORTS) != null) { port((extractorConfig.getInteger(ES_REST_PORTS))); } if (values.get(PORT) != null) { port((extractorConfig.getInteger(PORT))); } if (values.get(COLLECTION) != null) { table(extractorConfig.getString(COLLECTION)); } if (values.get(INPUT_COLUMNS) != null) { inputColumns(extractorConfig.getStringArray(INPUT_COLUMNS)); } if (values.get(DATABASE) != null) { catalog(extractorConfig.getString(DATABASE)); } if (values.get(FILTER_QUERY) != null) { filters(extractorConfig.getFilterArray(FILTER_QUERY)); } return (S) this; }
java
public S initialize(ExtractorConfig extractorConfig) { setExtractorImplClassName(extractorConfig.getExtractorImplClassName()); setEntityClass(extractorConfig.getEntityClass()); setRddId(extractorConfig.getRddId()); setPartitionId(extractorConfig.getPartitionId()); Map<String, Serializable> values = extractorConfig.getValues(); if (values.get(USERNAME) != null) { username(extractorConfig.getString(USERNAME)); } if (values.get(PASSWORD) != null) { password(extractorConfig.getString(PASSWORD)); } if (values.get(HOST) != null) { host((extractorConfig.getStringArray(HOST))); } if (values.get(ES_REST_PORTS) != null) { port((extractorConfig.getInteger(ES_REST_PORTS))); } if (values.get(PORT) != null) { port((extractorConfig.getInteger(PORT))); } if (values.get(COLLECTION) != null) { table(extractorConfig.getString(COLLECTION)); } if (values.get(INPUT_COLUMNS) != null) { inputColumns(extractorConfig.getStringArray(INPUT_COLUMNS)); } if (values.get(DATABASE) != null) { catalog(extractorConfig.getString(DATABASE)); } if (values.get(FILTER_QUERY) != null) { filters(extractorConfig.getFilterArray(FILTER_QUERY)); } return (S) this; }
[ "public", "S", "initialize", "(", "ExtractorConfig", "extractorConfig", ")", "{", "setExtractorImplClassName", "(", "extractorConfig", ".", "getExtractorImplClassName", "(", ")", ")", ";", "setEntityClass", "(", "extractorConfig", ".", "getEntityClass", "(", ")", ")", ";", "setRddId", "(", "extractorConfig", ".", "getRddId", "(", ")", ")", ";", "setPartitionId", "(", "extractorConfig", ".", "getPartitionId", "(", ")", ")", ";", "Map", "<", "String", ",", "Serializable", ">", "values", "=", "extractorConfig", ".", "getValues", "(", ")", ";", "if", "(", "values", ".", "get", "(", "USERNAME", ")", "!=", "null", ")", "{", "username", "(", "extractorConfig", ".", "getString", "(", "USERNAME", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "PASSWORD", ")", "!=", "null", ")", "{", "password", "(", "extractorConfig", ".", "getString", "(", "PASSWORD", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "HOST", ")", "!=", "null", ")", "{", "host", "(", "(", "extractorConfig", ".", "getStringArray", "(", "HOST", ")", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "ES_REST_PORTS", ")", "!=", "null", ")", "{", "port", "(", "(", "extractorConfig", ".", "getInteger", "(", "ES_REST_PORTS", ")", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "PORT", ")", "!=", "null", ")", "{", "port", "(", "(", "extractorConfig", ".", "getInteger", "(", "PORT", ")", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "COLLECTION", ")", "!=", "null", ")", "{", "table", "(", "extractorConfig", ".", "getString", "(", "COLLECTION", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "INPUT_COLUMNS", ")", "!=", "null", ")", "{", "inputColumns", "(", "extractorConfig", ".", "getStringArray", "(", "INPUT_COLUMNS", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "DATABASE", ")", "!=", "null", ")", "{", "catalog", "(", "extractorConfig", ".", "getString", "(", "DATABASE", ")", ")", ";", "}", "if", "(", "values", ".", "get", "(", "FILTER_QUERY", ")", "!=", "null", ")", "{", "filters", "(", "extractorConfig", ".", "getFilterArray", "(", "FILTER_QUERY", ")", ")", ";", "}", "return", "(", "S", ")", "this", ";", "}" ]
Initialize s. @param extractorConfig the extractor config @return the s
[ "Initialize", "s", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/config/DeepJobConfig.java#L191-L238
3,874
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.isShardedCollection
private boolean isShardedCollection(DBCollection collection) { DB config = collection.getDB().getMongo().getDB("config"); DBCollection configCollections = config.getCollection("collections"); DBObject dbObject = configCollections.findOne(new BasicDBObject(MONGO_DEFAULT_ID, collection.getFullName())); return dbObject != null; }
java
private boolean isShardedCollection(DBCollection collection) { DB config = collection.getDB().getMongo().getDB("config"); DBCollection configCollections = config.getCollection("collections"); DBObject dbObject = configCollections.findOne(new BasicDBObject(MONGO_DEFAULT_ID, collection.getFullName())); return dbObject != null; }
[ "private", "boolean", "isShardedCollection", "(", "DBCollection", "collection", ")", "{", "DB", "config", "=", "collection", ".", "getDB", "(", ")", ".", "getMongo", "(", ")", ".", "getDB", "(", "\"config\"", ")", ";", "DBCollection", "configCollections", "=", "config", ".", "getCollection", "(", "\"collections\"", ")", ";", "DBObject", "dbObject", "=", "configCollections", ".", "findOne", "(", "new", "BasicDBObject", "(", "MONGO_DEFAULT_ID", ",", "collection", ".", "getFullName", "(", ")", ")", ")", ";", "return", "dbObject", "!=", "null", ";", "}" ]
Is sharded collection. @param collection the collection @return the boolean
[ "Is", "sharded", "collection", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L137-L144
3,875
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.getShards
private Map<String, String[]> getShards(DBCollection collection) { DB config = collection.getDB().getSisterDB("config"); DBCollection configShards = config.getCollection("shards"); DBCursor cursorShards = configShards.find(); Map<String, String[]> map = new HashMap<>(); while (cursorShards.hasNext()) { DBObject currentShard = cursorShards.next(); String currentHost = (String) currentShard.get("host"); int slashIndex = currentHost.indexOf("/"); if (slashIndex > 0) { map.put((String) currentShard.get(MONGO_DEFAULT_ID), currentHost.substring(slashIndex + 1).split(",")); } } return map; }
java
private Map<String, String[]> getShards(DBCollection collection) { DB config = collection.getDB().getSisterDB("config"); DBCollection configShards = config.getCollection("shards"); DBCursor cursorShards = configShards.find(); Map<String, String[]> map = new HashMap<>(); while (cursorShards.hasNext()) { DBObject currentShard = cursorShards.next(); String currentHost = (String) currentShard.get("host"); int slashIndex = currentHost.indexOf("/"); if (slashIndex > 0) { map.put((String) currentShard.get(MONGO_DEFAULT_ID), currentHost.substring(slashIndex + 1).split(",")); } } return map; }
[ "private", "Map", "<", "String", ",", "String", "[", "]", ">", "getShards", "(", "DBCollection", "collection", ")", "{", "DB", "config", "=", "collection", ".", "getDB", "(", ")", ".", "getSisterDB", "(", "\"config\"", ")", ";", "DBCollection", "configShards", "=", "config", ".", "getCollection", "(", "\"shards\"", ")", ";", "DBCursor", "cursorShards", "=", "configShards", ".", "find", "(", ")", ";", "Map", "<", "String", ",", "String", "[", "]", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "while", "(", "cursorShards", ".", "hasNext", "(", ")", ")", "{", "DBObject", "currentShard", "=", "cursorShards", ".", "next", "(", ")", ";", "String", "currentHost", "=", "(", "String", ")", "currentShard", ".", "get", "(", "\"host\"", ")", ";", "int", "slashIndex", "=", "currentHost", ".", "indexOf", "(", "\"/\"", ")", ";", "if", "(", "slashIndex", ">", "0", ")", "{", "map", ".", "put", "(", "(", "String", ")", "currentShard", ".", "get", "(", "MONGO_DEFAULT_ID", ")", ",", "currentHost", ".", "substring", "(", "slashIndex", "+", "1", ")", ".", "split", "(", "\",\"", ")", ")", ";", "}", "}", "return", "map", ";", "}" ]
Gets shards. @param collection the collection @return the shards
[ "Gets", "shards", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L152-L169
3,876
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.getChunks
private DBCursor getChunks(DBCollection collection) { DB config = collection.getDB().getSisterDB("config"); DBCollection configChunks = config.getCollection("chunks"); return configChunks.find(new BasicDBObject("ns", collection.getFullName())); }
java
private DBCursor getChunks(DBCollection collection) { DB config = collection.getDB().getSisterDB("config"); DBCollection configChunks = config.getCollection("chunks"); return configChunks.find(new BasicDBObject("ns", collection.getFullName())); }
[ "private", "DBCursor", "getChunks", "(", "DBCollection", "collection", ")", "{", "DB", "config", "=", "collection", ".", "getDB", "(", ")", ".", "getSisterDB", "(", "\"config\"", ")", ";", "DBCollection", "configChunks", "=", "config", ".", "getCollection", "(", "\"chunks\"", ")", ";", "return", "configChunks", ".", "find", "(", "new", "BasicDBObject", "(", "\"ns\"", ",", "collection", ".", "getFullName", "(", ")", ")", ")", ";", "}" ]
Gets chunks. @param collection the collection @return the chunks
[ "Gets", "chunks", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L177-L181
3,877
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.calculateSplits
private DeepPartition[] calculateSplits(DBCollection collection) { BasicDBList splitData = getSplitData(collection); List<ServerAddress> serverAddressList = collection.getDB().getMongo().getServerAddressList(); if (splitData == null) { Pair<BasicDBList, List<ServerAddress>> pair = getSplitDataCollectionShardEnviroment(getShards(collection), collection.getDB().getName(), collection.getName()); splitData = pair.left; serverAddressList = pair.right; } Object lastKey = null; // Lower boundary of the first min split List<String> stringHosts = new ArrayList<>(); for (ServerAddress serverAddress : serverAddressList) { stringHosts.add(serverAddress.toString()); } int i = 0; MongoPartition[] partitions = new MongoPartition[splitData.size() + 1]; for (Object aSplitData : splitData) { BasicDBObject currentKey = (BasicDBObject) aSplitData; Object currentO = currentKey.get(MONGO_DEFAULT_ID); partitions[i] = new MongoPartition(mongoDeepJobConfig.getRddId(), i, new DeepTokenRange(lastKey, currentO, stringHosts), MONGO_DEFAULT_ID); lastKey = currentO; i++; } QueryBuilder queryBuilder = QueryBuilder.start(MONGO_DEFAULT_ID); queryBuilder.greaterThanEquals(lastKey); partitions[i] = new MongoPartition(0, i, new DeepTokenRange(lastKey, null, stringHosts), MONGO_DEFAULT_ID); return partitions; }
java
private DeepPartition[] calculateSplits(DBCollection collection) { BasicDBList splitData = getSplitData(collection); List<ServerAddress> serverAddressList = collection.getDB().getMongo().getServerAddressList(); if (splitData == null) { Pair<BasicDBList, List<ServerAddress>> pair = getSplitDataCollectionShardEnviroment(getShards(collection), collection.getDB().getName(), collection.getName()); splitData = pair.left; serverAddressList = pair.right; } Object lastKey = null; // Lower boundary of the first min split List<String> stringHosts = new ArrayList<>(); for (ServerAddress serverAddress : serverAddressList) { stringHosts.add(serverAddress.toString()); } int i = 0; MongoPartition[] partitions = new MongoPartition[splitData.size() + 1]; for (Object aSplitData : splitData) { BasicDBObject currentKey = (BasicDBObject) aSplitData; Object currentO = currentKey.get(MONGO_DEFAULT_ID); partitions[i] = new MongoPartition(mongoDeepJobConfig.getRddId(), i, new DeepTokenRange(lastKey, currentO, stringHosts), MONGO_DEFAULT_ID); lastKey = currentO; i++; } QueryBuilder queryBuilder = QueryBuilder.start(MONGO_DEFAULT_ID); queryBuilder.greaterThanEquals(lastKey); partitions[i] = new MongoPartition(0, i, new DeepTokenRange(lastKey, null, stringHosts), MONGO_DEFAULT_ID); return partitions; }
[ "private", "DeepPartition", "[", "]", "calculateSplits", "(", "DBCollection", "collection", ")", "{", "BasicDBList", "splitData", "=", "getSplitData", "(", "collection", ")", ";", "List", "<", "ServerAddress", ">", "serverAddressList", "=", "collection", ".", "getDB", "(", ")", ".", "getMongo", "(", ")", ".", "getServerAddressList", "(", ")", ";", "if", "(", "splitData", "==", "null", ")", "{", "Pair", "<", "BasicDBList", ",", "List", "<", "ServerAddress", ">", ">", "pair", "=", "getSplitDataCollectionShardEnviroment", "(", "getShards", "(", "collection", ")", ",", "collection", ".", "getDB", "(", ")", ".", "getName", "(", ")", ",", "collection", ".", "getName", "(", ")", ")", ";", "splitData", "=", "pair", ".", "left", ";", "serverAddressList", "=", "pair", ".", "right", ";", "}", "Object", "lastKey", "=", "null", ";", "// Lower boundary of the first min split", "List", "<", "String", ">", "stringHosts", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "ServerAddress", "serverAddress", ":", "serverAddressList", ")", "{", "stringHosts", ".", "add", "(", "serverAddress", ".", "toString", "(", ")", ")", ";", "}", "int", "i", "=", "0", ";", "MongoPartition", "[", "]", "partitions", "=", "new", "MongoPartition", "[", "splitData", ".", "size", "(", ")", "+", "1", "]", ";", "for", "(", "Object", "aSplitData", ":", "splitData", ")", "{", "BasicDBObject", "currentKey", "=", "(", "BasicDBObject", ")", "aSplitData", ";", "Object", "currentO", "=", "currentKey", ".", "get", "(", "MONGO_DEFAULT_ID", ")", ";", "partitions", "[", "i", "]", "=", "new", "MongoPartition", "(", "mongoDeepJobConfig", ".", "getRddId", "(", ")", ",", "i", ",", "new", "DeepTokenRange", "(", "lastKey", ",", "currentO", ",", "stringHosts", ")", ",", "MONGO_DEFAULT_ID", ")", ";", "lastKey", "=", "currentO", ";", "i", "++", ";", "}", "QueryBuilder", "queryBuilder", "=", "QueryBuilder", ".", "start", "(", "MONGO_DEFAULT_ID", ")", ";", "queryBuilder", ".", "greaterThanEquals", "(", "lastKey", ")", ";", "partitions", "[", "i", "]", "=", "new", "MongoPartition", "(", "0", ",", "i", ",", "new", "DeepTokenRange", "(", "lastKey", ",", "null", ",", "stringHosts", ")", ",", "MONGO_DEFAULT_ID", ")", ";", "return", "partitions", ";", "}" ]
Calculate splits. @param collection the collection @return the deep partition [ ]
[ "Calculate", "splits", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L189-L229
3,878
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.getSplitData
private BasicDBList getSplitData(DBCollection collection) { final DBObject cmd = BasicDBObjectBuilder.start("splitVector", collection.getFullName()) .add("keyPattern", new BasicDBObject(MONGO_DEFAULT_ID, 1)) .add("force", false) .add("maxChunkSize", splitSize) .get(); CommandResult splitVectorResult = collection.getDB().getSisterDB("admin").command(cmd); return (BasicDBList) splitVectorResult.get(SPLIT_KEYS); }
java
private BasicDBList getSplitData(DBCollection collection) { final DBObject cmd = BasicDBObjectBuilder.start("splitVector", collection.getFullName()) .add("keyPattern", new BasicDBObject(MONGO_DEFAULT_ID, 1)) .add("force", false) .add("maxChunkSize", splitSize) .get(); CommandResult splitVectorResult = collection.getDB().getSisterDB("admin").command(cmd); return (BasicDBList) splitVectorResult.get(SPLIT_KEYS); }
[ "private", "BasicDBList", "getSplitData", "(", "DBCollection", "collection", ")", "{", "final", "DBObject", "cmd", "=", "BasicDBObjectBuilder", ".", "start", "(", "\"splitVector\"", ",", "collection", ".", "getFullName", "(", ")", ")", ".", "add", "(", "\"keyPattern\"", ",", "new", "BasicDBObject", "(", "MONGO_DEFAULT_ID", ",", "1", ")", ")", ".", "add", "(", "\"force\"", ",", "false", ")", ".", "add", "(", "\"maxChunkSize\"", ",", "splitSize", ")", ".", "get", "(", ")", ";", "CommandResult", "splitVectorResult", "=", "collection", ".", "getDB", "(", ")", ".", "getSisterDB", "(", "\"admin\"", ")", ".", "command", "(", "cmd", ")", ";", "return", "(", "BasicDBList", ")", "splitVectorResult", ".", "get", "(", "SPLIT_KEYS", ")", ";", "}" ]
Gets split data. @param collection the collection @return the split data
[ "Gets", "split", "data", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L237-L248
3,879
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.getSplitDataCollectionShardEnviroment
private Pair<BasicDBList, List<ServerAddress>> getSplitDataCollectionShardEnviroment(Map<String, String[]> shards, String dbName, String collectionName) { MongoClient mongoClient = null; try { Set<String> keys = shards.keySet(); for (String key : keys) { List<ServerAddress> addressList = getServerAddressList(Arrays.asList(shards.get(key))); mongoClient = new MongoClient(addressList); BasicDBList dbList = getSplitData(mongoClient.getDB(dbName).getCollection(collectionName)); if (dbList != null) { return Pair.create(dbList, addressList); } } } catch (UnknownHostException e) { throw new DeepGenericException(e); } finally { if (mongoClient != null) { mongoClient.close(); } } return null; }
java
private Pair<BasicDBList, List<ServerAddress>> getSplitDataCollectionShardEnviroment(Map<String, String[]> shards, String dbName, String collectionName) { MongoClient mongoClient = null; try { Set<String> keys = shards.keySet(); for (String key : keys) { List<ServerAddress> addressList = getServerAddressList(Arrays.asList(shards.get(key))); mongoClient = new MongoClient(addressList); BasicDBList dbList = getSplitData(mongoClient.getDB(dbName).getCollection(collectionName)); if (dbList != null) { return Pair.create(dbList, addressList); } } } catch (UnknownHostException e) { throw new DeepGenericException(e); } finally { if (mongoClient != null) { mongoClient.close(); } } return null; }
[ "private", "Pair", "<", "BasicDBList", ",", "List", "<", "ServerAddress", ">", ">", "getSplitDataCollectionShardEnviroment", "(", "Map", "<", "String", ",", "String", "[", "]", ">", "shards", ",", "String", "dbName", ",", "String", "collectionName", ")", "{", "MongoClient", "mongoClient", "=", "null", ";", "try", "{", "Set", "<", "String", ">", "keys", "=", "shards", ".", "keySet", "(", ")", ";", "for", "(", "String", "key", ":", "keys", ")", "{", "List", "<", "ServerAddress", ">", "addressList", "=", "getServerAddressList", "(", "Arrays", ".", "asList", "(", "shards", ".", "get", "(", "key", ")", ")", ")", ";", "mongoClient", "=", "new", "MongoClient", "(", "addressList", ")", ";", "BasicDBList", "dbList", "=", "getSplitData", "(", "mongoClient", ".", "getDB", "(", "dbName", ")", ".", "getCollection", "(", "collectionName", ")", ")", ";", "if", "(", "dbList", "!=", "null", ")", "{", "return", "Pair", ".", "create", "(", "dbList", ",", "addressList", ")", ";", "}", "}", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "throw", "new", "DeepGenericException", "(", "e", ")", ";", "}", "finally", "{", "if", "(", "mongoClient", "!=", "null", ")", "{", "mongoClient", ".", "close", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Gets split data collection shard enviroment. @param shards the shards @param dbName the db name @param collectionName the collection name @return the split data collection shard enviroment
[ "Gets", "split", "data", "collection", "shard", "enviroment", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L258-L288
3,880
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.calculateShardChunks
private DeepPartition[] calculateShardChunks(DBCollection collection) { DBCursor chuncks = getChunks(collection); Map<String, String[]> shards = getShards(collection); MongoPartition[] deepPartitions = new MongoPartition[chuncks.count()]; int i = 0; boolean keyAssigned = false; String key = null; while (chuncks.hasNext()) { DBObject dbObject = chuncks.next(); if (!keyAssigned) { Set<String> keySet = ((DBObject) dbObject.get("min")).keySet(); for (String s : keySet) { key = s; keyAssigned = true; } } deepPartitions[i] = new MongoPartition(mongoDeepJobConfig.getRddId(), i, new DeepTokenRange(shards.get(dbObject.get ("shard")), ((DBObject) dbObject.get ("min")).get(key), ((DBObject) dbObject.get("max")).get(key)), key); i++; } List<MongoPartition> mongoPartitions = Arrays.asList(deepPartitions); Collections.shuffle(mongoPartitions); return mongoPartitions.toArray(new MongoPartition[mongoPartitions.size()]); }
java
private DeepPartition[] calculateShardChunks(DBCollection collection) { DBCursor chuncks = getChunks(collection); Map<String, String[]> shards = getShards(collection); MongoPartition[] deepPartitions = new MongoPartition[chuncks.count()]; int i = 0; boolean keyAssigned = false; String key = null; while (chuncks.hasNext()) { DBObject dbObject = chuncks.next(); if (!keyAssigned) { Set<String> keySet = ((DBObject) dbObject.get("min")).keySet(); for (String s : keySet) { key = s; keyAssigned = true; } } deepPartitions[i] = new MongoPartition(mongoDeepJobConfig.getRddId(), i, new DeepTokenRange(shards.get(dbObject.get ("shard")), ((DBObject) dbObject.get ("min")).get(key), ((DBObject) dbObject.get("max")).get(key)), key); i++; } List<MongoPartition> mongoPartitions = Arrays.asList(deepPartitions); Collections.shuffle(mongoPartitions); return mongoPartitions.toArray(new MongoPartition[mongoPartitions.size()]); }
[ "private", "DeepPartition", "[", "]", "calculateShardChunks", "(", "DBCollection", "collection", ")", "{", "DBCursor", "chuncks", "=", "getChunks", "(", "collection", ")", ";", "Map", "<", "String", ",", "String", "[", "]", ">", "shards", "=", "getShards", "(", "collection", ")", ";", "MongoPartition", "[", "]", "deepPartitions", "=", "new", "MongoPartition", "[", "chuncks", ".", "count", "(", ")", "]", ";", "int", "i", "=", "0", ";", "boolean", "keyAssigned", "=", "false", ";", "String", "key", "=", "null", ";", "while", "(", "chuncks", ".", "hasNext", "(", ")", ")", "{", "DBObject", "dbObject", "=", "chuncks", ".", "next", "(", ")", ";", "if", "(", "!", "keyAssigned", ")", "{", "Set", "<", "String", ">", "keySet", "=", "(", "(", "DBObject", ")", "dbObject", ".", "get", "(", "\"min\"", ")", ")", ".", "keySet", "(", ")", ";", "for", "(", "String", "s", ":", "keySet", ")", "{", "key", "=", "s", ";", "keyAssigned", "=", "true", ";", "}", "}", "deepPartitions", "[", "i", "]", "=", "new", "MongoPartition", "(", "mongoDeepJobConfig", ".", "getRddId", "(", ")", ",", "i", ",", "new", "DeepTokenRange", "(", "shards", ".", "get", "(", "dbObject", ".", "get", "(", "\"shard\"", ")", ")", ",", "(", "(", "DBObject", ")", "dbObject", ".", "get", "(", "\"min\"", ")", ")", ".", "get", "(", "key", ")", ",", "(", "(", "DBObject", ")", "dbObject", ".", "get", "(", "\"max\"", ")", ")", ".", "get", "(", "key", ")", ")", ",", "key", ")", ";", "i", "++", ";", "}", "List", "<", "MongoPartition", ">", "mongoPartitions", "=", "Arrays", ".", "asList", "(", "deepPartitions", ")", ";", "Collections", ".", "shuffle", "(", "mongoPartitions", ")", ";", "return", "mongoPartitions", ".", "toArray", "(", "new", "MongoPartition", "[", "mongoPartitions", ".", "size", "(", ")", "]", ")", ";", "}" ]
Calculates shard chunks. @param collection the collection @return the deep partition [ ]
[ "Calculates", "shard", "chunks", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L301-L333
3,881
Stratio/deep-spark
deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java
MongoNativeExtractor.getServerAddressList
private List<ServerAddress> getServerAddressList(List<String> addressStringList) throws UnknownHostException { List<ServerAddress> addressList = new ArrayList<>(); for (String addressString : addressStringList) { addressList.add(new ServerAddress(addressString)); } return addressList; }
java
private List<ServerAddress> getServerAddressList(List<String> addressStringList) throws UnknownHostException { List<ServerAddress> addressList = new ArrayList<>(); for (String addressString : addressStringList) { addressList.add(new ServerAddress(addressString)); } return addressList; }
[ "private", "List", "<", "ServerAddress", ">", "getServerAddressList", "(", "List", "<", "String", ">", "addressStringList", ")", "throws", "UnknownHostException", "{", "List", "<", "ServerAddress", ">", "addressList", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "addressString", ":", "addressStringList", ")", "{", "addressList", ".", "add", "(", "new", "ServerAddress", "(", "addressString", ")", ")", ";", "}", "return", "addressList", ";", "}" ]
Gets server address list. @param addressStringList the address string list @return the server address list @throws UnknownHostException the unknown host exception
[ "Gets", "server", "address", "list", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/extractor/MongoNativeExtractor.java#L342-L350
3,882
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.createRDD
public <T> RDD<T> createRDD(ExtractorConfig<T> config) { return new DeepRDD<>(this.sc(), config); }
java
public <T> RDD<T> createRDD(ExtractorConfig<T> config) { return new DeepRDD<>(this.sc(), config); }
[ "public", "<", "T", ">", "RDD", "<", "T", ">", "createRDD", "(", "ExtractorConfig", "<", "T", ">", "config", ")", "{", "return", "new", "DeepRDD", "<>", "(", "this", ".", "sc", "(", ")", ",", "config", ")", ";", "}" ]
Creates a RDD. @param <T> the type parameter @param config the config @return the rDD
[ "Creates", "a", "RDD", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L155-L157
3,883
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.createJavaRDD
public <T> JavaRDD<T> createJavaRDD( ExtractorConfig<T> config) { return new DeepJavaRDD<>((DeepRDD<T, ExtractorConfig<T>>) createRDD(config)); }
java
public <T> JavaRDD<T> createJavaRDD( ExtractorConfig<T> config) { return new DeepJavaRDD<>((DeepRDD<T, ExtractorConfig<T>>) createRDD(config)); }
[ "public", "<", "T", ">", "JavaRDD", "<", "T", ">", "createJavaRDD", "(", "ExtractorConfig", "<", "T", ">", "config", ")", "{", "return", "new", "DeepJavaRDD", "<>", "(", "(", "DeepRDD", "<", "T", ",", "ExtractorConfig", "<", "T", ">", ">", ")", "createRDD", "(", "config", ")", ")", ";", "}" ]
Creates a JavaRDD. @param <T> the type parameter @param config the config @return the java rDD
[ "Creates", "a", "JavaRDD", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L170-L173
3,884
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.createJavaRowRDD
public static JavaRDD<Row> createJavaRowRDD(JavaRDD<Cells> cellsRDD) throws UnsupportedDataTypeException { JavaRDD<Row> result = cellsRDD.map(new Function<Cells, Row>() { @Override public Row call(Cells cells) throws Exception { return CellsUtils.getRowFromCells(cells); } }); return result; }
java
public static JavaRDD<Row> createJavaRowRDD(JavaRDD<Cells> cellsRDD) throws UnsupportedDataTypeException { JavaRDD<Row> result = cellsRDD.map(new Function<Cells, Row>() { @Override public Row call(Cells cells) throws Exception { return CellsUtils.getRowFromCells(cells); } }); return result; }
[ "public", "static", "JavaRDD", "<", "Row", ">", "createJavaRowRDD", "(", "JavaRDD", "<", "Cells", ">", "cellsRDD", ")", "throws", "UnsupportedDataTypeException", "{", "JavaRDD", "<", "Row", ">", "result", "=", "cellsRDD", ".", "map", "(", "new", "Function", "<", "Cells", ",", "Row", ">", "(", ")", "{", "@", "Override", "public", "Row", "call", "(", "Cells", "cells", ")", "throws", "Exception", "{", "return", "CellsUtils", ".", "getRowFromCells", "(", "cells", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Creates a JavaRDD of SparkSQL rows @param cellsRDD RDD of cells for transforming. @return Java RDD of SparkSQL rows @throws UnsupportedDataTypeException
[ "Creates", "a", "JavaRDD", "of", "SparkSQL", "rows" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L185-L193
3,885
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.createJavaSchemaRDD
public DataFrame createJavaSchemaRDD(ExtractorConfig<Cells> config) throws UnsupportedDataTypeException, UnsupportedOperationException { JavaRDD<Cells> cellsRDD = createJavaRDD(config); JavaRDD<Row> rowsRDD = DeepSparkContext.createJavaRowRDD(cellsRDD); try { Cells firstCells = cellsRDD.first(); StructType schema = CellsUtils.getStructTypeFromCells(firstCells); return sqlContext.applySchema(rowsRDD, schema); } catch(UnsupportedOperationException e) { throw new UnsupportedOperationException("Cannot infer schema from empty data RDD", e); } }
java
public DataFrame createJavaSchemaRDD(ExtractorConfig<Cells> config) throws UnsupportedDataTypeException, UnsupportedOperationException { JavaRDD<Cells> cellsRDD = createJavaRDD(config); JavaRDD<Row> rowsRDD = DeepSparkContext.createJavaRowRDD(cellsRDD); try { Cells firstCells = cellsRDD.first(); StructType schema = CellsUtils.getStructTypeFromCells(firstCells); return sqlContext.applySchema(rowsRDD, schema); } catch(UnsupportedOperationException e) { throw new UnsupportedOperationException("Cannot infer schema from empty data RDD", e); } }
[ "public", "DataFrame", "createJavaSchemaRDD", "(", "ExtractorConfig", "<", "Cells", ">", "config", ")", "throws", "UnsupportedDataTypeException", ",", "UnsupportedOperationException", "{", "JavaRDD", "<", "Cells", ">", "cellsRDD", "=", "createJavaRDD", "(", "config", ")", ";", "JavaRDD", "<", "Row", ">", "rowsRDD", "=", "DeepSparkContext", ".", "createJavaRowRDD", "(", "cellsRDD", ")", ";", "try", "{", "Cells", "firstCells", "=", "cellsRDD", ".", "first", "(", ")", ";", "StructType", "schema", "=", "CellsUtils", ".", "getStructTypeFromCells", "(", "firstCells", ")", ";", "return", "sqlContext", ".", "applySchema", "(", "rowsRDD", ",", "schema", ")", ";", "}", "catch", "(", "UnsupportedOperationException", "e", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Cannot infer schema from empty data RDD\"", ",", "e", ")", ";", "}", "}" ]
Creates a JavaSchemaRDD from a DeepJobConfig and a JavaSQLContext. @param config Specific Deep ExtractorConfig. @return A JavaSchemaRDD built from Cells. @throws UnsupportedDataTypeException
[ "Creates", "a", "JavaSchemaRDD", "from", "a", "DeepJobConfig", "and", "a", "JavaSQLContext", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L201-L211
3,886
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.textFile
public RDD textFile(ExtractorConfig<Cells> config) throws IllegalArgumentException { if(ExtractorConstants.HDFS.equals(config.getExtractorImplClassName())) { return createHDFSRDD(config); } else if(ExtractorConstants.S3.equals(config.getExtractorImplClassName())) { return createS3RDD(config); } throw new IllegalArgumentException("Valid configurations are HDFS paths, S3 paths or local file paths."); }
java
public RDD textFile(ExtractorConfig<Cells> config) throws IllegalArgumentException { if(ExtractorConstants.HDFS.equals(config.getExtractorImplClassName())) { return createHDFSRDD(config); } else if(ExtractorConstants.S3.equals(config.getExtractorImplClassName())) { return createS3RDD(config); } throw new IllegalArgumentException("Valid configurations are HDFS paths, S3 paths or local file paths."); }
[ "public", "RDD", "textFile", "(", "ExtractorConfig", "<", "Cells", ">", "config", ")", "throws", "IllegalArgumentException", "{", "if", "(", "ExtractorConstants", ".", "HDFS", ".", "equals", "(", "config", ".", "getExtractorImplClassName", "(", ")", ")", ")", "{", "return", "createHDFSRDD", "(", "config", ")", ";", "}", "else", "if", "(", "ExtractorConstants", ".", "S3", ".", "equals", "(", "config", ".", "getExtractorImplClassName", "(", ")", ")", ")", "{", "return", "createS3RDD", "(", "config", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"Valid configurations are HDFS paths, S3 paths or local file paths.\"", ")", ";", "}" ]
Returns a Cells RDD from a HDFS or S3 ExtractorConfig. @param config ExtractorConfig for HDFS or S3. @return RDD of Cells. @throws IllegalArgumentException
[ "Returns", "a", "Cells", "RDD", "from", "a", "HDFS", "or", "S3", "ExtractorConfig", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L263-L270
3,887
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.createHDFSRDD
public RDD<Cells> createHDFSRDD(ExtractorConfig<Cells> config) { Serializable host = config.getValues().get(ExtractorConstants.HOST); Serializable port = config.getValues().get(ExtractorConstants.PORT); Serializable path = config.getValues().get(ExtractorConstants.FS_FILE_PATH); final TextFileDataTable textFileDataTable = UtilFS.createTextFileMetaDataFromConfig(config, this); String filePath = path.toString(); if (config.getExtractorImplClassName().equals(ExtractorConstants.HDFS)) { filePath = ExtractorConstants.HDFS_PREFIX + host.toString() + ":" + port + path.toString(); } return createRDDFromFilePath(filePath, textFileDataTable); }
java
public RDD<Cells> createHDFSRDD(ExtractorConfig<Cells> config) { Serializable host = config.getValues().get(ExtractorConstants.HOST); Serializable port = config.getValues().get(ExtractorConstants.PORT); Serializable path = config.getValues().get(ExtractorConstants.FS_FILE_PATH); final TextFileDataTable textFileDataTable = UtilFS.createTextFileMetaDataFromConfig(config, this); String filePath = path.toString(); if (config.getExtractorImplClassName().equals(ExtractorConstants.HDFS)) { filePath = ExtractorConstants.HDFS_PREFIX + host.toString() + ":" + port + path.toString(); } return createRDDFromFilePath(filePath, textFileDataTable); }
[ "public", "RDD", "<", "Cells", ">", "createHDFSRDD", "(", "ExtractorConfig", "<", "Cells", ">", "config", ")", "{", "Serializable", "host", "=", "config", ".", "getValues", "(", ")", ".", "get", "(", "ExtractorConstants", ".", "HOST", ")", ";", "Serializable", "port", "=", "config", ".", "getValues", "(", ")", ".", "get", "(", "ExtractorConstants", ".", "PORT", ")", ";", "Serializable", "path", "=", "config", ".", "getValues", "(", ")", ".", "get", "(", "ExtractorConstants", ".", "FS_FILE_PATH", ")", ";", "final", "TextFileDataTable", "textFileDataTable", "=", "UtilFS", ".", "createTextFileMetaDataFromConfig", "(", "config", ",", "this", ")", ";", "String", "filePath", "=", "path", ".", "toString", "(", ")", ";", "if", "(", "config", ".", "getExtractorImplClassName", "(", ")", ".", "equals", "(", "ExtractorConstants", ".", "HDFS", ")", ")", "{", "filePath", "=", "ExtractorConstants", ".", "HDFS_PREFIX", "+", "host", ".", "toString", "(", ")", "+", "\":\"", "+", "port", "+", "path", ".", "toString", "(", ")", ";", "}", "return", "createRDDFromFilePath", "(", "filePath", ",", "textFileDataTable", ")", ";", "}" ]
Returns a Cells RDD from HDFS. @param config HDFS ExtractorConfig. @return Cells RDD.
[ "Returns", "a", "Cells", "RDD", "from", "HDFS", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L277-L291
3,888
Stratio/deep-spark
deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java
DeepSparkContext.createS3RDD
public RDD<Cells> createS3RDD(ExtractorConfig<Cells> config) { Serializable bucket = config.getValues().get(ExtractorConstants.S3_BUCKET); Serializable path = config.getValues().get(ExtractorConstants.FS_FILE_PATH); final TextFileDataTable textFileDataTable = UtilFS.createTextFileMetaDataFromConfig(config, this); String filePath = path.toString(); if (config.getExtractorImplClassName().equals(ExtractorConstants.S3)) { filePath = ExtractorConstants.S3_PREFIX + bucket.toString() + path.toString(); } Configuration hadoopConf = this.sc().hadoopConfiguration(); hadoopConf.set("fs.s3n.impl", "org.apache.hadoop.fs.s3native.NativeS3FileSystem"); hadoopConf.set("fs.s3n.awsAccessKeyId", config.getString(ExtractorConstants.S3_ACCESS_KEY_ID)); hadoopConf.set("fs.s3n.awsSecretAccessKey", config.getString(ExtractorConstants.S3_SECRET_ACCESS_KEY)); return createRDDFromFilePath(filePath, textFileDataTable); }
java
public RDD<Cells> createS3RDD(ExtractorConfig<Cells> config) { Serializable bucket = config.getValues().get(ExtractorConstants.S3_BUCKET); Serializable path = config.getValues().get(ExtractorConstants.FS_FILE_PATH); final TextFileDataTable textFileDataTable = UtilFS.createTextFileMetaDataFromConfig(config, this); String filePath = path.toString(); if (config.getExtractorImplClassName().equals(ExtractorConstants.S3)) { filePath = ExtractorConstants.S3_PREFIX + bucket.toString() + path.toString(); } Configuration hadoopConf = this.sc().hadoopConfiguration(); hadoopConf.set("fs.s3n.impl", "org.apache.hadoop.fs.s3native.NativeS3FileSystem"); hadoopConf.set("fs.s3n.awsAccessKeyId", config.getString(ExtractorConstants.S3_ACCESS_KEY_ID)); hadoopConf.set("fs.s3n.awsSecretAccessKey", config.getString(ExtractorConstants.S3_SECRET_ACCESS_KEY)); return createRDDFromFilePath(filePath, textFileDataTable); }
[ "public", "RDD", "<", "Cells", ">", "createS3RDD", "(", "ExtractorConfig", "<", "Cells", ">", "config", ")", "{", "Serializable", "bucket", "=", "config", ".", "getValues", "(", ")", ".", "get", "(", "ExtractorConstants", ".", "S3_BUCKET", ")", ";", "Serializable", "path", "=", "config", ".", "getValues", "(", ")", ".", "get", "(", "ExtractorConstants", ".", "FS_FILE_PATH", ")", ";", "final", "TextFileDataTable", "textFileDataTable", "=", "UtilFS", ".", "createTextFileMetaDataFromConfig", "(", "config", ",", "this", ")", ";", "String", "filePath", "=", "path", ".", "toString", "(", ")", ";", "if", "(", "config", ".", "getExtractorImplClassName", "(", ")", ".", "equals", "(", "ExtractorConstants", ".", "S3", ")", ")", "{", "filePath", "=", "ExtractorConstants", ".", "S3_PREFIX", "+", "bucket", ".", "toString", "(", ")", "+", "path", ".", "toString", "(", ")", ";", "}", "Configuration", "hadoopConf", "=", "this", ".", "sc", "(", ")", ".", "hadoopConfiguration", "(", ")", ";", "hadoopConf", ".", "set", "(", "\"fs.s3n.impl\"", ",", "\"org.apache.hadoop.fs.s3native.NativeS3FileSystem\"", ")", ";", "hadoopConf", ".", "set", "(", "\"fs.s3n.awsAccessKeyId\"", ",", "config", ".", "getString", "(", "ExtractorConstants", ".", "S3_ACCESS_KEY_ID", ")", ")", ";", "hadoopConf", ".", "set", "(", "\"fs.s3n.awsSecretAccessKey\"", ",", "config", ".", "getString", "(", "ExtractorConstants", ".", "S3_SECRET_ACCESS_KEY", ")", ")", ";", "return", "createRDDFromFilePath", "(", "filePath", ",", "textFileDataTable", ")", ";", "}" ]
Returns a Cells RDD from S3 fileSystem. @param config Amazon S3 ExtractorConfig. @return RDD of Cells.
[ "Returns", "a", "Cells", "RDD", "from", "S3", "fileSystem", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-core/src/main/java/com/stratio/deep/core/context/DeepSparkContext.java#L298-L314
3,889
Stratio/deep-spark
deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeConfigFactory.java
AerospikeConfigFactory.createAerospike
public static <T extends IDeepType> AerospikeDeepJobConfig<T> createAerospike(Class<T> entityClass) { return new AerospikeDeepJobConfig<>(entityClass); }
java
public static <T extends IDeepType> AerospikeDeepJobConfig<T> createAerospike(Class<T> entityClass) { return new AerospikeDeepJobConfig<>(entityClass); }
[ "public", "static", "<", "T", "extends", "IDeepType", ">", "AerospikeDeepJobConfig", "<", "T", ">", "createAerospike", "(", "Class", "<", "T", ">", "entityClass", ")", "{", "return", "new", "AerospikeDeepJobConfig", "<>", "(", "entityClass", ")", ";", "}" ]
Creates a new entity-based Aerospike job configuration object. @param entityClass the class instance of the entity class that will be used to map db objects to Java objects. @param <T> the generic type of the entity object implementing IDeepType. @return a new entity-based Aerospike job configuration object.
[ "Creates", "a", "new", "entity", "-", "based", "Aerospike", "job", "configuration", "object", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-aerospike/src/main/java/com/stratio/deep/aerospike/config/AerospikeConfigFactory.java#L46-L48
3,890
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/utils/AnnotationUtils.java
AnnotationUtils.deepFieldName
public static String deepFieldName(Field field) { DeepField annotation = field.getAnnotation(DeepField.class); if (StringUtils.isNotEmpty(annotation.fieldName())) { return annotation.fieldName(); } else { return field.getName(); } }
java
public static String deepFieldName(Field field) { DeepField annotation = field.getAnnotation(DeepField.class); if (StringUtils.isNotEmpty(annotation.fieldName())) { return annotation.fieldName(); } else { return field.getName(); } }
[ "public", "static", "String", "deepFieldName", "(", "Field", "field", ")", "{", "DeepField", "annotation", "=", "field", ".", "getAnnotation", "(", "DeepField", ".", "class", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "annotation", ".", "fieldName", "(", ")", ")", ")", "{", "return", "annotation", ".", "fieldName", "(", ")", ";", "}", "else", "{", "return", "field", ".", "getName", "(", ")", ";", "}", "}" ]
Returns the field name as known by the datastore. If the provided field object DeepField annotation specifies the fieldName property, the value of this property will be returned, otherwise the java field name will be returned. @param field the Field object associated to the property for which we want to resolve the name. @return the field name.
[ "Returns", "the", "field", "name", "as", "known", "by", "the", "datastore", ".", "If", "the", "provided", "field", "object", "DeepField", "annotation", "specifies", "the", "fieldName", "property", "the", "value", "of", "this", "property", "will", "be", "returned", "otherwise", "the", "java", "field", "name", "will", "be", "returned", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/AnnotationUtils.java#L47-L55
3,891
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/RangeUtils.java
RangeUtils.mergeTokenRanges
static List<DeepTokenRange> mergeTokenRanges(Map<String, Iterable<Comparable>> tokens, final Session session, final IPartitioner p) { final Iterable<Comparable> allRanges = Ordering.natural().sortedCopy(concat(tokens.values())); final Comparable maxValue = Ordering.natural().max(allRanges); final Comparable minValue = (Comparable) p.minValue(maxValue.getClass()).getToken().token; Function<Comparable, Set<DeepTokenRange>> map = new MergeTokenRangesFunction(maxValue, minValue, session, p, allRanges); Iterable<DeepTokenRange> concatenated = concat(transform(allRanges, map)); Set<DeepTokenRange> dedup = Sets.newHashSet(concatenated); return Ordering.natural().sortedCopy(dedup); }
java
static List<DeepTokenRange> mergeTokenRanges(Map<String, Iterable<Comparable>> tokens, final Session session, final IPartitioner p) { final Iterable<Comparable> allRanges = Ordering.natural().sortedCopy(concat(tokens.values())); final Comparable maxValue = Ordering.natural().max(allRanges); final Comparable minValue = (Comparable) p.minValue(maxValue.getClass()).getToken().token; Function<Comparable, Set<DeepTokenRange>> map = new MergeTokenRangesFunction(maxValue, minValue, session, p, allRanges); Iterable<DeepTokenRange> concatenated = concat(transform(allRanges, map)); Set<DeepTokenRange> dedup = Sets.newHashSet(concatenated); return Ordering.natural().sortedCopy(dedup); }
[ "static", "List", "<", "DeepTokenRange", ">", "mergeTokenRanges", "(", "Map", "<", "String", ",", "Iterable", "<", "Comparable", ">", ">", "tokens", ",", "final", "Session", "session", ",", "final", "IPartitioner", "p", ")", "{", "final", "Iterable", "<", "Comparable", ">", "allRanges", "=", "Ordering", ".", "natural", "(", ")", ".", "sortedCopy", "(", "concat", "(", "tokens", ".", "values", "(", ")", ")", ")", ";", "final", "Comparable", "maxValue", "=", "Ordering", ".", "natural", "(", ")", ".", "max", "(", "allRanges", ")", ";", "final", "Comparable", "minValue", "=", "(", "Comparable", ")", "p", ".", "minValue", "(", "maxValue", ".", "getClass", "(", ")", ")", ".", "getToken", "(", ")", ".", "token", ";", "Function", "<", "Comparable", ",", "Set", "<", "DeepTokenRange", ">", ">", "map", "=", "new", "MergeTokenRangesFunction", "(", "maxValue", ",", "minValue", ",", "session", ",", "p", ",", "allRanges", ")", ";", "Iterable", "<", "DeepTokenRange", ">", "concatenated", "=", "concat", "(", "transform", "(", "allRanges", ",", "map", ")", ")", ";", "Set", "<", "DeepTokenRange", ">", "dedup", "=", "Sets", ".", "newHashSet", "(", "concatenated", ")", ";", "return", "Ordering", ".", "natural", "(", ")", ".", "sortedCopy", "(", "dedup", ")", ";", "}" ]
Merges the list of tokens for each cluster machine to a single list of token ranges. @param tokens the map of tokens for each cluster machine. @param session the connection to the cluster. @param p the partitioner used in the cluster. @return the merged lists of tokens transformed to DeepTokenRange(s). The returned collection is shuffled.
[ "Merges", "the", "list", "of", "tokens", "for", "each", "cluster", "machine", "to", "a", "single", "list", "of", "token", "ranges", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/RangeUtils.java#L106-L122
3,892
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/RangeUtils.java
RangeUtils.bisectTokeRange
private static void bisectTokeRange( DeepTokenRange range, final IPartitioner partitioner, final int bisectFactor, final List<DeepTokenRange> accumulator) { final AbstractType tkValidator = partitioner.getTokenValidator(); Token leftToken = partitioner.getTokenFactory().fromByteArray(tkValidator.decompose(range.getStartToken())); Token rightToken = partitioner.getTokenFactory().fromByteArray(tkValidator.decompose(range.getEndToken())); Token midToken = partitioner.midpoint(leftToken, rightToken); Comparable midpoint = (Comparable) tkValidator.compose(tkValidator.fromString(midToken.toString())); DeepTokenRange left = new DeepTokenRange(range.getStartToken(), midpoint, range.getReplicas()); DeepTokenRange right = new DeepTokenRange(midpoint, range.getEndToken(), range.getReplicas()); if (bisectFactor / 2 <= 1) { accumulator.add(left); accumulator.add(right); } else { bisectTokeRange(left, partitioner, bisectFactor / 2, accumulator); bisectTokeRange(right, partitioner, bisectFactor / 2, accumulator); } }
java
private static void bisectTokeRange( DeepTokenRange range, final IPartitioner partitioner, final int bisectFactor, final List<DeepTokenRange> accumulator) { final AbstractType tkValidator = partitioner.getTokenValidator(); Token leftToken = partitioner.getTokenFactory().fromByteArray(tkValidator.decompose(range.getStartToken())); Token rightToken = partitioner.getTokenFactory().fromByteArray(tkValidator.decompose(range.getEndToken())); Token midToken = partitioner.midpoint(leftToken, rightToken); Comparable midpoint = (Comparable) tkValidator.compose(tkValidator.fromString(midToken.toString())); DeepTokenRange left = new DeepTokenRange(range.getStartToken(), midpoint, range.getReplicas()); DeepTokenRange right = new DeepTokenRange(midpoint, range.getEndToken(), range.getReplicas()); if (bisectFactor / 2 <= 1) { accumulator.add(left); accumulator.add(right); } else { bisectTokeRange(left, partitioner, bisectFactor / 2, accumulator); bisectTokeRange(right, partitioner, bisectFactor / 2, accumulator); } }
[ "private", "static", "void", "bisectTokeRange", "(", "DeepTokenRange", "range", ",", "final", "IPartitioner", "partitioner", ",", "final", "int", "bisectFactor", ",", "final", "List", "<", "DeepTokenRange", ">", "accumulator", ")", "{", "final", "AbstractType", "tkValidator", "=", "partitioner", ".", "getTokenValidator", "(", ")", ";", "Token", "leftToken", "=", "partitioner", ".", "getTokenFactory", "(", ")", ".", "fromByteArray", "(", "tkValidator", ".", "decompose", "(", "range", ".", "getStartToken", "(", ")", ")", ")", ";", "Token", "rightToken", "=", "partitioner", ".", "getTokenFactory", "(", ")", ".", "fromByteArray", "(", "tkValidator", ".", "decompose", "(", "range", ".", "getEndToken", "(", ")", ")", ")", ";", "Token", "midToken", "=", "partitioner", ".", "midpoint", "(", "leftToken", ",", "rightToken", ")", ";", "Comparable", "midpoint", "=", "(", "Comparable", ")", "tkValidator", ".", "compose", "(", "tkValidator", ".", "fromString", "(", "midToken", ".", "toString", "(", ")", ")", ")", ";", "DeepTokenRange", "left", "=", "new", "DeepTokenRange", "(", "range", ".", "getStartToken", "(", ")", ",", "midpoint", ",", "range", ".", "getReplicas", "(", ")", ")", ";", "DeepTokenRange", "right", "=", "new", "DeepTokenRange", "(", "midpoint", ",", "range", ".", "getEndToken", "(", ")", ",", "range", ".", "getReplicas", "(", ")", ")", ";", "if", "(", "bisectFactor", "/", "2", "<=", "1", ")", "{", "accumulator", ".", "add", "(", "left", ")", ";", "accumulator", ".", "add", "(", "right", ")", ";", "}", "else", "{", "bisectTokeRange", "(", "left", ",", "partitioner", ",", "bisectFactor", "/", "2", ",", "accumulator", ")", ";", "bisectTokeRange", "(", "right", ",", "partitioner", ",", "bisectFactor", "/", "2", ",", "accumulator", ")", ";", "}", "}" ]
Recursive function that splits a given token range to a given number of token ranges. @param range the token range to be splitted. @param partitioner the cassandra partitioner. @param bisectFactor the actual number of pieces the original token range will be splitted to. @param accumulator a token range accumulator (ne
[ "Recursive", "function", "that", "splits", "a", "given", "token", "range", "to", "a", "given", "number", "of", "token", "ranges", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/RangeUtils.java#L209-L231
3,893
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/RangeUtils.java
RangeUtils.getPartitioner
public static IPartitioner getPartitioner(ICassandraDeepJobConfig config) { try { return (IPartitioner) Class.forName(config.getPartitionerClassName()).newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new DeepGenericException(e); } }
java
public static IPartitioner getPartitioner(ICassandraDeepJobConfig config) { try { return (IPartitioner) Class.forName(config.getPartitionerClassName()).newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new DeepGenericException(e); } }
[ "public", "static", "IPartitioner", "getPartitioner", "(", "ICassandraDeepJobConfig", "config", ")", "{", "try", "{", "return", "(", "IPartitioner", ")", "Class", ".", "forName", "(", "config", ".", "getPartitionerClassName", "(", ")", ")", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "ClassNotFoundException", "|", "InstantiationException", "|", "IllegalAccessException", "e", ")", "{", "throw", "new", "DeepGenericException", "(", "e", ")", ";", "}", "}" ]
Creates a new instance of the cassandra partitioner configured in the configuration object. @param config the Deep configuration object. @return an instance of the cassandra partitioner configured in the configuration object.
[ "Creates", "a", "new", "instance", "of", "the", "cassandra", "partitioner", "configured", "in", "the", "configuration", "object", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/RangeUtils.java#L239-L245
3,894
Stratio/deep-spark
deep-jdbc/src/main/java/com/stratio/deep/jdbc/reader/JdbcReader.java
JdbcReader.init
public void init(Partition p) throws Exception { Class.forName(jdbcDeepJobConfig.getDriverClass()); conn = DriverManager.getConnection(jdbcDeepJobConfig.getConnectionUrl(), jdbcDeepJobConfig.getUsername(), jdbcDeepJobConfig.getPassword()); Statement statement = conn.createStatement(); SelectQuery query = jdbcDeepJobConfig.getQuery(); JdbcPartition jdbcPartition = (JdbcPartition)p; if(jdbcDeepJobConfig.getNumPartitions() > 1) { Column partitionKey = jdbcDeepJobConfig.getPartitionKey(); query.getWhereClause().addCondition(BinaryCondition.lessThan(partitionKey, jdbcPartition.upper(), true)) .addCondition(BinaryCondition.greaterThan(partitionKey, jdbcPartition.lower(), true)); } resultSet = statement.executeQuery(query.toString()); // Fetches first element this.hasNext = resultSet.next(); }
java
public void init(Partition p) throws Exception { Class.forName(jdbcDeepJobConfig.getDriverClass()); conn = DriverManager.getConnection(jdbcDeepJobConfig.getConnectionUrl(), jdbcDeepJobConfig.getUsername(), jdbcDeepJobConfig.getPassword()); Statement statement = conn.createStatement(); SelectQuery query = jdbcDeepJobConfig.getQuery(); JdbcPartition jdbcPartition = (JdbcPartition)p; if(jdbcDeepJobConfig.getNumPartitions() > 1) { Column partitionKey = jdbcDeepJobConfig.getPartitionKey(); query.getWhereClause().addCondition(BinaryCondition.lessThan(partitionKey, jdbcPartition.upper(), true)) .addCondition(BinaryCondition.greaterThan(partitionKey, jdbcPartition.lower(), true)); } resultSet = statement.executeQuery(query.toString()); // Fetches first element this.hasNext = resultSet.next(); }
[ "public", "void", "init", "(", "Partition", "p", ")", "throws", "Exception", "{", "Class", ".", "forName", "(", "jdbcDeepJobConfig", ".", "getDriverClass", "(", ")", ")", ";", "conn", "=", "DriverManager", ".", "getConnection", "(", "jdbcDeepJobConfig", ".", "getConnectionUrl", "(", ")", ",", "jdbcDeepJobConfig", ".", "getUsername", "(", ")", ",", "jdbcDeepJobConfig", ".", "getPassword", "(", ")", ")", ";", "Statement", "statement", "=", "conn", ".", "createStatement", "(", ")", ";", "SelectQuery", "query", "=", "jdbcDeepJobConfig", ".", "getQuery", "(", ")", ";", "JdbcPartition", "jdbcPartition", "=", "(", "JdbcPartition", ")", "p", ";", "if", "(", "jdbcDeepJobConfig", ".", "getNumPartitions", "(", ")", ">", "1", ")", "{", "Column", "partitionKey", "=", "jdbcDeepJobConfig", ".", "getPartitionKey", "(", ")", ";", "query", ".", "getWhereClause", "(", ")", ".", "addCondition", "(", "BinaryCondition", ".", "lessThan", "(", "partitionKey", ",", "jdbcPartition", ".", "upper", "(", ")", ",", "true", ")", ")", ".", "addCondition", "(", "BinaryCondition", ".", "greaterThan", "(", "partitionKey", ",", "jdbcPartition", ".", "lower", "(", ")", ",", "true", ")", ")", ";", "}", "resultSet", "=", "statement", ".", "executeQuery", "(", "query", ".", "toString", "(", ")", ")", ";", "// Fetches first element", "this", ".", "hasNext", "=", "resultSet", ".", "next", "(", ")", ";", "}" ]
Initialized the reader @param p Spark partition. @throws Exception
[ "Initialized", "the", "reader" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/reader/JdbcReader.java#L84-L100
3,895
Stratio/deep-spark
deep-jdbc/src/main/java/com/stratio/deep/jdbc/reader/JdbcReader.java
JdbcReader.close
public void close() throws Exception { try { if (resultSet != null) { resultSet.close(); } } finally { if (conn != null) { conn.close(); } } }
java
public void close() throws Exception { try { if (resultSet != null) { resultSet.close(); } } finally { if (conn != null) { conn.close(); } } }
[ "public", "void", "close", "(", ")", "throws", "Exception", "{", "try", "{", "if", "(", "resultSet", "!=", "null", ")", "{", "resultSet", ".", "close", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "conn", "!=", "null", ")", "{", "conn", ".", "close", "(", ")", ";", "}", "}", "}" ]
closes the resultset and the jdbc connection. @throws java.lang.Exception
[ "closes", "the", "resultset", "and", "the", "jdbc", "connection", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-jdbc/src/main/java/com/stratio/deep/jdbc/reader/JdbcReader.java#L137-L147
3,896
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepRecordReader.java
DeepRecordReader.createConnection
private Session createConnection() { /* reorder locations */ List<String> locations = Lists.newArrayList(split.getReplicas()); Collections.sort(locations, new DeepPartitionLocationComparator()); Exception lastException = null; LOG.debug("createConnection: " + locations); for (String location : locations) { try { return trySessionForLocation(location, config, false).left; } catch (Exception e) { LOG.error("Could not get connection for: {}, replicas: {}", location, locations); lastException = e; } } throw new DeepIOException(lastException); }
java
private Session createConnection() { /* reorder locations */ List<String> locations = Lists.newArrayList(split.getReplicas()); Collections.sort(locations, new DeepPartitionLocationComparator()); Exception lastException = null; LOG.debug("createConnection: " + locations); for (String location : locations) { try { return trySessionForLocation(location, config, false).left; } catch (Exception e) { LOG.error("Could not get connection for: {}, replicas: {}", location, locations); lastException = e; } } throw new DeepIOException(lastException); }
[ "private", "Session", "createConnection", "(", ")", "{", "/* reorder locations */", "List", "<", "String", ">", "locations", "=", "Lists", ".", "newArrayList", "(", "split", ".", "getReplicas", "(", ")", ")", ";", "Collections", ".", "sort", "(", "locations", ",", "new", "DeepPartitionLocationComparator", "(", ")", ")", ";", "Exception", "lastException", "=", "null", ";", "LOG", ".", "debug", "(", "\"createConnection: \"", "+", "locations", ")", ";", "for", "(", "String", "location", ":", "locations", ")", "{", "try", "{", "return", "trySessionForLocation", "(", "location", ",", "config", ",", "false", ")", ".", "left", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Could not get connection for: {}, replicas: {}\"", ",", "location", ",", "locations", ")", ";", "lastException", "=", "e", ";", "}", "}", "throw", "new", "DeepIOException", "(", "lastException", ")", ";", "}" ]
Creates a new connection. Reuses a cached connection if possible. @return the new session
[ "Creates", "a", "new", "connection", ".", "Reuses", "a", "cached", "connection", "if", "possible", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepRecordReader.java#L189-L209
3,897
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepRecordReader.java
DeepRecordReader.reachEndRange
private boolean reachEndRange() { // current row key ByteBuffer rowKey; if (keyValidator instanceof CompositeType) { ByteBuffer[] keys = new ByteBuffer[partitionBoundColumns.size()]; for (int i = 0; i < partitionBoundColumns.size(); i++) { keys[i] = partitionBoundColumns.get(i).value.duplicate(); } rowKey = CompositeType.build(keys); } else { rowKey = partitionBoundColumns.get(0).value; } String endToken = String.valueOf(split.getEndToken()); String currentToken = partitioner.getToken(rowKey).toString(); return endToken.equals(currentToken); }
java
private boolean reachEndRange() { // current row key ByteBuffer rowKey; if (keyValidator instanceof CompositeType) { ByteBuffer[] keys = new ByteBuffer[partitionBoundColumns.size()]; for (int i = 0; i < partitionBoundColumns.size(); i++) { keys[i] = partitionBoundColumns.get(i).value.duplicate(); } rowKey = CompositeType.build(keys); } else { rowKey = partitionBoundColumns.get(0).value; } String endToken = String.valueOf(split.getEndToken()); String currentToken = partitioner.getToken(rowKey).toString(); return endToken.equals(currentToken); }
[ "private", "boolean", "reachEndRange", "(", ")", "{", "// current row key", "ByteBuffer", "rowKey", ";", "if", "(", "keyValidator", "instanceof", "CompositeType", ")", "{", "ByteBuffer", "[", "]", "keys", "=", "new", "ByteBuffer", "[", "partitionBoundColumns", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "partitionBoundColumns", ".", "size", "(", ")", ";", "i", "++", ")", "{", "keys", "[", "i", "]", "=", "partitionBoundColumns", ".", "get", "(", "i", ")", ".", "value", ".", "duplicate", "(", ")", ";", "}", "rowKey", "=", "CompositeType", ".", "build", "(", "keys", ")", ";", "}", "else", "{", "rowKey", "=", "partitionBoundColumns", ".", "get", "(", "0", ")", ".", "value", ";", "}", "String", "endToken", "=", "String", ".", "valueOf", "(", "split", ".", "getEndToken", "(", ")", ")", ";", "String", "currentToken", "=", "partitioner", ".", "getToken", "(", "rowKey", ")", ".", "toString", "(", ")", ";", "return", "endToken", ".", "equals", "(", "currentToken", ")", ";", "}" ]
check whether current row is at the end of range @return the boolean
[ "check", "whether", "current", "row", "is", "at", "the", "end", "of", "range" ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepRecordReader.java#L662-L681
3,898
Stratio/deep-spark
deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepRecordReader.java
DeepRecordReader.next
@Override public Pair<Map<String, ByteBuffer>, Map<String, ByteBuffer>> next() { if (!this.hasNext()) { throw new DeepIllegalAccessException("DeepRecordReader exhausted"); } return rowIterator.next(); }
java
@Override public Pair<Map<String, ByteBuffer>, Map<String, ByteBuffer>> next() { if (!this.hasNext()) { throw new DeepIllegalAccessException("DeepRecordReader exhausted"); } return rowIterator.next(); }
[ "@", "Override", "public", "Pair", "<", "Map", "<", "String", ",", "ByteBuffer", ">", ",", "Map", "<", "String", ",", "ByteBuffer", ">", ">", "next", "(", ")", "{", "if", "(", "!", "this", ".", "hasNext", "(", ")", ")", "{", "throw", "new", "DeepIllegalAccessException", "(", "\"DeepRecordReader exhausted\"", ")", ";", "}", "return", "rowIterator", ".", "next", "(", ")", ";", "}" ]
Returns the next element in the underlying rowIterator. @return the next element in the underlying rowIterator.
[ "Returns", "the", "next", "element", "in", "the", "underlying", "rowIterator", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/cql/DeepRecordReader.java#L726-L732
3,899
Stratio/deep-spark
deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java
ExtractorConfig.getInteger
public Integer getInteger(String key) { try { return getValue(Integer.class, key); } catch (ClassCastException e) { String value = getString(key); return Integer.parseInt(value.split(",")[0]); } }
java
public Integer getInteger(String key) { try { return getValue(Integer.class, key); } catch (ClassCastException e) { String value = getString(key); return Integer.parseInt(value.split(",")[0]); } }
[ "public", "Integer", "getInteger", "(", "String", "key", ")", "{", "try", "{", "return", "getValue", "(", "Integer", ".", "class", ",", "key", ")", ";", "}", "catch", "(", "ClassCastException", "e", ")", "{", "String", "value", "=", "getString", "(", "key", ")", ";", "return", "Integer", ".", "parseInt", "(", "value", ".", "split", "(", "\",\"", ")", "[", "0", "]", ")", ";", "}", "}" ]
Gets integer. @param key the key @return the integer
[ "Gets", "integer", "." ]
b9621c9b7a6d996f80fce1d073d696a157bed095
https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/config/ExtractorConfig.java#L118-L126