Anything wrong in the way to use getBytes() in my code?
hyunjun opened this issue · comments
hyunjun commented
void executeAlgorithm(AlgorithmData& data, AlgorithmContext& context)
{
Dataset* input = data.getInputDataset("input");
std::set<DataKey> keys = input->getAllFileKeys();
for ( std::set<DataKey>::iterator i = keys.begin(); i != keys.end(); i++ ) {
DataKey myKey = *i;
DataFile* myFile = input->getDataFile(myKey);
long fileSize = myFile->getSize();
char * fileBytes=myFile->getBytes();
}
}
Adding the last line char * fileBytes = myFile->getBytes();
, failed while without the line, succeeded.
Anything wrong in my code?
pandoublefeng commented
Malloc some space to the fileBytes?? 发件人: hyunjun已发送: 2015年3月17日星期二 9:40收件人: google/mr4c答复: google/mr4c主题: [mr4c] Anything wrong in the way to use getBytes() in my code? (#7) void executeAlgorithm(AlgorithmData& data, AlgorithmContext& context)
{
Dataset* input = data.getInputDataset("input");
std::set<DataKey> keys = input->getAllFileKeys();
for ( std::set<DataKey>::iterator i = keys.begin(); i != keys.end(); i++ ) {
DataKey myKey = *i;
DataFile* myFile = input->getDataFile(myKey);
long fileSize = myFile->getSize();
char * fileBytes=myFile->getBytes();
}
}
Adding the last line char * fileBytes = myFile->getBytes();, failed while without the line, succeeded.
Anything wrong in my code?
—Reply to this email directly or view it on GitHub.
Mitchell Ratisher commented
What kind of error are you seeing? Something should show up in the logs.
How big is your dataset? If you have a bunch of files, and you are just reading them all into memory, you could be running out of memory. Try calling release() on each file, so the memory gets freed up.