我已经成功安装了tomcat但是如果我想使用一些PHP代码.那么我应该把这个php代码放在我的tomcat目录中以及如何使用tomcat配置php.任何建议或链接将不胜感激..
如何在Hive中有效地存储数据,以及在hive中存储和检索压缩数据?目前我将其存储为TextFile.我正在阅读Bejoy文章,我发现LZO压缩对于存储文件很有用,而且它是可拆分的.
我有一个生成一些输出的HiveQL Select查询,我将该输出存储在某处,以便我的一个Hive表(质量)可以使用该数据,以便我可以查询该quality表.
下面是quality我通过使用我用来覆盖表的分区从下面的SELECT查询加载数据的表quality.
create table quality
(id bigint,
total bigint,
error bigint
)
partitioned by (ds string)
row format delimited fields terminated by '\t'
stored as textfile
location '/user/uname/quality'
;
insert overwrite table quality partition (ds='20120709')
SELECT id , count2 , coalesce(error, cast(0 AS BIGINT)) AS count1 FROM Table1;
Run Code Online (Sandbox Code Playgroud)
所以这里目前我将它存储为a TextFile,我应该将其作为a Sequence file并开始存储数据LZO compression format吗?或者文本文件在这里也可以吗?从选择查询开始,我将获得一些GB数据,这些数据需要每天上传到桌面质量上.
那么哪种方式最好?我应该将输出存储为TextFile或SequenceFile格式(LZO压缩),这样当我查询Hive质量表时,我会得到结果严重.意味着查询速度更快.
更新: -
如果我使用块压缩存储为SequenceFile怎么办?如下 -
set mapred.output.compress=true;
set mapred.output.compression.type=BLOCK;
set mapred.output.compression.codec=org.apache.hadoop.io.compress.LzoCodec;
Run Code Online (Sandbox Code Playgroud)
我需要设置一些其他的东西来启用除上面的BLOCK压缩?而且我也将Table创建为SequenceFile格式 …
下面是我在bash中执行的脚本.它工作正常.
fileexist=0
for i in $( ls /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done); do
mv /data/read-only/clv/daily/Finished-HADOOP_EXPORT_&processDate#.done /data/read-only/clv/daily/archieve-wip/
fileexist=1
done
Run Code Online (Sandbox Code Playgroud)
问题陈述:-
在我上面的shell脚本中,必须每天运行cron job,我没有error/exception handling mechanism.假设如果出现任何问题,我不知道发生了什么?
在执行上述脚本之后,就有some other scripts that will be dependent on the data provided by above script,所以我总是得到其他人的抱怨,这些人根据我的脚本数据发现了错误.
get notified if anything wrong has happened我的脚本中有什么办法吗?假设cluster is having some maintenance当时我正在运行我的脚本,那么肯定会失败肯定,所以如果我的上述脚本失败,我可以得到通知,这样我就可以确定发生了错误.
希望我的问题很清楚.
任何想法将不胜感激.
创建后台线程的最佳方法是什么,每15分钟运行一次以从数据库中获取数据?
下面是我所拥有的代码,我认为它在生产中会正常工作,但是我还有其他更好的方法或我应该注意的事情吗?
private static void checkDatabaseEveryXMinutes() {
new Thread() {
public void run() {
while (true) {
try {
Thread.sleep(checkingAfterEveryXMinutes);
getDataFromDatabase();
} catch (InterruptedException ex) {
//log here
} catch (Exception e) {
//log here
}
}
}
}.start();
}
Run Code Online (Sandbox Code Playgroud)
使用上面的代码有什么不利之处.ScheduledExecutorService与TimerTask的比较如何?
哪种方式更好?
如果有更好的方法,我会对此代码的任何示例基础表示赞赏.
我想在我在这里创建的文件夹中创建一个文本文件.
File dir = new File("crawl_html");
dir.mkdir();
String hash = MD5Util.md5Hex(url1.toString());
System.out.println("hash:-" + hash);
File file = new File(""+dir+"\""+hash+".txt");
Run Code Online (Sandbox Code Playgroud)
但是这段代码不会将文本文件创建到该文件夹中.相反,它会使文本文件位于该文件夹之外.
生成任意特定长度的随机字符串。我知道这个问题已经被问过很多次了,我在下面编写了这段代码,我只是想知道是否有比我编写的下面的代码更好的方法?或者我们可以让下面的代码更高效吗?
public static void main(String[] args) {
String s = randomString(25);
System.out.println(s);
}
public static String randomString(final int length) {
StringBuilder sb = new StringBuilder();
Random r = new Random();
String subset = "0123456789abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < length; i++) {
int index = r.nextInt(subset.length());
char c = subset.charAt( index );
sb.append( c );
}
return sb.toString();
}
Run Code Online (Sandbox Code Playgroud) 下面是我的代码,我使用反射来调用方法,但我总是得到异常
List<PdAttrKey> attrKeys = new ArrayList<PdAttrKey>();
Properties adapterProps = new Properties();
PdReadRequest pdReadRequest = new PdReadRequest(1L, 1L, (short) 0, new Date(),
dataDurationSec, 2L, 3L, attrKeys, null, adapterProps);
PdAdapterUserReadOnlyGemsReader adapter1 = new PdAdapterUserReadOnlyGemsReader();
PdReader reader = adapter1.acquireReader(pdReadRequest);
UserCacheDoImpl userDos = Some Value;
Method method = getClassMethod("createPdRecordFromUserDO");
// This line is throwing me exception. And I don't know why?
PdRecord onePdsxRecord = (PdRecord) method.invoke(reader, userDos);
Run Code Online (Sandbox Code Playgroud)
这是下面的方法,我从中获取类的所有方法名称.
private Method getClassMethod(String methodName) {
Method method = null;
Method[] methodList = PdAdapterUserReadOnlyGemsReader.PdUserReadOnlyGemsReader.class
.getDeclaredMethods();
for (Method …Run Code Online (Sandbox Code Playgroud) jExcel API如果一张纸已满,我需要在Java中创建多个Excel工作表(65536 rows).假设如果一张纸已满,则在下一张纸中,它应该从第一张纸中停止的位置开始自动写入.当一张纸已满时,我只是坚持使用逻辑来动态创建它.下面是我到目前为止所做的代码.
public void write() throws IOException, WriteException {
File file = new File(inputFile);
WorkbookSettings wbSettings = new WorkbookSettings();
wbSettings.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook = Workbook.createWorkbook(file, wbSettings);
writingToExcel(workbook);
}
//Logic to create sheet dyanmically if one is full should be done here I guess?
private void writingToExcel(WritableWorkbook workbook) {
workbook.createSheet("Report", 0);
WritableSheet excelSheet = workbook.getSheet(0);
try {
createLabel(excelSheet);
createContent(excelSheet);
} catch (WriteException e) {
e.printStackTrace();
} finally {
try {
workbook.write();
workbook.close();
} catch (IOException e) …Run Code Online (Sandbox Code Playgroud) 我TOKEN_AWARE在com.netflix.astyanax.connectionpool.NodeDiscoveryType中为Cassandra 找到了Astyanax客户端的枚举值,并且我试图了解它的作用?
package com.netflix.astyanax.connectionpool;
public enum NodeDiscoveryType {
/**
* Discover nodes exclusively from doing a ring describe
*/
RING_DESCRIBE,
/**
* Discover nodes exclusively from an external node discovery service
*/
DISCOVERY_SERVICE,
/**
* Intersect ring describe and nodes from an external service. This solve
* the multi-region ring describe problem where ring describe returns nodes
* from other regions.
*/
TOKEN_AWARE,
/**
* Use only nodes in the list of seeds
*/
NONE
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Java读取一个非常大的文件.那个大文件会有这样的数据,这意味着每一行都有一个用户ID.
149905320
1165665384
66969324
886633368
1145241312
286585320
1008665352
Run Code Online (Sandbox Code Playgroud)
在那个大文件中,将有大约3000万用户ID.现在我试图从那个大文件中一个一个地读取所有用户ID.意味着每个用户ID只能从该大文件中选择一次.例如,如果我有30万个用户ID,那么它应该使用多线程代码只打印一次3000万用户ID.
下面是我的代码,它是一个运行10个线程的多线程代码但是使用下面的程序,我无法确保每个用户ID只被选中一次.
public class ReadingFile {
public static void main(String[] args) {
// create thread pool with given size
ExecutorService service = Executors.newFixedThreadPool(10);
for (int i = 0; i < 10; i++) {
service.submit(new FileTask());
}
}
}
class FileTask implements Runnable {
@Override
public void run() {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("D:/abc.txt"));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
//do things with …Run Code Online (Sandbox Code Playgroud)