use of herddb.core.HerdDBInternalException in project herddb by diennea.
the class SQLRecordPredicateFunctions method compileLikePattern.
static Pattern compileLikePattern(String b, char escapeChar) throws HerdDBInternalException {
/*
* We presume that in string there will be 1 or 2 '%' or '_' characters. To avoid multiple array
* copies in standard cases we preallocate a builder size of string input size plus 6 chars per
* special character (4 chars for wrapping quoting sequence and 2 for pattern characters: \\E.*\\Q
* or \\E.?\\Q) plus 4 chars for whole string wrapping quote sequence (\\Qstring\\E).
*/
final StringBuilder builder = new StringBuilder(b.length() + 18);
builder.append("\\Q");
int limit = b.length();
boolean escaping = false;
for (int idx = 0; idx < limit; ++idx) {
char ch = b.charAt(idx);
if (ch == escapeChar) {
escaping = true;
} else {
if (escaping) {
builder.append(ch);
escaping = false;
} else {
switch(ch) {
case '%':
builder.append("\\E.*\\Q");
break;
case '_':
builder.append("\\E.{1}\\Q");
break;
default:
builder.append(ch);
break;
}
}
}
}
builder.append("\\E");
String like = builder.toString();
try {
return Pattern.compile(like, Pattern.DOTALL);
} catch (IllegalArgumentException err) {
throw new HerdDBInternalException("Cannot compile LIKE expression '" + b + "': " + err);
}
}
use of herddb.core.HerdDBInternalException in project herddb by diennea.
the class FileDataStorageManager method fullTableScan.
@Override
public void fullTableScan(String tableSpace, String tableName, FullTableScanConsumer consumer) throws DataStorageManagerException {
try {
TableStatus status = getLatestTableStatus(tableSpace, tableName);
fullTableScan(tableSpace, tableName, status, consumer);
} catch (HerdDBInternalException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.core.HerdDBInternalException in project herddb by diennea.
the class FileDataStorageManager method fullTableScan.
@Override
public void fullTableScan(String tableSpace, String tableUuid, LogSequenceNumber sequenceNumber, FullTableScanConsumer consumer) throws DataStorageManagerException {
try {
TableStatus status = getTableStatus(tableSpace, tableUuid, sequenceNumber);
fullTableScan(tableSpace, tableUuid, status, consumer);
} catch (HerdDBInternalException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.core.HerdDBInternalException in project herddb by diennea.
the class BookKeeperDataStorageManager method fullTableScan.
@Override
public void fullTableScan(String tableSpace, String tableName, FullTableScanConsumer consumer) throws DataStorageManagerException {
try {
TableStatus status = getLatestTableStatus(tableSpace, tableName);
fullTableScan(tableSpace, tableName, status, consumer);
} catch (HerdDBInternalException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.core.HerdDBInternalException in project herddb by diennea.
the class TmpMapImpl method forEachKey.
@Override
public void forEachKey(Sink<K> sink) throws CollectionsException, SinkException {
try (DataScanner dataScanner = tableSpaceManager.scan(scan, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION, false, false)) {
while (dataScanner.hasNext()) {
DataAccessor next = dataScanner.next();
Object key = next.get(0);
if (key instanceof RawString) {
key = key.toString();
}
try {
if (!sink.accept((K) key)) {
return;
}
} catch (Exception err) {
throw new SinkException(err);
}
}
} catch (SinkException err) {
throw err;
} catch (HerdDBInternalException | DataScannerException err) {
throw new CollectionsException(err);
}
}
Aggregations