fluo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [3/3] incubator-fluo git commit: Merge branch 'fluo-746'
Date Thu, 04 Aug 2016 14:18:46 GMT
Merge branch 'fluo-746'


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

Branch: refs/heads/master
Commit: f8d0af6e92a58beebf2060416448a1f3ed138fe6
Parents: 5400971 aa36c88
Author: Keith Turner <keith@deenlo.com>
Authored: Thu Aug 4 09:56:42 2016 -0400
Committer: Keith Turner <keith@deenlo.com>
Committed: Thu Aug 4 09:56:42 2016 -0400

----------------------------------------------------------------------
 .../fluo/accumulo/data/WriteUtilImpl.java       |  36 ---
 .../fluo/accumulo/util/ByteArrayUtil.java       |  65 +++-
 .../fluo/accumulo/util/NotificationUtil.java    |   4 +-
 .../apache/fluo/accumulo/values/LockValue.java  |   6 +-
 .../java/org/apache/fluo/api/data/Bytes.java    | 307 ++++++++++++-------
 .../org/apache/fluo/api/data/BytesBuilder.java  | 133 --------
 .../apache/fluo/api/data/BytesBuilderTest.java  | 164 ++++++++++
 .../org/apache/fluo/api/data/BytesTest.java     | 171 +++++++++++
 .../org/apache/fluo/api/data/ColumnTest.java    | 122 ++++++++
 .../org/apache/fluo/api/data/RowColumnTest.java |  86 ++++++
 .../fluo/api/data/RowColumnValueTest.java       |  87 ++++++
 .../java/org/apache/fluo/api/data/SpanTest.java | 260 ++++++++++++++++
 .../org/apache/fluo/core/util/ByteUtil.java     |  19 ++
 .../org/apache/fluo/core/util/ColumnUtil.java   |  22 +-
 .../apache/fluo/core/data/BytesBuilderTest.java | 131 --------
 .../org/apache/fluo/core/data/BytesTest.java    | 102 ------
 .../org/apache/fluo/core/data/ColumnTest.java   | 122 --------
 .../apache/fluo/core/data/RowColumnTest.java    |  86 ------
 .../fluo/core/data/RowColumnValueTest.java      |  87 ------
 .../org/apache/fluo/core/data/SpanTest.java     | 260 ----------------
 .../org/apache/fluo/core/util/ByteUtilTest.java |  18 ++
 21 files changed, 1196 insertions(+), 1092 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/f8d0af6e/modules/api/src/test/java/org/apache/fluo/api/data/BytesTest.java
----------------------------------------------------------------------
diff --cc modules/api/src/test/java/org/apache/fluo/api/data/BytesTest.java
index 0000000,12acdcc..56c33f6
mode 000000,100644..100644
--- a/modules/api/src/test/java/org/apache/fluo/api/data/BytesTest.java
+++ b/modules/api/src/test/java/org/apache/fluo/api/data/BytesTest.java
@@@ -1,0 -1,163 +1,171 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+  * agreements. See the NOTICE file distributed with this work for additional information
regarding
+  * copyright ownership. The ASF licenses this file to you under the Apache License, Version
2.0 (the
+  * "License"); you may not use this file except in compliance with the License. You may
obtain a
+  * copy of the License at
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0
+  * 
+  * Unless required by applicable law or agreed to in writing, software distributed under
the License
+  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+  * or implied. See the License for the specific language governing permissions and limitations
under
+  * the License.
+  */
+ 
+ package org.apache.fluo.api.data;
+ 
+ import java.io.ByteArrayOutputStream;
+ import java.io.IOException;
+ import java.nio.ByteBuffer;
+ import java.nio.ReadOnlyBufferException;
+ import java.nio.charset.StandardCharsets;
+ import java.util.Arrays;
+ 
+ import org.apache.fluo.api.data.Bytes;
+ import org.junit.Assert;
+ import org.junit.Test;
+ 
+ /**
+  * Unit test for {@link Bytes}
+  */
+ public class BytesTest {
+ 
+   @Test
+   public void testBytesWrap() {
+ 
+     String s1 = "test1";
+     Bytes b1 = Bytes.of(s1);
+     Assert.assertArrayEquals(s1.getBytes(), b1.toArray());
+     Assert.assertEquals(s1, b1.toString());
+ 
+     String s2 = "test2";
+     ByteBuffer bb = ByteBuffer.wrap(s2.getBytes());
+     Bytes b2 = Bytes.of(bb);
+     Assert.assertArrayEquals(s2.getBytes(), b2.toArray());
+     Assert.assertEquals(s2, b2.toString());
+ 
+     // call again to ensure that position was not changed by previous call
+     b2 = Bytes.of(bb);
+     Assert.assertArrayEquals(s2.getBytes(), b2.toArray());
+     Assert.assertEquals(s2, b2.toString());
+ 
+     String s3 = "test3";
+     Bytes b3 = Bytes.of(s3.getBytes());
+     Assert.assertArrayEquals(s3.getBytes(), b3.toArray());
+     Assert.assertEquals(s3, b3.toString());
+ 
+     String s4 = "test4";
+     byte[] d4 = s4.getBytes();
+     Bytes b4 = Bytes.of(d4, 0, d4.length);
+     Assert.assertArrayEquals(s4.getBytes(), b4.toArray());
+     Assert.assertEquals(s4, b4.toString());
+   }
+ 
+   @Test
+   public void testImmutable() {
+     byte[] d1 = Bytes.of("mydata").toArray();
+ 
+     Bytes imm = Bytes.of(d1);
+     Assert.assertNotSame(d1, imm.toArray());
+   }
+ 
+   @Test
++  public void testHashSubsequence() {
++    Bytes b1 = Bytes.of("abcde");
++    Bytes b2 = Bytes.of("cde");
++
++    Assert.assertEquals(b2.hashCode(), b1.subSequence(2, 5).hashCode());
++  }
++
++  @Test
+   public void testCompare() {
+     Bytes b1 = Bytes.of("a");
+     Bytes b2 = Bytes.of("b");
+     Bytes b3 = Bytes.of("a");
+     Assert.assertEquals(-1, b1.compareTo(b2));
+     Assert.assertEquals(1, b2.compareTo(b1));
+     Assert.assertEquals(0, b1.compareTo(b3));
+     Assert.assertEquals(1, b1.compareTo(Bytes.EMPTY));
+   }
+ 
+   @Test
+   public void testToByteBuffer() {
+     Bytes b1 = Bytes.of("fluofluo");
+     ByteBuffer buffer = b1.toByteBuffer();
+     Assert.assertFalse(buffer.hasArray());
+     Assert.assertEquals(buffer.remaining(), 8);
+ 
+     byte[] copy = new byte[8];
+     buffer.duplicate().get(copy);
+     Assert.assertEquals("fluofluo", new String(copy, StandardCharsets.UTF_8));
+ 
+     try {
+       buffer.put((byte) 6);
+       Assert.fail();
+     } catch (ReadOnlyBufferException e) {
+     }
+   }
+ 
+   @Test
+   public void testWrite() throws IOException {
+     ByteArrayOutputStream out = new ByteArrayOutputStream();
+ 
+     byte[] ba1 = "abc".getBytes(StandardCharsets.UTF_8);
+     Bytes little = Bytes.of(ba1);
+     byte[] ba2 = new byte[1024];
+     Arrays.fill(ba2, (byte) 42);
+     Bytes big = Bytes.of(ba2);
+ 
+     little.writeTo(out);
+     big.writeTo(out);
+ 
+     byte[] expected = new byte[ba1.length + ba2.length];
+     System.arraycopy(ba1, 0, expected, 0, ba1.length);
+     System.arraycopy(ba2, 0, expected, ba1.length, ba2.length);
+ 
+     Assert.assertArrayEquals(expected, out.toByteArray());
+     out.close();
+   }
+ 
+   @Test
+   public void testBounds() {
+     Bytes bytes = Bytes.of("abcdefg").subSequence(2, 5);
+     Assert.assertEquals("abcdefg".substring(2, 5), bytes.toString());
+     Assert.assertEquals('c', bytes.byteAt(0));
+     Assert.assertEquals('d', bytes.byteAt(1));
+     Assert.assertEquals('e', bytes.byteAt(2));
+ 
+     Assert.assertEquals("de", bytes.subSequence(1, 3).toString());
+ 
+     try {
+       bytes.byteAt(-1);
+       Assert.fail();
+     } catch (IndexOutOfBoundsException e) {
+     }
+ 
+     try {
+       bytes.byteAt(3);
+       Assert.fail();
+     } catch (IndexOutOfBoundsException e) {
+     }
+ 
+     try {
+       bytes.subSequence(-1, 2);
+       Assert.fail();
+     } catch (IndexOutOfBoundsException e) {
+     }
+ 
+     try {
+       bytes.subSequence(0, 5);
+       Assert.fail();
+     } catch (IndexOutOfBoundsException e) {
+     }
+ 
+     try {
+       bytes.subSequence(2, 1);
+       Assert.fail();
+     } catch (IndexOutOfBoundsException e) {
+     }
+   }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/f8d0af6e/modules/api/src/test/java/org/apache/fluo/api/data/RowColumnTest.java
----------------------------------------------------------------------
diff --cc modules/api/src/test/java/org/apache/fluo/api/data/RowColumnTest.java
index 0000000,f5b5fdb..85b5eb6
mode 000000,100644..100644
--- a/modules/api/src/test/java/org/apache/fluo/api/data/RowColumnTest.java
+++ b/modules/api/src/test/java/org/apache/fluo/api/data/RowColumnTest.java
@@@ -1,0 -1,86 +1,86 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+  * agreements. See the NOTICE file distributed with this work for additional information
regarding
+  * copyright ownership. The ASF licenses this file to you under the Apache License, Version
2.0 (the
+  * "License"); you may not use this file except in compliance with the License. You may
obtain a
+  * copy of the License at
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0
+  * 
+  * Unless required by applicable law or agreed to in writing, software distributed under
the License
+  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+  * or implied. See the License for the specific language governing permissions and limitations
under
+  * the License.
+  */
+ 
+ package org.apache.fluo.api.data;
+ 
+ import org.apache.fluo.api.data.Bytes;
+ import org.apache.fluo.api.data.Column;
+ import org.apache.fluo.api.data.RowColumn;
+ import org.junit.Assert;
+ import org.junit.Test;
+ 
+ /**
+  * Unit test for {@link RowColumn}
+  */
+ public class RowColumnTest {
+ 
+   @Test
+   public void testBasic() {
+ 
+     RowColumn rc = new RowColumn();
+     Assert.assertEquals(RowColumn.EMPTY, rc);
+     Assert.assertEquals(Bytes.EMPTY, rc.getRow());
+     Assert.assertEquals("", rc.getsRow());
+     Assert.assertEquals(Column.EMPTY, rc.getColumn());
+     Assert.assertEquals("   ", rc.toString());
+     Assert.assertNotEquals(RowColumn.EMPTY, Column.EMPTY);
+ 
+     rc = new RowColumn(Bytes.of("r1"));
+     Assert.assertEquals(Bytes.of("r1"), rc.getRow());
+     Assert.assertEquals("r1", rc.getsRow());
+     Assert.assertEquals(Column.EMPTY, rc.getColumn());
+     Assert.assertEquals(new RowColumn("r1"), rc);
+     Assert.assertEquals("r1   ", rc.toString());
+ 
+     rc = new RowColumn("r2", new Column("cf2"));
+     Assert.assertEquals(Bytes.of("r2"), rc.getRow());
+     Assert.assertEquals("r2", rc.getsRow());
+     Assert.assertEquals(new Column("cf2"), rc.getColumn());
+     Assert.assertEquals(new RowColumn(Bytes.of("r2"), new Column("cf2")), rc);
+     Assert.assertEquals("r2 cf2  ", rc.toString());
 -    Assert.assertEquals(4007699, rc.hashCode());
++    Assert.assertEquals(123316141, rc.hashCode());
+   }
+ 
+   @Test
+   public void testFollowing() {
+     byte[] fdata = new String("data1").getBytes();
+     fdata[4] = (byte) 0x00;
+     Bytes fb = Bytes.of(fdata);
+ 
+     Assert.assertEquals(RowColumn.EMPTY, new RowColumn().following());
+     Assert.assertEquals(new RowColumn(fb), new RowColumn("data").following());
+     Assert.assertEquals(new RowColumn("row", new Column(fb)), new RowColumn("row", new Column(
+         "data")).following());
+     Assert.assertEquals(new RowColumn("row", new Column(Bytes.of("cf"), fb)), new RowColumn("row",
+         new Column("cf", "data")).following());
+     Assert.assertEquals(new RowColumn("row", new Column(Bytes.of("cf"), Bytes.of("cq"),
fb)),
+         new RowColumn("row", new Column("cf", "cq", "data")).following());
+   }
+ 
+   @Test
+   public void testCompare() {
+     RowColumn rc1 = new RowColumn("a", new Column("b"));
+     RowColumn rc2 = new RowColumn("b");
+     RowColumn rc3 = new RowColumn("a", new Column("c"));
+     RowColumn rc4 = new RowColumn("a", new Column("c", "d"));
+     Assert.assertEquals(-1, rc1.compareTo(rc2));
+     Assert.assertEquals(1, rc2.compareTo(rc1));
+     Assert.assertEquals(-1, rc1.compareTo(rc3));
+     Assert.assertEquals(-1, rc3.compareTo(rc2));
+     Assert.assertEquals(0, rc3.compareTo(rc3));
+     Assert.assertEquals(1, rc2.compareTo(RowColumn.EMPTY));
+     Assert.assertEquals(-1, rc3.compareTo(rc4));
+   }
+ }


Mime
View raw message