incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/3] git commit: Adding test for deletion of column during row update where the record mutation type is replace columns. If the column value is null then the column is removed form the record. Also fixing a NPE in the transaction recorder.
Date Sun, 15 Sep 2013 01:44:18 GMT
Adding test for deletion of column during row update where the record mutation type is replace
columns.  If the column value is null then the column is removed form the record.  Also fixing
a NPE in the transaction recorder.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/faab2e14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/faab2e14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/faab2e14

Branch: refs/heads/master
Commit: faab2e145d159391bdaedd9128fdf5d6d7b001ce
Parents: f76fa04
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Sep 14 21:02:09 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Sep 14 21:02:09 2013 -0400

----------------------------------------------------------------------
 .../manager/writer/TransactionRecorder.java     |  7 +++++++
 .../apache/blur/manager/IndexManagerTest.java   | 22 ++++++++++++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/faab2e14/blur-core/src/main/java/org/apache/blur/manager/writer/TransactionRecorder.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/TransactionRecorder.java
b/blur-core/src/main/java/org/apache/blur/manager/writer/TransactionRecorder.java
index 207d21f..605fe32 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/TransactionRecorder.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/TransactionRecorder.java
@@ -273,6 +273,10 @@ public class TransactionRecorder extends TimerTask implements Closeable
{
   }
 
   private static void writeString(DataOutputStream outputStream, String s) throws IOException
{
+    if (s == null) {
+      Utils.writeVInt(outputStream, -1);  
+      return;
+    }
     byte[] bs = s.getBytes();
     Utils.writeVInt(outputStream, bs.length);
     outputStream.write(bs);
@@ -280,6 +284,9 @@ public class TransactionRecorder extends TimerTask implements Closeable
{
 
   private static String readString(DataInputStream inputStream) throws IOException {
     int length = Utils.readVInt(inputStream);
+    if (length == -1) {
+      return null;
+    }
     byte[] buffer = new byte[length];
     inputStream.readFully(buffer);
     return new String(buffer);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/faab2e14/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
index 82748f0..8edb2d7 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
@@ -1000,6 +1000,28 @@ public class IndexManagerTest {
     }
     assertTrue("column 3 should be unmodified", foundUnmodifiedColumn);
   }
+  
+  @Test
+  public void testMutationUpdateRowReplaceExistingColumnsWhileDeletingAColumn() throws Exception
{
+    Column c1 = newColumn("testcol1", "value999");
+    Column c2 = newColumn("testcol2", null);
+    String rec = "record-1";
+    RecordMutation rm = newRecordMutation(REPLACE_COLUMNS, FAMILY, rec, c1, c2);
+
+    Record r = updateAndFetchRecord("row-1", rec, rm);
+
+    assertNotNull("record should exist", r);
+    assertEquals("only 2 columns in record", 2, r.getColumnsSize());
+    assertTrue("column 1 should be in record", r.columns.contains(c1));
+    boolean foundUnmodifiedColumn = false;
+    for (Column column : r.columns) {
+      if (column.name.equals("testcol3") && column.value.equals("value3")) {
+        foundUnmodifiedColumn = true;
+        break;
+      }
+    }
+    assertTrue("column 3 should be unmodified", foundUnmodifiedColumn);
+  }
 
   @Test
   public void testMutationUpdateRowReplaceExistingDuplicateColumns() throws Exception {


Mime
View raw message