[英]How can I get data generated by one function in one class in another class in same package in java
now I have a package in my current project with 2 java classes. 现在我当前的项目中有一个包含2个Java类的包。 One of them pull data from a table and rearrange into a Map
. 其中一个从表中提取数据,然后重新排列到Map
。 The other class does the checking work in which it need access this Map
frequently. 另一个类执行需要经常访问此Map
的检查工作。 Obviously, I don't want to generate this Map
every time the checking class called. 显然,我不想每次检查类都调用时生成此Map
。 What is the easiest and most efficient way for me to store that Map
making my checking class work faster. 对我而言,最简单,最有效的方法就是存储该Map
从而使检查类的工作更快。 I hope to find a way to make that Map global accessible within my package after it is generated. 我希望找到一种方法,使生成的地图在我的程序包中可以全局访问。 Need advice! 需要咨询!
To make it clear, the checking class extend abstract class of a spark UDF1. 为了清楚起见,检查类扩展了火花UDF1的抽象类。 So it will work as a UDF on spark. 因此,它将作为火花上的UDF使用。 No main function in both classes, THx. 这两个类别都没有主要功能,THx。
If I understood your question correct.. It is like below 如果我正确理解您的问题。如下所示
public class Loader {
public static Map<K, V> holder;
public void loadMap() {
// Code to populate map goes here
}
}
and you will be able to access map like 这样您就可以访问类似的地图
public class Checker {
public void check() {
// Acccess map like this Loader.holder;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.