Skip to content

Commit

Permalink
Rename remove to removeByField
Browse files Browse the repository at this point in the history
  • Loading branch information
cc committed Aug 13, 2015
1 parent 247bbb0 commit 237a838
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions servers/src/main/java/tachyon/master/next/IndexedSet.java
Expand Up @@ -144,10 +144,9 @@ public boolean remove(T object) {
* *
* @param fieldName the field name * @param fieldName the field name
* @param value the field value * @param value the field value
* @return the set of objects that are removed, if no object is removed, the returned set is empty
* @return true if the objects are removed, otherwise false * @return true if the objects are removed, otherwise false
*/ */
public boolean remove(String fieldName, Object value) { public boolean removeByField(String fieldName, Object value) {
Set<T> toRemove = mSetIndexedByFieldValue.get(fieldName).remove(value); Set<T> toRemove = mSetIndexedByFieldValue.get(fieldName).remove(value);
boolean success = true; boolean success = true;
if (toRemove != null) { if (toRemove != null) {
Expand Down
Expand Up @@ -166,7 +166,7 @@ public synchronized boolean removeChild(Inode child) {
* @return true if the inode was removed, false otherwise. * @return true if the inode was removed, false otherwise.
*/ */
public synchronized boolean removeChild(String name) { public synchronized boolean removeChild(String name) {
return mChildren.remove("mName", name); return mChildren.removeByField("mName", name);
} }


@Override @Override
Expand Down
6 changes: 3 additions & 3 deletions servers/src/test/java/tachyon/master/next/IndexedSetTest.java
Expand Up @@ -95,17 +95,17 @@ public void getTest() {
} }


@Test @Test
public void removeTest1() { public void removeTest() {
Pair toRemove = mSet.all().iterator().next(); Pair toRemove = mSet.all().iterator().next();
Assert.assertEquals(3, mSet.getByField("mDouble", toRemove.mDouble).size()); Assert.assertEquals(3, mSet.getByField("mDouble", toRemove.mDouble).size());
Assert.assertTrue(mSet.remove(toRemove)); Assert.assertTrue(mSet.remove(toRemove));
Assert.assertEquals(2, mSet.getByField("mDouble", toRemove.mDouble).size()); Assert.assertEquals(2, mSet.getByField("mDouble", toRemove.mDouble).size());
} }


@Test @Test
public void removeTest2() { public void removeByFieldTest() {
Assert.assertEquals(3, mSet.getByField("mInt", 1).size()); Assert.assertEquals(3, mSet.getByField("mInt", 1).size());
Assert.assertTrue(mSet.remove("mInt", 1)); Assert.assertTrue(mSet.removeByField("mInt", 1));
Assert.assertEquals(0, mSet.getByField("mInt", 1).size()); Assert.assertEquals(0, mSet.getByField("mInt", 1).size());
} }
} }

0 comments on commit 237a838

Please sign in to comment.