use of io.crate.exceptions.UnhandledServerException in project crate by crate.
the class LuceneReferenceResolver method typeSpecializedExpression.
private static LuceneCollectorExpression<?> typeSpecializedExpression(final FieldTypeLookup fieldTypeLookup, final Reference ref) {
final String fqn = ref.column().fqn();
final MappedFieldType fieldType = fieldTypeLookup.get(fqn);
if (fieldType == null) {
return NO_FIELD_TYPES_IDS.contains(unnest(ref.valueType()).id()) || isIgnoredDynamicReference(ref) ? DocCollectorExpression.create(toSourceLookup(ref)) : new LiteralValueExpression(null);
}
if (!fieldType.hasDocValues()) {
return DocCollectorExpression.create(toSourceLookup(ref));
}
switch(ref.valueType().id()) {
case BitStringType.ID:
return new BitStringColumnReference(fqn, ((BitStringType) ref.valueType()).length());
case ByteType.ID:
return new ByteColumnReference(fqn);
case ShortType.ID:
return new ShortColumnReference(fqn);
case IpType.ID:
return new IpColumnReference(fqn);
case StringType.ID:
return new BytesRefColumnReference(fqn);
case DoubleType.ID:
return new DoubleColumnReference(fqn);
case BooleanType.ID:
return new BooleanColumnReference(fqn);
case FloatType.ID:
return new FloatColumnReference(fqn);
case LongType.ID:
case TimestampType.ID_WITH_TZ:
case TimestampType.ID_WITHOUT_TZ:
return new LongColumnReference(fqn);
case IntegerType.ID:
return new IntegerColumnReference(fqn);
case GeoPointType.ID:
return new GeoPointColumnReference(fqn);
case ArrayType.ID:
return DocCollectorExpression.create(toSourceLookup(ref));
default:
throw new UnhandledServerException("Unsupported type: " + ref.valueType().getName());
}
}
use of io.crate.exceptions.UnhandledServerException in project crate by crate.
the class DocTableInfoBuilder method buildDocIndexMetadata.
private DocIndexMetadata buildDocIndexMetadata(String indexName) {
DocIndexMetadata docIndexMetadata;
IndexMetadata indexMetadata = metadata.index(indexName);
try {
docIndexMetadata = new DocIndexMetadata(nodeCtx, indexMetadata, ident);
} catch (IOException e) {
throw new UnhandledServerException("Unable to build DocIndexMetadata", e);
}
try {
return docIndexMetadata.build();
} catch (Exception e) {
try {
LOGGER.error("Could not build DocIndexMetadata from: {}", indexMetadata.mapping().getSourceAsMap());
} catch (Exception ignored) {
}
throw e;
}
}
use of io.crate.exceptions.UnhandledServerException in project crate by crate.
the class CountTaskTest method testClose.
@Test
public void testClose() throws Exception {
CompletableFuture<Long> future = new CompletableFuture<>();
CountOperation countOperation = mock(CountOperation.class);
when(countOperation.count(eq(txnCtx), any(), any(Symbol.class))).thenReturn(future);
CountTask countTask = new CountTask(countPhaseWithId(1), txnCtx, countOperation, new TestingRowConsumer(), null);
countTask.start();
future.complete(1L);
assertTrue(countTask.isClosed());
// assure that there was no exception
countTask.completionFuture().get();
// on error
future = new CompletableFuture<>();
when(countOperation.count(eq(txnCtx), any(), any(Symbol.class))).thenReturn(future);
countTask = new CountTask(countPhaseWithId(2), txnCtx, countOperation, new TestingRowConsumer(), null);
countTask.start();
future.completeExceptionally(new UnhandledServerException("dummy"));
assertTrue(countTask.isClosed());
expectedException.expectCause(CauseMatcher.cause(UnhandledServerException.class));
countTask.completionFuture().get();
}
Aggregations