예제 #1
0
 @Nullable
 private Function rewriteAndValidateFields(Function function, Context context) {
   if (function.arguments().size() == 2) {
     Symbol left = function.arguments().get(0);
     Symbol right = function.arguments().get(1);
     if (left.symbolType() == SymbolType.REFERENCE && right.symbolType().isValueSymbol()) {
       Reference ref = (Reference) left;
       if (ref.info().ident().columnIdent().equals(DocSysColumns.ID)) {
         function.setArgument(
             0,
             new Reference(DocSysColumns.forTable(ref.ident().tableIdent(), DocSysColumns.UID)));
         function.setArgument(
             1,
             Literal.newLiteral(
                 Uid.createUid(
                     Constants.DEFAULT_MAPPING_TYPE, ValueSymbolVisitor.STRING.process(right))));
       } else {
         String unsupportedMessage =
             context.unsupportedMessage(ref.info().ident().columnIdent().name());
         if (unsupportedMessage != null) {
           throw new UnsupportedFeatureException(unsupportedMessage);
         }
       }
     }
   }
   return function;
 }
예제 #2
0
 public Context convert(
     WhereClause whereClause,
     MapperService mapperService,
     IndexFieldDataService indexFieldDataService,
     IndexCache indexCache)
     throws UnsupportedFeatureException {
   Context ctx = new Context(inputSymbolVisitor, mapperService, indexFieldDataService, indexCache);
   if (whereClause.noMatch()) {
     ctx.query = Queries.newMatchNoDocsQuery();
   } else if (!whereClause.hasQuery()) {
     ctx.query = Queries.newMatchAllQuery();
   } else {
     ctx.query = VISITOR.process(whereClause.query(), ctx);
   }
   if (LOGGER.isTraceEnabled()) {
     if (whereClause.hasQuery()) {
       LOGGER.trace(
           "WHERE CLAUSE [{}] -> LUCENE QUERY [{}] ",
           SymbolFormatter.format(whereClause.query()),
           ctx.query);
     }
   }
   return ctx;
 }