我正在使用 public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Intent LoginActivity = new Intent(this,LoginActivity.class);
final Intent TeacherActivity = new Intent(this,TeacherActivity.class);
final Intent ParentActivity = new Intent(this,ParentActivity.class);
final Intent ManagerActivity = new Intent(this,ManagerActivity.class);
for (int i = 0; i < 20; i++)
{
mAuth = FirebaseAuth.getInstance();
final String username = StudentCreator.parent_names[i].replaceAll(" ", "") + StudentCreator.student_numbers[i];
final String email = username + "@onurmail.com";
final String password = "123456";
final String student_name = StudentCreator.student_names[i];
final String parent_name = StudentCreator.parent_names[i];
//Registration is successul here.
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d("User Registered", "createUserWithEmail:success");
final FirebaseUser user = mAuth.getCurrentUser();
final String user_id = user.getUid();
//I get valid userId's for 20 users.
//CREATE STUDENT OBJECT AND FIREBASE INSTANCES
final FirebaseFirestore db = FirebaseFirestore.getInstance();
final Map<String, Object> student = new HashMap<>();
student.put("student_name", student_name);
student.put("parent_name", parent_name);
//My first element of array comes here and prints its parent name and student name perfectly but cant see anything about it on database.
//PUT STUDENT TO THE DB
db.collection("TED_Ankara")
.document(parent_name)
.set(student)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(getApplicationContext(), "User inserted sucessfully: "+parent_name,
Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(getApplicationContext(), "User cannot be inserted: "+parent_name,
Toast.LENGTH_SHORT).show();
}
}
});
//PUT STUDENT TO THE DB
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.getException());
Toast.makeText(getApplicationContext(), "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
}
我了解了import sys
if use_standard_output:
stream = sys.stdout
else:
stream = open('logfile', 'w')
print("print something to monitor the process", file=stream)
参数的作用,但实际上并不知道将其设置为什么明智的值。 (以上使用默认值100。)仅将其设置为可笑的大值会有什么弊端?
答案 0 :(得分:0)
根据我的理解,page_size给出每个sql语句的输入值的大小。给出更大的数字意味着更长的sql语句,因此查询的更多内存使用情况。如果您不需要查询返回任何值,则可以安全地使用较小的值,例如默认为100。
但是,如果您想使用返回语句插入/更新某些表,则可能希望创建page_size的长度至少与数据的长度相同。您可以将其设置为length(data)(您的数据应为列表列表或元组列表),缺点是您必须对每次调用的数据值数量引入一些限制。 Postgresql允许使用很长的sql,因此,如果您有足够的内存,则应接受数百万条记录。