Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Seperate file read func#334

Merged
carsonwang merged 1 commit intoIntel-bigdata:6.0from
gcz2022:seperate_file_read_func
Oct 21, 2016
Merged

Seperate file read func#334
carsonwang merged 1 commit intoIntel-bigdata:6.0from
gcz2022:seperate_file_read_func

Conversation

@gcz2022
Copy link
Copy Markdown
Contributor

@gcz2022 gcz2022 commented Oct 20, 2016

No description provided.

@gcz2022 gcz2022 changed the base branch from master to 6.0 October 20, 2016 08:31
content = f.read()
except IOError:
return
lines = read_file_content(file_name)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you still use try and catch the exception? read_file_content is likely to throws an exception

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that funcion, I check if the file exists, so it will only throws an exception when there are some exceptions in file I/O. In this case, shouldn't the exception be thrown?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just saw if file exists is checked in that function.

lines = read_file_content(file_name)
content = ""
for line in lines:
content = content + line
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any difference between lines and content?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines is a list, content is a str

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to use read() and now you use readlines and concat the lines. The content should be the same, right? I means the '\n' in each line is also included in content.

Copy link
Copy Markdown
Contributor Author

@gcz2022 gcz2022 Oct 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the contents are not the same, but the code still works.
The difference is: when you use the former code(with '\n'(s) in the content), the strip func below will take effect,
while when you use the present code(without '\n's in the content), the strip func below doesn't need to take effect.

spark_env_file = join(spark_home, "conf/spark-env.sh")
value = default_value

if(len(glob.glob(spark_env_file)) == 1):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this if condition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved this statement to read_file_content func

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

@carsonwang carsonwang merged commit 06bb56f into Intel-bigdata:6.0 Oct 21, 2016
carsonwang pushed a commit to carsonwang/HiBench that referenced this pull request Nov 7, 2016
carsonwang pushed a commit that referenced this pull request Nov 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants