Package org.riversun.bigdoc.bin
Class BigFileSearcher
java.lang.Object
org.riversun.bigdoc.bin.BigFileSearcher
Search bytes from big file
Available for giga-bytes order file
Available for giga-bytes order file
- Author:
- Tom Misawa (riversun.org@gmail.com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intList<org.riversun.bigdoc.bin.BigFileSearcher.BigFileSearchTask>static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidProfiling methodvoidcancel()Cancel searchinglongGet operation time in millis of last searchReturns the index within this file of the first occurrence of the specified substring.Returns the index within this file of the first occurrence of the specified substring, starting at the specified position.searchBigFile(File f, byte[] searchBytes) Search bytes from big file faster in a concurrent processing with progress callbacksearchBigFile(File f, byte[] searchBytes, BigFileSearcher.OnProgressListener listener) Search bytes from big file faster in a concurrent processing with progress callbacksearchBigFileRealtime(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 #searchBigFilesearchBigFileRealtime(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 #searchBigFilevoidsetBlockSize(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.voidsetBufferSizePerWorker(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.voidsetMaxNumOfThreads(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.voidsetSubBufferSize(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.voidsetSubThreadSize(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.voidsetUseOptimization(boolean enabled) Use memory and threading optimization
(default is true)
-
Field Details
-
DEFAULT_MAX_NUM_OF_THREADS
public static final int DEFAULT_MAX_NUM_OF_THREADS- See Also:
-
THREADS_NO_LIMIT
public static final int THREADS_NO_LIMIT- See Also:
-
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE- See Also:
-
mTaskList
-
-
Constructor Details
-
BigFileSearcher
public BigFileSearcher()
-
-
Method Details
-
setUseOptimization
public void setUseOptimization(boolean enabled) Use memory and threading optimization
(default is true)- Parameters:
enabled- optimization enabled or not
-
setBlockSize
public 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.- Parameters:
blockSize- size per unit when divide loading big sized file
-
setBufferSizePerWorker
public 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.- Parameters:
bufferSize- size(byte) to be read into memory at one search operation
-
setMaxNumOfThreads
public 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.- Parameters:
maxNumOfThreads- number of threads(concurrency)
-
setSubThreadSize
public 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.- Parameters:
subThreadSize- number of threads for sub threads(concurrency)
-
setSubBufferSize
public 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.- Parameters:
subBufferSize- size(bytes) of the window
-
indexOf
Returns the index within this file of the first occurrence of the specified substring.- Parameters:
f- target filesearchBytes- sequence of bytes you want to search- Returns:
-
indexOf
Returns the index within this file of the first occurrence of the specified substring, starting at the specified position.- Parameters:
f- target filesearchBytes- a sequence of bytes you want to findfromPosition- "0" means the beginning of the file- Returns:
- position of the first occurence. '-1' means that it was not found.
-
searchBigFileRealtime
public 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- Parameters:
f- targetFilesearchBytes- sequence of bytes you want to searchlistener- callback for progress and realtime result
-
searchBigFileRealtime
public 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- Parameters:
f- targetFilesearchBytes- sequence of bytes you want to searchstartPosition- starting positionlistener- callback for progress and realtime result- Returns:
-
searchBigFile
Search bytes from big file faster in a concurrent processing with progress callback- Parameters:
f- target filesearchBytes- sequence of bytes you want to search- Returns:
-
searchBigFile
public List<Long> searchBigFile(File f, byte[] searchBytes, BigFileSearcher.OnProgressListener listener) Search bytes from big file faster in a concurrent processing with progress callback- Parameters:
f- target filesearchBytes- sequence of bytes you want to searchlistener- callback for progress- Returns:
-
cancel
public void cancel()Cancel searching -
searchBigFile
-
getEllapsedMillis
public long getEllapsedMillis()Get operation time in millis of last search- Returns:
-
_showProfile
public void _showProfile()Profiling method
-