Fast Read Of Blobs Within Sqlite Using Simplequeryforblobfiledescriptor?
I am reading blobs with size between 100kb and 1000kb from SQlite in my Android App using the following code : public Object getCachefromDb(String sIdentifier){ String sSQL =
Solution 1:
My Tests results says its slower.
After long testing I found out, that using simpleQueryForBlobFileDescriptor is slower. See following code. My old code for example reads a blob in 390 miliseconds and the new code with simpleQueryForBlobFileDescriptor reads the same blob in 805 ms. I read somewhere that simpleQueryForBlobFileDescriptor should be very fast for blob readings, but this seems not to be in my tests. Perhabs I am not doing it properly ? ( I hope so ). Any other hints.
publicObject getCachefromDb_old(String sIdentifier){
Log.v("DEBUG LOAD BLOB","Start : " + sIdentifier);
Object o = null;
try {
// Erstelle ein SQLStatemant mit einer InClauseString sSQL = " Select cache from cachetable where identifier='" + sIdentifier + "'";
SQLiteStatement get = connection_chronica.compileStatement(sSQL);
ParcelFileDescriptor result = get.simpleQueryForBlobFileDescriptor();
FileInputStream fis = new FileInputStream(result.getFileDescriptor());
ObjectInputStream inStream = new ObjectInputStream(fis);
o=inStream.readObject();
} catch (StreamCorruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.v("DEBUG LOAD BLOB","End : " + sIdentifier);
return o;
}
Post a Comment for "Fast Read Of Blobs Within Sqlite Using Simplequeryforblobfiledescriptor?"