随着数据的越来越大,数据库也越来越大,同时伴随着磁盘空间的增长以及性能的下降。使用SQLServer 2008的数据压缩功能可以大大的减小数据量提高查询性能,尤其对于数据仓库非常有用。(BestPractices for Data Warehousing with SQL Server 2008:http://msdn.microsoft.com/en-us/library/cc719165.aspx)
但是启用数据压缩是一个很耗费CPU资源的动作,这个过程我们可以充分发挥多CPU的优势?如何实现呢?
比如针对客户表启用PAGE压缩,我们会使用下面的脚本:
ALTER TABLE customerREBUILDWITH (DATA_COMPRESSION=PAGE);
由于数据库使用了8颗CPU在维护期间没有其他应用,这样我们可以充分使用8颗CPU并行执行压缩:
ALTER TABLE customerREBUILDWITH (DATA_COMPRESSION=PAGE,MAXDOP=8);
下面一张图可以看到使用MAXDOP以后的效果。
在将PowerManagerService.java文件DEBUG_SCREEN_ON打开后,在log发现RuntimeException,仔细查看代码,原来是在setLightBrightness中的debug信息,
特地写下来,以便以后使用.
1.setLightBrightness 函数:
private void setLightBrightness(int mask, int value) {
int brightnessMode = (mAutoBrightessEnabled
? LightsService.BRIGHTNESS_MODE_SENSOR
: LightsService.BRIGHTNESS_MODE_USER);
if ((mask & SCREEN_BRIGHT_BIT) != 0) {
if (DEBUG_SCREEN_ON) {
RuntimeException e = new RuntimeException("here");
e.fillInStackTrace();
Slog.i(TAG, "Set LCD brightness: " + value, e);
}
mLcdLight.setBrightness(value, brightnessMode);
}
if ((mask & BUTTON_BRIGHT_BIT) != 0) {
mButtonLight.setBrightness(value);
}
if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
mKeyboardLight.setBrightness(value);
}
}
2.log信息:
I/PowerManagerService( 228): java.lang.RuntimeException: here
I/PowerManagerService( 228): at com.android.server.PowerManagerService.setLightBrightness(PowerManagerService.java:2160)
I/PowerManagerService( 228): at com.android.server.PowerManagerService.access$4600(PowerManagerService.java:77)
I/PowerManagerService( 228): at com.android.server.PowerManagerService$BrightnessState.jumpToTargetLocked(PowerManagerService.java:2265)
I/PowerManagerService( 228): at com.android.server.PowerManagerService.setBacklightBrightness(PowerManagerService.java:3049)
I/PowerManagerService( 228): at android.os.IPowerManager$Stub.onTransact(IPowerManager.java:227)
I/PowerManagerService( 228): at android.os.Binder.execTransact(Binder.java:338)
I/PowerManagerService( 228): at dalvik.system.NativeStart.run(Native Method)
先要对pdf文件进行解析,然后显示出来
解析pdf文件需要pdfbox的jar包,下载地址为:http://pdfbox.apache.org/download.html
下面是解析pdf的代码:
package com.lingjoin.extractors;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.util.Date;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import org.apache.pdfbox.util.PDFTextStripper;
import com.lingjoin.paser.LingJoinFile;
/**
* PDF解析器
*
* @author Ansj
*
*/
public class PDFExtractor extends AbstractExtractor {
private String getContent(LingJoinFile f) {
// TODO Auto-generated method stub
PDDocument doc = null ;
try {
doc = PDDocument.load(f);
PDFTextStripper stripper = new PDFTextStripper();
/**
* 设置文件的信息
*/
this.setLingJoinFileInfo(f, doc
.getDocumentInformation());
return stripper.getText(doc);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (doc != null) {
try {
doc.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return "";
}
private BufferedReader getContentReader(LingJoinFile f) {
return new BufferedReader(new StringReader(this.getContent(f)));
}
/**
*
* 项目名称:FilePaser
* 类描述: 设置文件的信息
* 创建人:ANSJ
* 创建时间:2010-4-14 下午04:27:57
* 修改备注:
* @version
*/
private void setLingJoinFileInfo(LingJoinFile f, PDDocumentInformation info) {
if (info.getAuthor() != null) {
f.setlAuthor(info.getAuthor());
}
}
public void paserFileToReader(LingJoinFile f) throws Exception {
f.setlContentReader(this.getContentReader(f)) ;
}
public void paserFileToString(LingJoinFile f) throws Exception {
// TODO Auto-generated method stub
f.setlContent(this.getContent(f)) ;
}
public PDFExtractor(Integer typeFlag) {
// TODO Auto-generated constructor stub
this.typeFlag = typeFlag ;
}
private Integer typeFlag = null ;
public Integer getTypeFlag() {
// TODO Auto-generated method stub
return typeFlag;
}
}