Skip to content

Commit

Permalink
Handle null mutators
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Yokota committed Feb 3, 2017
1 parent b454af4 commit 5e6fc48
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/main/java/io/hgraphdb/HBaseBulkLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Vertex addVertex(final Object... keyValues) {
indexVertex(vertex, indices);

Creator creator = new VertexWriter(graph, vertex);
verticesMutator.mutate(getMutationList(creator.constructInsertions()));
if (verticesMutator != null) verticesMutator.mutate(getMutationList(creator.constructInsertions()));

return vertex;
} catch (IOException e) {
Expand All @@ -102,7 +102,7 @@ public Vertex addVertex(final Object... keyValues) {
public void indexVertex(Vertex vertex, Iterator<IndexMetadata> indices) {
try {
VertexIndexWriter writer = new VertexIndexWriter(graph, vertex, indices, null);
vertexIndicesMutator.mutate(getMutationList(writer.constructInsertions()));
if (vertexIndicesMutator != null) vertexIndicesMutator.mutate(getMutationList(writer.constructInsertions()));
} catch (IOException e) {
throw new HBaseGraphException(e);
}
Expand All @@ -125,10 +125,10 @@ public Edge addEdge(Vertex outVertex, Vertex inVertex, String label, Object... k
indexEdge(edge, indices);

EdgeIndexWriter writer = new EdgeIndexWriter(graph, edge, Constants.CREATED_AT);
edgeIndicesMutator.mutate(getMutationList(writer.constructInsertions()));
if (edgeIndicesMutator != null) edgeIndicesMutator.mutate(getMutationList(writer.constructInsertions()));

Creator creator = new EdgeWriter(graph, edge);
edgesMutator.mutate(getMutationList(creator.constructInsertions()));
if (edgesMutator != null) edgesMutator.mutate(getMutationList(creator.constructInsertions()));

return edge;
} catch (IOException e) {
Expand All @@ -139,7 +139,7 @@ public Edge addEdge(Vertex outVertex, Vertex inVertex, String label, Object... k
public void indexEdge(Edge edge, Iterator<IndexMetadata> indices) {
try {
EdgeIndexWriter indexWriter = new EdgeIndexWriter(graph, edge, indices, null);
edgeIndicesMutator.mutate(getMutationList(indexWriter.constructInsertions()));
if (edgeIndicesMutator != null) edgeIndicesMutator.mutate(getMutationList(indexWriter.constructInsertions()));
} catch (IOException e) {
throw new HBaseGraphException(e);
}
Expand All @@ -160,7 +160,7 @@ public void setProperty(Edge edge, String key, Object value) {
oldValue = e.getProperty(key);
if (oldValue != null && !oldValue.equals(value)) {
EdgeIndexRemover indexRemover = new EdgeIndexRemover(graph, e, key, null);
edgeIndicesMutator.mutate(getMutationList(indexRemover.constructMutations()));
if (edgeIndicesMutator != null) edgeIndicesMutator.mutate(getMutationList(indexRemover.constructMutations()));

This comment has been minimized.

Copy link
@nguyenhoan

nguyenhoan Feb 14, 2017

Hi @rayokota
We are a team of researchers from Iowa State, The University of Texs at Dallas and Oregon State University, USA. We are investigating common/repeated code changes.
We have four short questions regarding the change in this statement of the commit.

Questions:

Q1- Is the change at these lines similar to another change from before? (yes, no, not sure)

Q2- Can you briefly describe the change and why you made it? (for example, checking parameter before calling the method to avoid a Null Pointer Exception)

Q3- Can you give it a name? (for example, Null Check)

Q4- Would you like to have this change automated by a tool? (Yes, No, Already automated)

The data collected from the answers will never be associated with you or your project. Our questions are about recurring code changes from the developer community, not about personal information. All the data is merged across recurring changes from GitHub repositories. We will publish aggregated data from the trends of the whole community.
We have a long tradition of developing refactoring tools and contributing them freely to the Eclipse, Netbeans, Android Studio under their respective FLOSS licenses. For example, look at some of our recently released refactoring tools: http://refactoring.info/tools/

Thank you,
Hoan Nguyen https://sites.google.com/site/nguyenanhhoan/
Michael Hilton http://web.engr.oregonstate.edu/~hiltonm/
Tien Nguyen http://www.utdallas.edu/~tien.n.nguyen/
Danny Dig http://eecs.oregonstate.edu/people/dig-danny

}
}

Expand All @@ -170,11 +170,11 @@ public void setProperty(Edge edge, String key, Object value) {
if (hasIndex) {
if (oldValue == null || !oldValue.equals(value)) {
EdgeIndexWriter indexWriter = new EdgeIndexWriter(graph, e, key);
edgeIndicesMutator.mutate(getMutationList(indexWriter.constructInsertions()));
if (edgeIndicesMutator != null) edgeIndicesMutator.mutate(getMutationList(indexWriter.constructInsertions()));
}
}
PropertyWriter propertyWriter = new PropertyWriter(graph, e, key, value);
edgesMutator.mutate(getMutationList(propertyWriter.constructMutations()));
if (edgesMutator != null) edgesMutator.mutate(getMutationList(propertyWriter.constructMutations()));
} catch (IOException e) {
throw new HBaseGraphException(e);
}
Expand All @@ -195,7 +195,7 @@ public void setProperty(Vertex vertex, String key, Object value) {
oldValue = v.getProperty(key);
if (oldValue != null && !oldValue.equals(value)) {
VertexIndexRemover indexRemover = new VertexIndexRemover(graph, v, key, null);
vertexIndicesMutator.mutate(getMutationList(indexRemover.constructMutations()));
if (vertexIndicesMutator != null) vertexIndicesMutator.mutate(getMutationList(indexRemover.constructMutations()));
}
}

Expand All @@ -205,11 +205,11 @@ public void setProperty(Vertex vertex, String key, Object value) {
if (hasIndex) {
if (oldValue == null || !oldValue.equals(value)) {
VertexIndexWriter indexWriter = new VertexIndexWriter(graph, v, key);
vertexIndicesMutator.mutate(getMutationList(indexWriter.constructInsertions()));
if (vertexIndicesMutator != null) vertexIndicesMutator.mutate(getMutationList(indexWriter.constructInsertions()));
}
}
PropertyWriter propertyWriter = new PropertyWriter(graph, v, key, value);
verticesMutator.mutate(getMutationList(propertyWriter.constructMutations()));
if (verticesMutator != null) verticesMutator.mutate(getMutationList(propertyWriter.constructMutations()));
} catch (IOException e) {
throw new HBaseGraphException(e);
}
Expand All @@ -222,10 +222,10 @@ private List<? extends Mutation> getMutationList(Iterator<? extends Mutation> mu

public void close() {
try {
edgesMutator.close();
edgeIndicesMutator.close();
verticesMutator.close();
vertexIndicesMutator.close();
if (edgesMutator != null) edgesMutator.close();
if (edgeIndicesMutator != null) edgeIndicesMutator.close();
if (verticesMutator != null) verticesMutator.close();
if (vertexIndicesMutator != null) vertexIndicesMutator.close();
} catch (IOException e) {
throw new HBaseGraphException(e);
}
Expand Down

0 comments on commit 5e6fc48

Please sign in to comment.