我在运行时生成一个单例
public void ConfigureServices(IServiceCollection services)
{
var applications = Utils.generateApplications()
services.AddSingleton<ApplicationModel[]>(applications);
services.AddMvc();
}
Run Code Online (Sandbox Code Playgroud)
我以后如何更新注入ApplicationModel[]全新的ApplicationModel[]. 我的应用程序中有一个功能,用户可以使用该功能来触发应用程序上的数据刷新,但是如何更新底层注入的单例,以便所有未来的注入都将使用更新的应用程序?我有一个函数Utils.generateApplications()可以获取最新的应用程序列表并返回ApplicationModel[]. 如果有意义的话,如何用新对象覆盖旧的注入单例以注入到将来的调用中?
我有一些代码:
public void UpdateData()
{
var applications = Utils.generateApplications()
//How do I set applications to replace the injected singleton for all future injections?
}
Run Code Online (Sandbox Code Playgroud) 问题摘要 - 如何将其转换为Scala类?
问题 - 调用不同超级构造函数的多个构造函数
Java类 -
public class ClassConstExample extends BaseClassExample {
private String xyzProp;
private string inType = "def";
private String outType = "def";
private String flagSpecial = "none";
public ClassConstExample(final String file, final String header, final String inType,
final String outType, final String flag) {
super(file);
init(header, inType, outType, flag);
}
public ClassConstExample(final String file, final String header, final String inType,
final String outType, final String flag, final String mode) {
super(file, mode);
init(header, inType, outType, …Run Code Online (Sandbox Code Playgroud) with gzip.open("/tar/access.tar.gz", 'rb') as f_in:
with open("/tar/access.tar", 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
Run Code Online (Sandbox Code Playgroud)
我的输入文件是150GB.一旦我意识到尝试执行此操作时内存为50GB,我将服务器提升到了432GB的内存.gzip是否首先尝试在内存中打开整个文件?为什么432GB不够用?
确切的错误是OSError: [Errno 14] Bad address: '/tar/access.tar.gz'但是当存在内存错误时抛出此错误.
堆栈跟踪 :
/usr/lib/python3.5/gzip.py in open(filename, mode, compresslevel, encoding, errors, newline)
51 gz_mode = mode.replace("t", "")
52 if isinstance(filename, (str, bytes)):
---> 53 binary_file = GzipFile(filename, gz_mode, compresslevel)
54 elif hasattr(filename, "read") or hasattr(filename, "write"):
55 binary_file = GzipFile(None, gz_mode, compresslevel, filename)
/usr/lib/python3.5/gzip.py in __init__(self, filename, mode, compresslevel, fileobj, mtime)
161 mode += 'b'
162 if fileobj is None:
--> …Run Code Online (Sandbox Code Playgroud) val schema = df.schema
val x = df.flatMap(r =>
(0 until schema.length).map { idx =>
((idx, r.get(idx)), 1l)
}
)
Run Code Online (Sandbox Code Playgroud)
这会产生错误
java.lang.ClassNotFoundException: scala.Any
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,有什么帮助吗?
DECLARE @result NVARCHAR(max);
SET @result = (SELECT * FROM table
FOR JSON AUTO, ROOT('Data'))
SELECT @result;
Run Code Online (Sandbox Code Playgroud)
这将返回一个〜43000个字符的json字符串,某些结果将被截断。
SET @result = (SELECT * FROM table
FOR JSON AUTO, ROOT('Data'))
Run Code Online (Sandbox Code Playgroud)
这将返回约2000个字符的json字符串。有什么方法可以防止任何截断吗?即使在处理一些大数据时,字符串也有数百万个字符?
scala ×2
.net-core ×1
apache-spark ×1
c# ×1
databricks ×1
java ×1
json ×1
python ×1
sql ×1
sql-server ×1