我有大量查询的.hql文件。蜂巢运行缓慢。我想使用pyspark / sparksql读取并运行.hql文件。
我尝试了using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
public class Player : MonoBehaviour
{
private Rigidbody2D myRigidbody;
private Animator myAnimator;
[SerializeField]
private float movementSpeed;
private bool walk;
private bool slide;
private bool facingRight;
[SerializeField]
private Transform[] groundPoints;
[SerializeField]
private float groundRadius;
private LayerMask whatIsGround;
private bool IsGrounded;
private bool jump;
[SerializeField]
private bool airControl;
[SerializeField]
private float jumpForce;
// Start is called before the first frame update
void Start()
{
facingRight = true;
myRigidbody = GetComponent<Rigidbody2D>();
myAnimator = GetComponent<Animator>();
}
void Update()
{
HandleInput();
}
// Update is called once per frame
void FixedUpdate()
{
float horizontal = Input.GetAxis("Horizontal");
isGround = IsGrounded();
HandleMovement(horizontal);
Flip(horizontal);
HandleWalk();
ResetValues();
}
private void HandleMovement(float horizontal)
{
if (!this.myAnimator.GetCurrentAnimatorStateInfo(0).IsTag("Walk")&& (isGround || airControl))
{
myRigidbody.velocity = new Vector2(horizontal * movementSpeed, myRigidbody.velocity.y);
}
if (isGround && jump)
{
isGround = false;
myRigidbody.AddForce(new Vector2(0, jumpForce));
}
if (slide && !this.myAnimator.GetCurrentAnimatorStateInfo(0).IsName("Slide"))
{
myAnimator.SetBool("slide", true);
}
else if (!this.myAnimator.GetCurrentAnimatorStateInfo(0).IsName("slide"))
{
myAnimator.SetBool("slide", false);
}
myAnimator.SetFloat("speed", Mathf.Abs(horizontal));
}
private void HandleWalk()
{
if (walk)
{
myAnimator.SetTrigger("walk");
myRigidbody.velocity = Vector2.zero;
}
}
private void HandleInput()
{
if (Input.GetKeyDown(KeyCode.Space))
{
jump = true;
}
if (Input.GetKeyDown(KeyCode.LeftShift))
{
walk = true;
}
if (Input.GetKeyDown(KeyCode.LeftControl))
{
slide = true;
}
}
private void Flip(float horizontal)
{
if (horizontal > 0 && !facingRight || horizontal < 0 && facingRight)
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
private void ResetValues()
{
walk = false;
slide = false;
}
private bool isGround()
{
if (myRigidbody.velocity.y <= 0)
{
foreach (Transform point in instance.groundPoints)
{
Collider2D[] colliders = Physics2D.OverlapCircleAll (point.position, instance.groundRadius, instance.whatIsGround);
for (int i = 0; i < colliders.Length; i++)
{
if (colliders[i].gameObject != gameObject)
{
return true;
}
}
}
}
return false;
}
}
,但出现了以下错误:
count = sqlContext.sql(open("file.hql").read()).count()