获取ActiveRecordPlugin
@param dp DruidPlugin
@return
179936
private ActiveRecordPlugin getActiveRecordPlugin(String ds, DruidPlugin dp){
		ActiveRecordPlugin arp = new ActiveRecordPlugin(ds, dp);
		arp.setShowSql(this.getPropertyToBoolean("db.showsql"));

		// auto mapping
		if (!this.geRuned) {
			try {
				Class<?> clazz = Class.forName(this.getModelPackage()+"."+ds.toUpperCase()+this.getMappingKitClassName());
				Method mapping = clazz.getMethod("mapping", ActiveRecordPlugin.class);
				mapping.invoke(clazz, arp);
			} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException
					| IllegalArgumentException | InvocationTargetException e) {
				throw (new RuntimeException(String.valueOf(e) + ",may be your table is not contain `PrimaryKey`."));
			}
		}
		return arp;
	}
113302
@Override
	@Deprecated
	public UUID spawn(Class<? extends Agent> agentType, Object... params) {
		return getLifecycleSkill().spawnInContext(agentType, this.parentContext, params);
	}
12873
@Override
    public VoltTable runDML(String dml) {
        String modifiedDml = transformDML(dml);
        printTransformedSql(dml, modifiedDml);
        return super.runDML(modifiedDml, false);
    }
215433
public static String print(DeprData dd) {
        StringBuilder sb = new StringBuilder();
        sb.append(depr(dd.since, dd.forRemoval))
          .append(' ');

        switch (dd.kind) {
            case ANNOTATION_TYPE:
                sb.append("@interface ");
                sb.append(unslashify(dd.typeName));
                break;
            case CLASS:
                sb.append("class ");
                sb.append(unslashify(dd.typeName));
                break;
            case ENUM:
                sb.append("enum ");
                sb.append(unslashify(dd.typeName));
                break;
            case INTERFACE:
                sb.append("interface ");
                sb.append(unslashify(dd.typeName));
                break;

            case ENUM_CONSTANT:
            case FIELD:
                sb.append(unslashify(dd.typeName))
                  .append('.')
                  .append(dd.nameSig);
                break;
            case CONSTRUCTOR:
                Matcher cons = DESC_PAT.matcher(dd.nameSig);
                sb.append(unslashify(dd.typeName));
                if (cons.matches()) {
                    sb.append('(')
                      .append(parms(cons.group("args")))
                      .append(')');
                } else {
                    sb.append('.')
                      .append(dd.nameSig);
                }
                break;
            case METHOD:
                Matcher meth = DESC_PAT.matcher(dd.nameSig);
                if (meth.matches()) {
                    sb.append(desc(meth.group("return")))
                      .append(' ')
                      .append(unslashify(dd.typeName))
                      .append('.')
                      .append(meth.group("name"))
                      .append('(')
                      .append(parms(meth.group("args")))
                      .append(')');
                } else {
                    sb.append(unslashify(dd.typeName))
                      .append('.')
                      .append(dd.nameSig);
                }
                break;
        }

        return sb.toString();
    }
1167596
private boolean validRecordTypeExpression(Node expr) {
    // The expression must have at least two children. The record keyword and
    // a record expression
    if (!checkParameterCount(expr, Keywords.RECORD)) {
      return false;
    }
    // Each child must be a valid record
    for (int i = 0; i < getCallParamCount(expr); i++) {
      if (!validRecordParam(getCallArgument(expr, i))) {
        warnInvalidInside(Keywords.RECORD.name, expr);
        return false;
      }
    }
    return true;
  }
709582
protected final PrcWebstorePage<RS> lazyGetPrcWebstorePage(
    final Map<String, Object> pAddParam) throws Exception {
    String beanName = PrcWebstorePage.class.getSimpleName();
    @SuppressWarnings("unchecked")
    PrcWebstorePage<RS> proc = (PrcWebstorePage<RS>)
      this.processorsMap.get(beanName);
    if (proc == null) {
      proc = new PrcWebstorePage<RS>();
      proc.setSrvOrm(getSrvOrm());
      proc.setLogger(getLogger());
      proc.setSrvDatabase(getSrvDatabase());
      proc.setSrvShoppingCart(getSrvShoppingCart());
      proc.setSrvPage(getSrvPage());
      proc.setMngUvdSettings(getMngUvdSettings());
      //assigning fully initialized object:
      this.processorsMap.put(beanName, proc);
      this.logger.info(null, FctBnPublicTradeProcessors.class,
        beanName + " has been created.");
    }
    return proc;
  }
949512
static QueryMeta buildDeleteSql(ActiveRecord activeRecord) {
        QueryMeta     queryMeta = new QueryMeta();
        StringBuilder sqlBuf    = new StringBuilder("DELETE FROM " + activeRecord.getTableName());

        int[]        pos  = {1};
        List<Object> list = parseWhere(activeRecord, pos, sqlBuf);

        if (activeRecord.whereValues.isEmpty()) {
            throw new RuntimeException("Delete operation must take conditions.");
        } else {
            if (sqlBuf.indexOf(Const.SPACE + Const.SQL_WHERE + Const.SPACE) == -1) {
                sqlBuf.append(Const.SPACE + Const.SQL_WHERE + Const.SPACE);
            }
        }

        List<Object> temp = andWhere(activeRecord, pos, sqlBuf);
        if (null != temp) {
            list.addAll(temp);
        }

        String sql = sqlBuf.toString();

        sql = sql.replace(", WHERE", " WHERE").replace("AND  OR", "OR");
        if (sql.endsWith(Const.SQL_AND + Const.SPACE)) {
            sql = sql.substring(0, sql.length() - 5);
        }

        Object[] args = list.toArray();
        queryMeta.setSql(sql);
        queryMeta.setParams(args);
        return queryMeta;
    }
586353
def serialize(self, pid, record, links_factory=None):
        
        return self.schema.tostring(
            self.transform_record(pid, record, links_factory))
190474
def cast_with_active_record(object, type)
      cast = cast_without_active_record(object, type)
      return cast if !defined?(::ActiveRecord::Base)

      if object.is_a?(::ActiveRecord::Base)
        cast = :active_record_instance
      elsif object.is_a?(::ActiveModel::Errors)
        cast = :active_model_error
      elsif object.is_a?(Class) && object.ancestors.include?(::ActiveRecord::Base)
        cast = :active_record_class
      elsif type == :activerecord_relation || object.class.ancestors.include?(::ActiveRecord::Relation)
        cast = :array
      end
      cast
    end
698323
protected final PrBuOr<RS> lazyGetPrBuOr(
    final Map<String, Object> pAddParam) throws Exception {
    String beanName = PrBuOr.class.getSimpleName();
    @SuppressWarnings("unchecked")
    PrBuOr<RS> proc = (PrBuOr<RS>)
      this.processorsMap.get(beanName);
    if (proc == null) {
      proc = new PrBuOr<RS>();
      proc.setSrvOrm(getSrvOrm());
      proc.setSrvPage(getSrvPage());
      proc.setProcFac(this);
      proc.setMngUvd(getMngUvdSettings());
      proc.setSrvDate(getSrvDate());
      proc.setHldFldCnv(getHldFldCnv());
      proc.setFacFldCnv(getFacFldCnv());
      proc.setBuySr(getBuySr());
      //assigning fully initialized object:
      this.processorsMap.put(beanName, proc);
      this.logger.info(null, FctBnPublicTradeProcessors.class,
        beanName + " has been created.");
    }
    return proc;
  }
1199294
@Override
  public final IFillerObjectFields<?> lazyGet(//NOPMD Rule:DoubleCheckedLocking
    final Map<String, Object> pAddParam,
      final Class<?> pBeanClass) throws Exception {
    // There is no way to get from Map partially initialized bean
    // in this double-checked locking implementation
    // cause putting to the Map fully initialized bean
    IFillerObjectFields<?> filler = this.fillersMap.get(pBeanClass);
    if (filler == null) {
      // locking:
      synchronized (this.fillersMap) {
        // make sure again whether it's null after locking:
        filler = this.fillersMap.get(pBeanClass);
        if (filler == null) {
          filler = createFillerObjectFieldsStd(pBeanClass);
        }
      }
    }
    return filler;
  }
572546
static Map<String, Object> toRDataMap(Record record) {
    if ("MX".equals(record.type)) {
      return MXData.create(record.priority, record.data());
    } else if ("TXT".equals(record.type)) {
      return TXTData.create(record.data());
    } else if ("SRV".equals(record.type)) {
      List<String> rdata = split(' ', record.data());
      return SRVData.builder()
          .priority(record.priority)
          .weight(Integer.valueOf(rdata.get(0)))
          .port(Integer.valueOf(rdata.get(1)))
          .target(rdata.get(2)).build();
    } else if ("SOA".equals(record.type)) {
      List<String> threeParts = split(' ', record.data());
      return SOAData.builder()
          .mname(threeParts.get(0))
          .rname(threeParts.get(1))
          .serial(Integer.valueOf(threeParts.get(2)))
          .refresh(record.ttl)
          .retry(record.ttl)
          .expire(record.ttl).minimum(record.ttl).build();
    } else {
      return Util.toMap(record.type, record.data());
    }
  }
212125
public <DO> RecordStreamWithMetadata<DO, S> mapRecords(Function<RecordEnvelope<D>, RecordEnvelope<DO>> transform) {
    return withRecordStream(this.recordStream.map(entity -> {
      if (entity instanceof RecordEnvelope) {
        return transform.apply((RecordEnvelope<D>) entity);
      } else {
        return (StreamEntity<DO>) entity;
      }
    }));
  }
826623
public BaseTable doMakeTable(Record record)
    {
        BaseTable table = null;
        boolean bIsQueryRecord = record.isQueryRecord();
        int iRawDBType = (record.getDatabaseType() & DBConstants.TABLE_TYPE_MASK);
        if ((((iRawDBType == DBConstants.LOCAL) || (iRawDBType == DBConstants.TABLE))
                && (!bIsQueryRecord))
            || ((iRawDBType == DBConstants.LOCAL)
                    || (iRawDBType == DBConstants.REMOTE)
                    || (iRawDBType == DBConstants.REMOTE_MEMORY)
                    || (iRawDBType == DBConstants.TABLE)))
        {
            table = new ClientTable(this, record);
            String strTableClassName = record.getClass().getName();
            try   {
                Task task = null;
                RemoteTask server = null;
                if (record.getRecordOwner() != null)
                    if (record.getRecordOwner().getTask() != null)
                        task = record.getRecordOwner().getTask();
                if (task != null)
                    server = (RemoteTask)task.getRemoteTask();
                if (server == null)
                    server = (RemoteTask)((Environment)this.getDatabaseOwner().getEnvironment()).getDefaultApplication().getRemoteTask(task, null, true);
//?                String strUserID = null;
//?                if (record.getRecordOwner() != null)
//?                    strUserID = record.getRecordOwner().getProperty(DBParams.USER_ID);
                RemoteTable tableRemote = null;
                synchronized (this.getSyncObject(server))
                {   // In case this is called from another task
                    Map<String,Object> properties = table.getProperties();
                    Map<String,Object> propDatabase = BaseDatabase.addDBProperties(this.getProperties(), this, null); 
                    tableRemote = server.makeRemoteTable(strTableClassName, null, properties, propDatabase);  // NOTE: I DO Send the table properties down.
                    ((ClientTable)table).setRemoteTable(tableRemote);
                }
                // Do not get the remote db connection unless I need it
            } catch (RemoteException ex)    {
                Utility.getLogger().warning("remote doMakeTable error: " + ex.getMessage());
                ex.printStackTrace();
            }
        }
        else
            table = super.doMakeTable(record);
        return table;
    }
56216
@SafeVarargs
    static QueryMeta buildFindAllSql(ActiveRecord activeRecord, Supplier<ConditionEnum>... conditions) {

        QueryMeta queryMeta = new QueryMeta();

        String        initSql = parseFieldsSql(activeRecord.getTableName(), conditions);
        StringBuilder sqlBuf  = new StringBuilder(initSql);

        int[]        pos  = {1};
        List<Object> list = parseWhere(activeRecord, pos, sqlBuf);
        List<Object> temp = andWhere(activeRecord, pos, sqlBuf);
        if (null != temp) {
            list.addAll(temp);
        }

        String sql     = sqlFilter(sqlBuf.toString());
        String orderBy = parseOrderBySql(conditions);
        if (null != orderBy) {
            sql += orderBy;
        }
        String limit = parseLimitSql(conditions);
        if (null != limit) {
            sql += limit;
        }
        PageRow pageRow = Base.pageLocal.get();
        sql = appendPageParams(sql, pageRow);

        Object[] args = list.toArray();

        queryMeta.setSql(sql);
        queryMeta.setParams(args);
        mapping(queryMeta, activeRecord.getClass());
        return queryMeta;
    }
431852
private boolean validRecordParam(Node expr) {
    if (expr.isObjectLit()) {
      // Each value of a property must be a valid expression
      for (Node prop : expr.children()) {
        if (prop.isShorthandProperty()) {
          warnInvalid("property, missing type", prop);
          return false;
        } else if (!validTypeTransformationExpression(prop.getFirstChild())) {
          return false;
        }
      }
    } else if (!validTypeTransformationExpression(expr)) {
      return false;
    }
    return true;
  }
494515
private DruidRel<?> getLeftRelWithFilter()
  {
    final DruidRel<?> druidRight = (DruidRel) this.right;

    // Build list of acceptable values from right side.
    final Set<List<String>> valuess = new HashSet<>();
    final List<RexNode> conditions = druidRight.runQuery().accumulate(
        new ArrayList<>(),
        new Accumulator<List<RexNode>, Object[]>()
        {
          int numRows;

          @Override
          public List<RexNode> accumulate(final List<RexNode> theConditions, final Object[] row)
          {
            final List<String> values = new ArrayList<>(rightKeys.size());

            for (int i : rightKeys) {
              final Object value = row[i];
              if (value == null) {
                // NULLs are not supposed to match NULLs in a join. So ignore them.
                continue;
              }
              final String stringValue = DimensionHandlerUtils.convertObjectToString(value);
              values.add(stringValue);
            }

            if (valuess.add(values)) {
              if (++numRows > maxSemiJoinRowsInMemory) {
                throw new ResourceLimitExceededException(
                    StringUtils.format("maxSemiJoinRowsInMemory[%,d] exceeded", maxSemiJoinRowsInMemory)
                );
              }
              final List<RexNode> subConditions = new ArrayList<>();

              for (int i = 0; i < values.size(); i++) {
                final String value = values.get(i);
                // NULLs are not supposed to match NULLs in a join. So ignore them.
                if (value != null) {
                  subConditions.add(
                      getCluster().getRexBuilder().makeCall(
                          SqlStdOperatorTable.EQUALS,
                          leftExpressions.get(i),
                          getCluster().getRexBuilder().makeLiteral(value)
                      )
                  );
                }
                theConditions.add(makeAnd(subConditions));
              }
            }
            return theConditions;
          }
        }
    );

    valuess.clear();

    if (!conditions.isEmpty()) {
      // Add a filter to the left side.
      final PartialDruidQuery leftPartialQuery = left.getPartialDruidQuery();
      final Filter whereFilter = leftPartialQuery.getWhereFilter();
      final Filter newWhereFilter;

      if (whereFilter != null) {
        newWhereFilter = whereFilter.copy(
            whereFilter.getTraitSet(),
            whereFilter.getInput(),
            RexUtil.flatten(
                getCluster().getRexBuilder(),
                makeAnd(ImmutableList.of(whereFilter.getCondition(), makeOr(conditions)))
            )
        );
      } else {
        newWhereFilter = LogicalFilter.create(
            leftPartialQuery.getScan(),
            makeOr(conditions) // already in flattened form
        );
      }

      PartialDruidQuery newPartialQuery = PartialDruidQuery.create(leftPartialQuery.getScan())
                                                           .withWhereFilter(newWhereFilter)
                                                           .withSelectProject(leftPartialQuery.getSelectProject())
                                                           .withSelectSort(leftPartialQuery.getSelectSort());

      if (leftPartialQuery.getAggregate() != null) {
        newPartialQuery = newPartialQuery.withAggregate(leftPartialQuery.getAggregate());
      }

      if (leftPartialQuery.getHavingFilter() != null) {
        newPartialQuery = newPartialQuery.withHavingFilter(leftPartialQuery.getHavingFilter());
      }

      if (leftPartialQuery.getAggregateProject() != null) {
        newPartialQuery = newPartialQuery.withAggregateProject(leftPartialQuery.getAggregateProject());
      }

      if (leftPartialQuery.getSort() != null) {
        newPartialQuery = newPartialQuery.withSort(leftPartialQuery.getSort());
      }

      if (leftPartialQuery.getSortProject() != null) {
        newPartialQuery = newPartialQuery.withSortProject(leftPartialQuery.getSortProject());
      }

      return left.withPartialQuery(newPartialQuery);
    } else {
      return null;
    }
  }