Construct a model.QuerySpec from model.MapperSpec.
11832
def _get_query_spec(cls, params):
    """"""
    entity_kind = params[cls.ENTITY_KIND_PARAM]
    filters = params.get(cls.FILTERS_PARAM)
    app = params.get(cls._APP_PARAM)
    ns = params.get(cls.NAMESPACE_PARAM)

    return model.QuerySpec(
        entity_kind=cls._get_raw_entity_kind(entity_kind),
        keys_only=bool(params.get(cls.KEYS_ONLY_PARAM, False)),
        filters=filters,
        batch_size=int(params.get(cls.BATCH_SIZE_PARAM, cls._BATCH_SIZE)),
        model_class_path=entity_kind,
        app=app,
        ns=ns)
577561
@Beta
    public GetItemSpec withExpressionSpec(GetItemExpressionSpec xspec) {
        return withProjectionExpression(xspec.getProjectionExpression())
              .withNameMap(xspec.getNameMap())
              ;
    }
266161
def _gql(cls, query_string, *args, **kwds):
    """"""
    from .query import gql  # Import late to avoid circular imports.
    return gql('SELECT * FROM %s %s' % (cls._class_name(), query_string),
               *args, **kwds)
230622
private Mapper createCustomMapper(Field field, PropertyMapper propertyMapperAnnotation) {
    Class<? extends Mapper> mapperClass = propertyMapperAnnotation.value();
    Constructor<? extends Mapper> constructor = IntrospectionUtils.getConstructor(mapperClass,
        Field.class);
    if (constructor != null) {
      try {
        return constructor.newInstance(field);
      } catch (Exception exp) {
        throw new EntityManagerException(exp);
      }
    }
    throw new EntityManagerException(
        String.format("Mapper class %s must have a public constructor with a parameter type of %s",
            mapperClass.getName(), Field.class.getName()));

  }
29773
public List<ModelServiceInstance> queryUPModelInstances(ServiceInstanceQuery query){
        List<ModelServiceInstance> upInstances= null;
        List<ModelServiceInstance> instances = queryModelInstances(query);
        if(instances != null && instances.size() > 0){

            for(ModelServiceInstance instance : instances){
                if(OperationalStatus.UP.equals(instance.getStatus())){
                    if(upInstances == null){
                        upInstances = new ArrayList<ModelServiceInstance>();
                    }
                    upInstances.add(instance);
                }
            }
        }
        if(upInstances == null){
            return Collections.emptyList();
        }
        return upInstances;

    }
98448
def _one_to_many_query(cls, query_obj, search4, model_attrib):
        
        model = model_attrib.parent.class_

        already_joined_tables = [mapper.class_ for mapper in query_obj._join_entities]

        if isinstance(search4, (str, int, Iterable)) and model not in already_joined_tables:
            query_obj = query_obj.join(model)

        if isinstance(search4, str):
            query_obj = query_obj.filter(model_attrib.like(search4))

        elif isinstance(search4, int):
            query_obj = query_obj.filter(model_attrib == search4)

        elif isinstance(search4, Iterable):
            query_obj = query_obj.filter(model_attrib.in_(search4))

        return query_obj
851888
public void setQuerySpecDeserializer(QuerySpecDeserializer querySpecDeserializer) {
		PreconditionUtil.assertNotNull("A query spec deserializer must be provided, but is null", querySpecDeserializer);
		this.querySpecDeserializer = querySpecDeserializer;
		this.queryParamsBuilder = null;
	}
1015743
def _constructor(cls, mapping, configuration):
        
        sequence_type, default_factory, pass_key = configuration
        return cls(default_factory, mapping, sequence_type=sequence_type,
                   pass_key=pass_key)
713544
def _build_implicit_queryset(self, model, requirements):
        """"""

        queryset = self._make_model_queryset(model)
        prefetches = {}
        self._build_implicit_prefetches(
            model,
            prefetches,
            requirements
        )
        prefetch = prefetches.values()
        queryset = queryset.prefetch_related(*prefetch).distinct()
        if self.DEBUG:
            queryset._using_prefetches = prefetches
        return queryset
93444
private MapperConstructor getMapper(String dName){
		return new MapperConstructor(destinationType(), sourceType(), dName, dName, getSName(), configChosen, xml,methodsToGenerate);
	}
1280895
def fielddefsql_from_fieldspeclist(
            self, fieldspeclist: FIELDSPECLIST_TYPE) -> str:
        """"""
        return ",".join([
            self.fielddefsql_from_fieldspec(x)
            for x in fieldspeclist
        ])
181429
def from_api_repr(cls, resource):
        
        name = resource.get("name")
        type_ = resource["parameterType"]["type"]
        value = resource["parameterValue"]["value"]
        converted = _QUERY_PARAMS_FROM_JSON[type_](value, None)
        return cls(name, type_, converted)
522264
def fielddefsql_from_fieldspec(fieldspec: FIELDSPEC_TYPE) -> str:
        """"""
        sql = fieldspec["name"] + " " + fieldspec["sqltype"]
        if "notnull" in fieldspec and fieldspec["notnull"]:
            sql += " NOT NULL"
        if "autoincrement" in fieldspec and fieldspec["autoincrement"]:
            sql += " AUTO_INCREMENT"
        if "pk" in fieldspec and fieldspec["pk"]:
            sql += " PRIMARY KEY"
        else:
            if "unique" in fieldspec and fieldspec["unique"]:
                sql += " UNIQUE"
        if "comment" in fieldspec:
            sql += " COMMENT " + sql_quote_string(fieldspec["comment"])
        return sql
435943
def from_json(cls, json):
    """"""
    obj = cls(key_range.KeyRange.from_json(json["key_range"]),
              model.QuerySpec.from_json(json["query_spec"]))
    cursor = json["cursor"]
    # lint bug. Class method can access protected fields.
    # pylint: disable=protected-access
    if cursor and json["cursor_object"]:
      obj._cursor = datastore_query.Cursor.from_websafe_string(cursor)
    else:
      obj._cursor = cursor
    return obj
345329
@PublicEvolving
	public QueryableStateStream<KEY, T> asQueryableState(
			String queryableStateName,
			ValueStateDescriptor<T> stateDescriptor) {

		transform("Queryable state: " + queryableStateName,
				getType(),
				new QueryableValueStateOperator<>(queryableStateName, stateDescriptor));

		stateDescriptor.initializeSerializerUnlessSet(getExecutionConfig());

		return new QueryableStateStream<>(
				queryableStateName,
				stateDescriptor,
				getKeyType().createSerializer(getExecutionConfig()));
	}
178417
def _to_protobuf(self):
        
        projection = self._normalize_projection(self._projection)
        orders = self._normalize_orders()
        start_at = self._normalize_cursor(self._start_at, orders)
        end_at = self._normalize_cursor(self._end_at, orders)

        query_kwargs = {
            "select": projection,
            "from": [
                query_pb2.StructuredQuery.CollectionSelector(
                    collection_id=self._parent.id
                )
            ],
            "where": self._filters_pb(),
            "order_by": orders,
            "start_at": _cursor_pb(start_at),
            "end_at": _cursor_pb(end_at),
        }
        if self._offset is not None:
            query_kwargs["offset"] = self._offset
        if self._limit is not None:
            query_kwargs["limit"] = wrappers_pb2.Int32Value(value=self._limit)

        return query_pb2.StructuredQuery(**query_kwargs)
262374
def _FromSpecs(self, specs):
        

        if isinstance(specs, dict):
            specs_ = []
            for name, value in specs.items():
                specs_.append((name, {"value": value}))
        else:
            specs_ = specs
        for spec in specs_:
            self.params.append(Parameter(spec))