This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val df = spark.read.text(inputFile) | |
df.createOrReplaceTempView("data") | |
val query = | |
""" | |
| WITH loglevel AS (SELECT SPLIT(value, ' ')[0] AS level FROM data WHERE LENGTH(value) > 0), | |
| levelcount AS (SELECT level, COUNT(*) as count FROM loglevel GROUP BY level) | |
| SELECT level, count FROM levelcount ORDER BY count DESC | |
""".stripMargin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shell判断文件,目录是否存在或者具有权限 | |
#!/bin/sh | |
Path="/var/log/httpd/" | |
File="/var/log/httpd/access.log" | |
#这里的-x 参数判断$Path是否存在并且是否具有可执行权限 | |
if [ ! -x "$Path"]; then | |
mkdir "$Path" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# delete local tag '12345' | |
git tag -d 12345 | |
# delete remote tag '12345' (eg, GitHub version too) | |
git push origin :refs/tags/12345 | |
# alternative approach | |
git push --delete origin tagName | |
git tag -d tagName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.komamitsu; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.nio.ByteBuffer; | |
import java.nio.channels.SelectionKey; | |
import java.nio.channels.Selector; | |
import java.nio.channels.ServerSocketChannel; | |
import java.nio.channels.SocketChannel; | |
import java.util.Iterator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
public class CopyFile { | |
public static void main(String[] args) { | |
String infname = "/tmp/in.txt"; | |
String outfname = "/tmp/out.txt"; | |
FileInputStream fis = new FileInputStream(infname); | |
FileOutputStream fos = new FileOutputStream(outfname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ByteBuffer to String | |
String s = Charset.forName("UTF-8").decode(byteBuffer).toString(); | |
// String to ByteBuffer | |
ByteBuffer buff = Charset.forName("UTF-9").encode("Hello, World!"); | |
// String to ByteBuffer | |
public static ByteBuffer str_to_bb(String msg, Charset charset){ | |
return ByteBuffer.wrap(msg.getBytes(charset)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ClassLoader CLASS_LOADER = ReflectHelpers.findClassLoader(); | |
TreeSet pipelineRunnerRegistrars = Sets.newTreeSet(ObjectsClassComparator.INSTANCE); | |
Lists.newArrayList(ServiceLoader.load(PipelineRunnerRegistrar.class, CLASS_LOADER)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReflectHelpers { | |
public static ClassLoader findClassLoader() { | |
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
if(classLoader == null) { | |
classLoader = ReflectHelpers.class.getClassLoader(); | |
} | |
if(classLoader == null) { | |
classLoader = ClassLoader.getSystemClassLoader(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 循环 | |
for i in {1..100}; do echo $i; done | |
for i in $(seq 1 100); do echo $i; done | |
for ((i = 0; i < 100; i++)); do echo $i; done | |
# sed 读取文件 a,b行的内容 | |
sed -n '5,10p' test.txt | |
# 删除空行 | |
sed '/^$/d' file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ExecutorService es = Executors.newCachedThreadPool(); | |
ExecutorCompletionService<Boolean> ecs = new ExecutorCompletionService<>(es); | |
Set<Future> futureSet = new HashSet<Future>(); | |
List<Callable> callerList = new ArrayList<Callable>(); | |
// 构造任务列表 | |
for (int i = 0; i < 100; i++) { | |
callerList.add(...); | |
} |
NewerOlder