org.apache.blur.utils
Class BlurUtil
java.lang.Object
org.apache.blur.utils.BlurUtil
public class BlurUtil
- extends Object
Method Summary |
static
|
configure(T t)
|
static
|
convert(Iterator<T> iterator)
|
static BlurResults |
convertToHits(BlurResultIterable hitsIterable,
BlurQuery query,
AtomicLongArray facetCounts,
ExecutorService executor,
Selector selector,
Blur.Iface iface,
String table)
|
static SortFieldResult |
convertToSortField(Object o)
|
static List<SortFieldResult> |
convertToSortFields(Object[] fields)
|
static int |
countDocuments(IndexReader reader,
Term term)
|
static void |
createIfMissing(org.apache.zookeeper.ZooKeeper zookeeper,
String path)
|
static boolean |
createPath(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path path)
|
static void |
createPath(org.apache.zookeeper.ZooKeeper zookeeper,
String path,
byte[] data)
|
static List<org.apache.lucene.document.Document> |
fetchDocuments(IndexReader reader,
ResetableDocumentStoredFieldVisitor fieldSelector,
Selector selector,
int maxHeap,
String context,
Term primeDocTerm,
org.apache.lucene.search.Filter filter,
AtomicBoolean moreToFetch,
AtomicInteger totalRecords,
BlurHighlighter highlighter)
NOTE: This is a potentially dangerous call, it will return all the
documents that match the term. |
static Serializable |
fromBytes(byte[] bs)
|
static Serializable |
fromBytes(byte[] bs,
int offset,
int length)
|
static String |
getArgsStr(Object[] args,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
|
static String |
getArgsStr(Object[] args,
String methodName,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
|
static String |
getArgsStr(Object o,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
|
static String |
getArgsStr(TBase o,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
|
static AtomicLongArray |
getAtomicLongArraySameLengthAsList(List<?> list)
|
static AtomicReader |
getAtomicReader(IndexReader reader)
|
static String |
getErrorResponseLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
double ms,
User user)
|
static
|
getInstance(String className,
Class<T> c)
|
static List<Long> |
getList(AtomicLongArray atomicLongArray)
|
static String |
getPid()
|
static String |
getRequestLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
User user)
|
static String |
getResponseLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
double ms,
User user,
boolean success)
|
static SegmentReader |
getSegmentReader(IndexReader indexReader)
|
static int |
getShardIndex(String shard)
|
static String |
getShardName(int id)
|
static String |
getShardName(String prefix,
int id)
|
static String |
getSuccessfulResponseLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
double ms,
User user)
|
static String |
getVersion()
|
static String |
humanizeTime(long hours,
long minutes,
long seconds)
|
static String |
humanizeTime(long time,
TimeUnit unit)
|
static
|
lastChanceErrorHandling(T t,
Class<T> clazz)
|
static String |
lockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper,
String nodeName,
String cluster)
|
static
|
nullCheck(T t,
String message)
|
static void |
quietClose(Object... close)
|
static byte[] |
read(TBase<?,?> base)
|
static
|
recordMethodCallsAndAverageTimes(T t,
Class<T> clazz,
boolean controller)
|
static void |
removeAll(org.apache.zookeeper.ZooKeeper zooKeeper,
String path)
|
static void |
removeIndexFiles(String uri)
|
static Blur.Iface |
runTrace(Blur.Iface iface,
boolean controller)
|
static Blur.Iface |
runWithUser(Blur.Iface iface,
boolean controller)
|
static void |
setStartTime(BlurQuery query)
|
static void |
setupFileSystem(String uri,
int shardCount)
|
static void |
setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper)
|
static void |
setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper,
String cluster)
|
static byte[] |
toBytes(Serializable serializable)
|
static List<Long> |
toList(AtomicLongArray atomicLongArray)
|
static RecordMutation |
toRecordMutation(Record record)
|
static RowMutation |
toRowMutation(String table,
Row row)
|
static String |
toString(byte[] b,
int off,
int len)
|
static String |
toStringBinary(byte[] b,
int off,
int len)
|
static void |
unlockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper,
String lockPath)
|
static boolean |
validate(String s)
|
static void |
validateRowIdAndRecord(String rowId,
Record record)
|
static void |
validateShardCount(int shardCount,
org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path tablePath)
|
static void |
validateShardName(String shardName)
|
static void |
validateTableName(String tableName)
|
static void |
validateWritableDirectory(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path tablePath)
|
static Blur.Iface |
wrapFilteredBlurServer(BlurConfiguration configuration,
Blur.Iface iface,
boolean shard)
|
static void |
write(byte[] data,
TBase<?,?> base)
|
static int |
zeroCheck(int i,
String message)
|
SORT_FIELD_COMPARATOR
public static final SortFieldComparator SORT_FIELD_COMPARATOR
HITS_PEEKABLE_ITERATOR_COMPARATOR
public static final Comparator<? super PeekableIterator<BlurResult,BlurException>> HITS_PEEKABLE_ITERATOR_COMPARATOR
HITS_COMPARATOR
public static final Comparator<? super BlurResult> HITS_COMPARATOR
PRIME_DOC_TERM
public static final Term PRIME_DOC_TERM
BlurUtil
public BlurUtil()
lastChanceErrorHandling
public static <T extends Blur.Iface> T lastChanceErrorHandling(T t,
Class<T> clazz)
recordMethodCallsAndAverageTimes
public static <T extends Blur.Iface> T recordMethodCallsAndAverageTimes(T t,
Class<T> clazz,
boolean controller)
getArgsStr
public static String getArgsStr(Object[] args,
String methodName,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
getArgsStr
public static String getArgsStr(Object[] args,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
getArgsStr
public static String getArgsStr(Object o,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
getArgsStr
public static String getArgsStr(TBase o,
org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
getRequestLogMessage
public static String getRequestLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
User user)
getResponseLogMessage
public static String getResponseLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
double ms,
User user,
boolean success)
getSuccessfulResponseLogMessage
public static String getSuccessfulResponseLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
double ms,
User user)
getErrorResponseLogMessage
public static String getErrorResponseLogMessage(String requestId,
String connectionString,
String argsStr,
String name,
double ms,
User user)
setupZookeeper
public static void setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper)
throws org.apache.zookeeper.KeeperException,
InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
setupZookeeper
public static void setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper,
String cluster)
throws org.apache.zookeeper.KeeperException,
InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
createIfMissing
public static void createIfMissing(org.apache.zookeeper.ZooKeeper zookeeper,
String path)
throws org.apache.zookeeper.KeeperException,
InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
getList
public static List<Long> getList(AtomicLongArray atomicLongArray)
quietClose
public static void quietClose(Object... close)
toBytes
public static byte[] toBytes(Serializable serializable)
fromBytes
public static Serializable fromBytes(byte[] bs)
fromBytes
public static Serializable fromBytes(byte[] bs,
int offset,
int length)
toList
public static List<Long> toList(AtomicLongArray atomicLongArray)
getAtomicLongArraySameLengthAsList
public static AtomicLongArray getAtomicLongArraySameLengthAsList(List<?> list)
convertToHits
public static BlurResults convertToHits(BlurResultIterable hitsIterable,
BlurQuery query,
AtomicLongArray facetCounts,
ExecutorService executor,
Selector selector,
Blur.Iface iface,
String table)
throws InterruptedException,
ExecutionException,
BlurException
- Throws:
InterruptedException
ExecutionException
BlurException
setStartTime
public static void setStartTime(BlurQuery query)
getVersion
public static String getVersion()
unlockForSafeMode
public static void unlockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper,
String lockPath)
throws InterruptedException,
org.apache.zookeeper.KeeperException
- Throws:
InterruptedException
org.apache.zookeeper.KeeperException
lockForSafeMode
public static String lockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper,
String nodeName,
String cluster)
throws org.apache.zookeeper.KeeperException,
InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
getShardName
public static String getShardName(int id)
getShardName
public static String getShardName(String prefix,
int id)
humanizeTime
public static String humanizeTime(long time,
TimeUnit unit)
humanizeTime
public static String humanizeTime(long hours,
long minutes,
long seconds)
createPath
public static void createPath(org.apache.zookeeper.ZooKeeper zookeeper,
String path,
byte[] data)
throws org.apache.zookeeper.KeeperException,
InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
setupFileSystem
public static void setupFileSystem(String uri,
int shardCount)
throws IOException
- Throws:
IOException
validateShardCount
public static void validateShardCount(int shardCount,
org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path tablePath)
throws IOException
- Throws:
IOException
createPath
public static boolean createPath(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path path)
throws IOException
- Throws:
IOException
zeroCheck
public static int zeroCheck(int i,
String message)
nullCheck
public static <T> T nullCheck(T t,
String message)
getInstance
public static <T> T getInstance(String className,
Class<T> c)
configure
public static <T> T configure(T t)
read
public static byte[] read(TBase<?,?> base)
write
public static void write(byte[] data,
TBase<?,?> base)
removeAll
public static void removeAll(org.apache.zookeeper.ZooKeeper zooKeeper,
String path)
throws org.apache.zookeeper.KeeperException,
InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
removeIndexFiles
public static void removeIndexFiles(String uri)
throws IOException
- Throws:
IOException
toRowMutation
public static RowMutation toRowMutation(String table,
Row row)
toRecordMutation
public static RecordMutation toRecordMutation(Record record)
countDocuments
public static int countDocuments(IndexReader reader,
Term term)
throws IOException
- Throws:
IOException
fetchDocuments
public static List<org.apache.lucene.document.Document> fetchDocuments(IndexReader reader,
ResetableDocumentStoredFieldVisitor fieldSelector,
Selector selector,
int maxHeap,
String context,
Term primeDocTerm,
org.apache.lucene.search.Filter filter,
AtomicBoolean moreToFetch,
AtomicInteger totalRecords,
BlurHighlighter highlighter)
throws IOException
- NOTE: This is a potentially dangerous call, it will return all the
documents that match the term.
- Parameters:
selector
- primeDocTerm
- filter
- totalRecords
- highlighter
-
- Throws:
IOException
getSegmentReader
public static SegmentReader getSegmentReader(IndexReader indexReader)
getAtomicReader
public static AtomicReader getAtomicReader(IndexReader reader)
throws IOException
- Throws:
IOException
getShardIndex
public static int getShardIndex(String shard)
validateRowIdAndRecord
public static void validateRowIdAndRecord(String rowId,
Record record)
validate
public static boolean validate(String s)
validateTableName
public static void validateTableName(String tableName)
validateShardName
public static void validateShardName(String shardName)
getPid
public static String getPid()
convert
public static <T,E extends Exception> BlurIterator<T,E> convert(Iterator<T> iterator)
validateWritableDirectory
public static void validateWritableDirectory(org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.Path tablePath)
throws IOException
- Throws:
IOException
wrapFilteredBlurServer
public static Blur.Iface wrapFilteredBlurServer(BlurConfiguration configuration,
Blur.Iface iface,
boolean shard)
runWithUser
public static Blur.Iface runWithUser(Blur.Iface iface,
boolean controller)
runTrace
public static Blur.Iface runTrace(Blur.Iface iface,
boolean controller)
convertToSortFields
public static List<SortFieldResult> convertToSortFields(Object[] fields)
convertToSortField
public static SortFieldResult convertToSortField(Object o)
toStringBinary
public static String toStringBinary(byte[] b,
int off,
int len)
toString
public static String toString(byte[] b,
int off,
int len)
Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.