'Returns a v1 internal proto representation of the query key filter.
Args:
adapter: A datastore_rpc.AbstractAdapter.
Returns:
A tuple (googledatastore.RunQueryRequest, googledatastore.Filter).
The second tuple value is a Filter representing the ancestor portion of the
query. If there is no ancestor constraint, this value will be None'

def _to_pb_v1(self, adapter):

    pb = googledatastore.RunQueryRequest()
    partition_id = pb.partition_id
    partition_id.project_id = adapter.get_entity_converter().app_to_project_id(self.__app)
    if self.__namespace:
        partition_id.namespace_id = self.__namespace
    if (self.__kind is not None):
        pb.query.kind.add().name = self.__kind
    ancestor_filter = None
    if self.__ancestor:
        ancestor_filter = googledatastore.Filter()
        ancestor_prop_filter = ancestor_filter.property_filter
        ancestor_prop_filter.op = googledatastore.PropertyFilter.HAS_ANCESTOR
        prop_pb = ancestor_prop_filter.property
        prop_pb.name = datastore_types.KEY_SPECIAL_PROPERTY
        adapter.get_entity_converter().v3_to_v1_key(self.ancestor, ancestor_prop_filter.value.key_value)
    return (pb, ancestor_filter)
