我有一个非常简单的任务要做,但不知何故我仍然陷入困境。
我有一个大数据文件(“File_initial.dat”),应该由集群上的所有节点读取(使用 MPI),每个节点都会对此大文件的一部分(File_size / number_of_nodes)执行一些操作,最后对每个节点执行一些操作会将其结果写入一个共享的大文件(“File_final.dat”)。文件的元素数量保持不变。
通过谷歌搜索,我了解到,将数据文件写入二进制文件(我在这个文件中只有十进制数字)而不是 *.txt”文件要好得多。因为没有人会读取这个文件,而只会读取计算机。
我尝试自己实现(但使用格式化的输入/输出而不是二进制文件),但我得到了不正确的行为。
到目前为止我的代码如下:
#include <fstream>
#define NNN 30
int main(int argc, char **argv)
{
ifstream fin;
// setting MPI environment
int rank, nprocs;
MPI_File file;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// reading the initial file
fin.open("initial.txt");
for (int i=0;i<NNN;i++)
{
fin >> res[i];
cout << res[i] << endl; // to see, what I have in the file
}
fin.close();
// starting position in the "res" array as a function of "rank" of process …Run Code Online (Sandbox Code Playgroud) 在我的 qt 应用程序中,我有一个类(worker),它是从在线程中运行的对象调用的。在我的工人阶级中,我创建了 QList,如下所示
QList <QString> albums;
while (i.hasNext())
{
QRegularExpressionMatch album = i.next();
albums.append(album.captured("album"));
}
emit SignalGotAlbums(albums);
Run Code Online (Sandbox Code Playgroud)
我在另一个包装我的工作线程的类中收到这个信号,以供线程使用。我们将此类命名为 GetAlbumsThread。在那里我成功地在插槽中接收到 SignalGotAlbums
void GetAlbumsThread::Reply(QList <QString> &list)
{
emit gotAlbums(list);
emit finished();
}
Run Code Online (Sandbox Code Playgroud)
在这个插槽中,我正在触发另一个信号gotAlbums,该信号应该与我的gui线程中的插槽连接,并将我的QList传递到那里。我的问题是,当我尝试将 QList 从线程传递到 gui 时,它不起作用!插槽未收到 gotAlbums 信号;
信号声明如下:
void gotAlbums(QList<QString> &);
Run Code Online (Sandbox Code Playgroud)
并连接到我的 gui 插槽(当然在我的 gui 线程中),如下所示:
private slots:
void AlbumsReceived(QList<QString> &list)
...
QThread* albumsThread = new QThread();
GetAlbumsThread *albumsObject = new GetAlbumsThread();
albumsObject->moveToThread(albumsThread);
connect(albumsThread, SIGNAL(started()), albumsObject, SLOT(process()));
connect(albumsObject, SIGNAL(gotAlbums(QList<QString> &)), this, SLOT(AlbumsReceived(QList<QString> &));
albumsThread->start();
Run Code Online (Sandbox Code Playgroud)
由于某种原因,AlbumsReceived 从未被调用。连接返回真。有人可以帮我弄这个吗。我认为问题在于线程之间传递 QList。
通常,Overriding是重新定义子类中成员含义的概念.为什么变量在重写时不像java中的方法?
例如:
class Base {
int a = 10;
void display() {
System.out.println("Inside Base :");
}
}
class Derived extends Base {
int a = 99;
@Override
// method overriding
void display() {
System.out.println("Inside Derived :");
}
}
public class NewClass {
public static void main(String... a) {
Derived d = new Derived();
Base b = d;
b.display(); // Dynamic method dispatch
System.out.println("a=" + b.a);
}
}
Run Code Online (Sandbox Code Playgroud)
由于数据成员a是指定的包访问,因此Derived该类也可以使用它.但通常在使用基类引用调用重写方法时,会调用派生类中重新定义的方法(动态方法调度)..但对于变量..why,它是不一样的.
预期输出
内部派生:
a = 99
获得的输出:
内部衍生:
a …
我在我的机器上安装pywin32时遇到问题.我正在使用easy_install python,这是我得到的日志.
我提前为发布整个日志道歉,尽管只需要一部分来分析问题.
Downloading
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/py
win32-218.zip/download
Processing pywin32-218.zip
Writing
c:\users\jugesh\appdata\local\temp\easy_install-o_rxio\pywin32-218\setup
.cfg
Running pywin32-218\setup.py -q bdist_egg --dist-dir
c:\users\jugesh\appdata\loc
al\temp\easy_install-o_rxio\pywin32-218\egg-dist-tmp-25h0eo
Building pywin32 2.7.218.0
Traceback (most recent call last):
File "C:\Python27\Scripts\easy_install-script.py", line 9, in <module>
load_entry_point('setuptools==0.8', 'console_scripts', 'easy_install')()
File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 1992,
in main
File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 1979,
in with_ei_usage
File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 1996,
in <lambda>
File "C:\Python27\Lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd
File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 380, …Run Code Online (Sandbox Code Playgroud) 我正在努力用JSF实现一个相当简单的功能,它涉及在页面上动态显示嵌套地图的内容并编辑其值的功能.但事实证明,MappedValueExpression$Entry在迭代地图时得到的c:forEach是不可写的!
<c:forEach items='#{inflectionBean.word.inflectionalForms}' var="number" >
<p:fieldset legend="#{number.key}">
<c:forEach items="#{number.value}" var="case" >
<p:panel header="#{case.key}">
<h:inputText value="#{case.value}" />
</p:panel>
</c:forEach>
</p:fieldset>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
当我试图提交上述表格时,我得到:
javax.el.PropertyNotWritableException:/inflection.xhtml @ 39,56 value ="#{case.value}":类'com.sun.faces.facelets.tag.jstl.core.MappedValueExpression $ Entry'没有可写财产'价值'.
我想知道是否有合理的解决方法,或者我是否以错误的方式处理问题.谢谢!
您认为设计信号/插槽交互以更新类中的成员值的最佳做法是什么?
例如,考虑在UI上表示的成员变量.用户更改UI中的值.存在信号/槽关系以通过成员变量更新功能自动更新成员变量.
我们还希望在UI上自动更新成员变量的更改,因此另一种方式存在信号/插槽关系.在通过更新功能更新成员变量时,信号触发UI更新.
你如何防止这些成为循环?它是否像调用成员变量更新函数时检查新值与当前值一样简单,如果存在差异,仅发送信号以更新UI?
或者......有更优雅的方式吗?
Commonsware的WakefulIntentService运行得很漂亮,但有一些我不太了解的东西.以下是该服务的核心 - 源代码的精简版本:
class WIS extends IntentService {
private static final String NAME = WIS.class.getName() + ".Lock";
private static volatile WakeLock lockStatic = null;
synchronized private static PowerManager.WakeLock getLock(Context context) {
if (lockStatic == null) {
PowerManager mgr = (PowerManager) context
.getSystemService(Context.POWER_SERVICE);
lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, NAME);
lockStatic.setReferenceCounted(true);
}
return (lockStatic);
}
public static void startWIS(Context ctxt, Intent i) {
getLock(ctxt.getApplicationContext()).acquire();
ctxt.startService(i);
}
public WIS(String name) {
super(name);
setIntentRedelivery(true);
}
@Override
public int onStartCommand(Intent intent, int …Run Code Online (Sandbox Code Playgroud) 我想添加一个输入文本,用户可以在其中编辑数量 h:dataTable
<h:dataTable id="checkout_table" value="#{cartController.cart.entrySet()}"
var="item" >
<h:column>
<f:facet name="header">Movie</f:facet>
#{item.key.title} - #{item.key.getAvailable()}
</h:column>
<h:column>
<f:facet name="header">Quantity</f:facet>
<h:inputText id="quantity"
value="#{item.value}" redisplay="true"
converterMessage="Please provide an integer" required="true"
requiredMessage="Please enter a quantity">
<!-- <f:validateLongRange minimum="1"
maximum="#{item.key.getAvailable()}" />
this validation must be performed on set-->
<f:ajax event="blur" render="quantityMessage" />
</h:inputText>
</h:column>
<h:column><h:commandButton value="edit"
action="#{cartController.addMovieToCart(item.key, item.value)}" />
</h:column>
<h:column><h:commandButton value="delete"
action="#{cartController.removeMovie(item.key)}" />
</h:column>
<h:column><h:message id="quantityMessage" for="quantity" /></h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)
因为它现在抛出了异常The class 'java.util.LinkedHashMap$Entry' does not have a writable property 'value'.我已经阅读了有关绑定的各种内容,但无法完全理解它们.如何为此输入字段定义getter和setter?我可以使用其他一些组件吗?
如果验证也可以处理,那将是值得赞赏的!
编辑:在@BalusC回答后,我设法读取并写入地图 - …
我试图在我的项目的两个活动之间共享共享偏好,但由于某种原因我无法传递数据.
我有活动A,它读取共享首选项和活动B,读取和编辑共享首选项.
这是我用来在Activity B中编写共享首选项的代码:
SharedPreferences sharedPref = getSharedPreferences("myPrefs", Context.
MODE_WORLD_WRITEABLE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("theme", "black");
editor.commit();
Run Code Online (Sandbox Code Playgroud)
并在活动A中阅读:
SharedPreferences sharedPref = getSharedPreferences("myPrefs", Context.
MODE_WORLD_WRITEABLE);
String theme=sharedPref.getString("theme","blue");
Run Code Online (Sandbox Code Playgroud)
我尝试使用不同的模式,它在活动B中以私有模式工作,但它没有与活动A共享.出于某些原因,我认为我有两个不同的共享首选项(同名)用于两个不同的活动.如何对这两个活动使用相同的共享首选项?
我目前正在开发一个Qt项目,我在SLOT方面遇到了一些麻烦.我想传递一个指向成员函数的指针作为SLOT的参数.为此,我在课堂上宣布了SLOT,但是当我这样做时,我得到了MOC错误.我不知道我想要达到的目标是否可行.
名为MainFrame的类的语法示例:
void slotAnswerReceived (QString answer, void (MainFrame::*ptr)(QString));
Run Code Online (Sandbox Code Playgroud)
我没有任何连接,没有使用该功能,我唯一的错误是在上面的这一行.
谢谢大家的帮助.我在网上找不到任何解决方案(但是如果有人感兴趣,我发现这篇文章深入解释了SIGNAL和SLOT).
qt ×3
slot ×3
android ×2
jsf ×2
signals ×2
c++ ×1
easy-install ×1
inheritance ×1
io ×1
java ×1
jsf-2.2 ×1
jstl ×1
map ×1
mpi ×1
output ×1
overriding ×1
python-2.7 ×1
pywin32 ×1
qlist ×1