1. Origin Table
CREATE TABLE `TEST` (
`NO` int(11) NOT NULL AUTO_INCREMENT,
`TIME` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ID` varchar(32) NOT NULL,
`EVENTNO` int(11) NOT NULL DEFAULT '0',
`VALUENO` int(11) NOT NULL DEFAULT '0',
`VALUE` bigint(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`NO`),
KEY `ID` (`ID`),
KEY `EVENTNO` (`EVENTNO`),
KEY `VALUENO` (`VALUENO`)
) ENGINE=MyISAM AUTO_INCREMENT=0
ALTER TABLE TEST DROP PRIMARY KEY, ADD UNIQUE KEY `ID_EVENTNO_VALUENO` (`ID`,`EVENTNO`,`VALUENO`), ADD UNIQUE KEY `NO_EVENTNO` (`NO`,`EVENTNO`), DROP KEY `VALUENO`;
ALTER TABLE TEST PARTITION BY HASH(`EVENTNO`) PARTITIONS 10;
PS : We could also DROP KEY `ID` and `EVENTNO` ...
Use EVENTNO to be Hash Key into 10 partition
2. Explain
EXPLAIN PARTITIONS SELECT VALUE FROM TEST WHERE ID = 'AAAA' AND EVENTNO = 200015 AND VALUENO = 10008;
+----+-------------+-----------------+------------+-------+-------------------------------+--------------------+---------+-------------------+------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------+------------+-------+-------------------------------+--------------------+---------+-------------------+------+-------+
| 1 | SIMPLE | TEST | p5 | const | ID_EVENTNO_VALUENO,ID,EVENTNO | ID_EVENTNO_VALUENO | 74 | const,const,const | 1 | NULL |
+----+-------------+-----------------+------------+-------+-------------------------------+--------------------+---------+-------------------+------+-------+
partitions = p5 ==> we use EVENTNO to partition
key ID_EVENTNO_VALUENO
rows = 1 , only 1 row, good index
3. Partition Rule
A: HASH (N) , N must be an integer
B: All columns used in the partitioning expression for a partitioned table must be part of every unique key that the table may have.
(https://dev.mysql.com/doc/refman/5.6/en/partitioning-limitations-partitioning-keys-unique-keys.html)
也就是說 拿來當 Partition 的Key, 必須存在在所有的 Primay / Unique Key中
2015年3月25日 星期三
2015年2月13日 星期五
GenyMotion Google Play and ARM(CPU_ABI_INCOMPATIBLE) Support
1. Google Play
https://gist.github.com/wbroek/9321145
2. Install ARM
Other Ref:
http://forum.xda-developers.com/showthread.php?t=2528952
https://gist.github.com/wbroek/9321145
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
Google Apps for Android 4.2 (https://www.androidfilehost.com/?fid=23060877490000128 - gapps-jb-20130812-signed.zip)
Google Apps for Android 4.1 (https://www.androidfilehost.com/?fid=22979706399755082 - gapps-jb-20121011-signed.zip)
Google Apps for Android 2.3.7 (http://www.mediafire.com/download/bs063kb0m742o5l/gapps-gb-20131027-signed.zip - gapps-gb-20131027-signe.zip)
2. Install ARM
http://filetrip.net/dl?4SUOrdcMRv
Other Ref:
http://forum.xda-developers.com/showthread.php?t=2528952
2015年1月16日 星期五
Get Other App Status in Android
1. Before API Level 21 (Lolipop , 5.0 )
ref:
http://stackoverflow.com/questions/22500959/detect-when-other-application-opened-or-launched
http://developer.android.com/reference/android/app/ActivityManager.html
Returns a list of application processes that are running on the device.
This method was deprecated in API level 21. As of
LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak person information to the caller. For backwards compatibility, it will still retu rn a small subset of its data: at least the caller's own tasks, and possibly some other tasks such as home that are known to not be sensitive.A : Get Running Processes Lists
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();
for (int i = 0; i < runningAppProcessInfo.size(); i++) {
if(runningAppProcessInfo.get(i).processName.equals("com.the.app.you.are.looking.for") {
// Do you stuff
}
}
B: Get Top Task ( Foreground Tasks)
public static boolean isForeground(Context ctx, String myPackage){
ActivityManager manager = (ActivityManager) ctx.getSystemService(ACTIVITY_SERVICE);
List< ActivityManager.RunningTaskInfo > runningTaskInfo = manager.getRunningTasks(1);
ComponentName componentInfo = runningTaskInfo.get(0).topActivity;
if(componentInfo.getPackageName().equals(myPackage)) {
return true;
}
return false;
}
2. After API Level 21 (Lolipop)
the getRunningTasks is deprecated
other approach :
getAppTasks
http://developer.android.com/reference/android/app/ActivityManager.html#getAppTasks%28%29
http://www.intertech.com/Blog/android-5-api-changes-getapptasks/
2015年1月14日 星期三
WebView Size Problem in Andorid 4.4
1. the webpage will over screen size
ref :
https://developer.android.com/guide/webapps/migrating.html
add :
Other:
set webview background color
myWebView.setBackgroundResource(Color.TRANSPARENT);
myWebView.setBackgroundColor(Color.TRANSPARENT);
ref :
https://developer.android.com/guide/webapps/migrating.html
add :
WebSettings settings = webView.getSettings(); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true);
Other:
set webview background color
myWebView.setBackgroundResource(Color.TRANSPARENT);
myWebView.setBackgroundColor(Color.TRANSPARENT);
2015年1月7日 星期三
Disable TitleBar(ActionBar) in Android App
1. Activity shouldn't exntend ActionBarActivity
public class MainActivity extends ActionBarActivity {
public class MainActivity extends Activity {
2. in AndroidManifest.xml
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
public class MainActivity extends Activity {
2. in AndroidManifest.xml
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
Android WebView App Crash on Android 4.4 in GenyMotion
In LogCat
Some errors like
eglCodecCommon﹕ **** ERROR unknown type (many)
GL ERROR :GL_INVALID_ENUM : glProduceTextureCHROMIUM: target was GL_TEXTURE_EXTERNAL_OES
temporary disable hardware accelerate
in AndroidManifest.xml
.
.
android:hardwareAccelerated="false"
.
.>
reference :
http://stackoverflow.com/questions/26836858/android-genymotion-vm-logcat-runs-into-infinite-loop
http://blog.csdn.net/lfdfhl/article/details/9139259
Some errors like
eglCodecCommon﹕ **** ERROR unknown type (many)
GL ERROR :GL_INVALID_ENUM : glProduceTextureCHROMIUM: target was GL_TEXTURE_EXTERNAL_OES
temporary disable hardware accelerate
in AndroidManifest.xml
.
android:hardwareAccelerated="false"
.
.>
reference :
http://stackoverflow.com/questions/26836858/android-genymotion-vm-logcat-runs-into-infinite-loop
http://blog.csdn.net/lfdfhl/article/details/9139259
2014年10月17日 星期五
CentOS SELinux http bind port (http listen port other than (80, 81, 443, 488, 8008, 8009, 8443, 9000)
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Confined_Services/chap-Managing_Confined_Services-The_Apache_HTTP_Server.html
1. List current allowed port
semanage port -l | grep -w http_port_t
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
2. Add another port
semanage port -a -t http_port_t -p tcp 12345
1. List current allowed port
semanage port -l | grep -w http_port_t
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
2. Add another port
semanage port -a -t http_port_t -p tcp 12345
訂閱:
文章 (Atom)