public class BigFileSearcher extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
BigFileSearcher.OnProgressListener |
static interface |
BigFileSearcher.OnRealtimeResultListener |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BLOCK_SIZE |
static int |
DEFAULT_MAX_NUM_OF_THREADS |
static int |
THREADS_NO_LIMIT |
Constructor and Description |
---|
BigFileSearcher() |
Modifier and Type | Method and Description |
---|---|
void |
_showProfile()
Profiling method
|
long |
getEllapsedMillis()
Get operation time in millis of last search
|
Long |
indexOf(File f,
byte[] searchBytes)
Returns the index within this file of the first occurrence of the
specified substring.
|
Long |
indexOf(File f,
byte[] searchBytes,
long fromPosition)
Returns the index within this file of the first occurrence of the
specified substring, starting at the specified position.
|
List<Long> |
searchBigFile(File f,
byte[] searchBytes)
Search bytes from big file faster in a concurrent processing with
progress callback
|
List<Long> |
searchBigFile(File f,
byte[] searchBytes,
BigFileSearcher.OnProgressListener listener)
Search bytes from big file faster in a concurrent processing with
progress callback
|
List<Long> |
searchBigFileRealtime(File f,
byte[] searchBytes,
BigFileSearcher.OnRealtimeResultListener listener)
Search bytes from big file faster with realtime result callback
This callbacks the result in real time, but since the concurrency is inferior to #searchBigFile,so the execution speed is slower than #searchBigFile |
List<Long> |
searchBigFileRealtime(File f,
byte[] searchBytes,
long startPosition,
BigFileSearcher.OnRealtimeResultListener listener)
* Search bytes from big file faster with realtime result callback
This callbacks the result in real time, but since the concurrency is inferior to #searchBigFile,so the execution speed is slower than #searchBigFile |
void |
setBlockSize(long blockSize)
Set size per unit when divide loading big sized file into multiple pieces
In order to make this method effective,call setUseOptimization(false) to turn off the optimization. |
void |
setBufferSizePerWorker(int bufferSize)
Set size to be read into memory at one search
In order to make this method effective,call setUseOptimization(false) to turn off the optimization. |
void |
setMaxNumOfThreads(int maxNumOfThreads)
Set max number of thread to concurrent load to file
Increased the number of threads does not means improving a performance In order to make this method effective,call setUseOptimization(false) to turn off the optimization. |
void |
setSubBufferSize(int subBufferSize)
Set the size of the window used to scan memory used in each worker
In order to make this method effective,call setUseOptimization(false) to turn off the optimization. |
void |
setSubThreadSize(int subThreadSize)
Set number of threads used in each worker
In order to make this method effective,call setUseOptimization(false) to turn off the optimization. |
void |
setUseOptimization(boolean enabled)
Use memory and threading optimization
(default is true) |
public static final int DEFAULT_MAX_NUM_OF_THREADS
public static final int THREADS_NO_LIMIT
public static final int DEFAULT_BLOCK_SIZE
public void setUseOptimization(boolean enabled)
enabled
- optimization enabled or notpublic void setBlockSize(long blockSize)
blockSize
- size per unit when divide loading big sized filepublic void setBufferSizePerWorker(int bufferSize)
bufferSize
- size(byte) to be read into memory at one search operationpublic void setMaxNumOfThreads(int maxNumOfThreads)
maxNumOfThreads
- number of threads(concurrency)public void setSubThreadSize(int subThreadSize)
subThreadSize
- number of threads for sub threads(concurrency)public void setSubBufferSize(int subBufferSize)
subBufferSize
- size(bytes) of the windowpublic Long indexOf(File f, byte[] searchBytes)
f
- target filesearchBytes
- sequence of bytes you want to searchpublic Long indexOf(File f, byte[] searchBytes, long fromPosition)
f
- target filesearchBytes
- a sequence of bytes you want to findfromPosition
- "0" means the beginning of the filepublic List<Long> searchBigFileRealtime(File f, byte[] searchBytes, BigFileSearcher.OnRealtimeResultListener listener)
f
- targetFilesearchBytes
- sequence of bytes you want to searchlistener
- callback for progress and realtime resultpublic List<Long> searchBigFileRealtime(File f, byte[] searchBytes, long startPosition, BigFileSearcher.OnRealtimeResultListener listener)
f
- targetFilesearchBytes
- sequence of bytes you want to searchstartPosition
- starting positionlistener
- callback for progress and realtime resultpublic List<Long> searchBigFile(File f, byte[] searchBytes)
f
- target filesearchBytes
- sequence of bytes you want to searchpublic List<Long> searchBigFile(File f, byte[] searchBytes, BigFileSearcher.OnProgressListener listener)
f
- target filesearchBytes
- sequence of bytes you want to searchlistener
- callback for progresspublic long getEllapsedMillis()
public void _showProfile()
Copyright © 2016. All rights reserved.