Java Code Examples for org.apache.accumulo.core.data.ColumnUpdate#getValue()
The following examples show how to use
org.apache.accumulo.core.data.ColumnUpdate#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAccumuloStorage.java From spork with Apache License 2.0 | 4 votes |
@Test public void testWriteMultipleColumnsWithExpandedMap() throws IOException, ParseException { AccumuloStorage storage = new AccumuloStorage("col1,col2:"); Map<String, Object> map = Maps.newHashMap(); map.put("mapcol1", "mapval1"); map.put("mapcol2", "mapval2"); map.put("mapcol3", "mapval3"); map.put("mapcol4", "mapval4"); Tuple t = TupleFactory.getInstance().newTuple(3); t.set(0, "row"); t.set(1, "value1"); t.set(2, map); Collection<Mutation> mutations = storage.getMutations(t); Assert.assertEquals(1, mutations.size()); Mutation m = mutations.iterator().next(); Assert.assertTrue("Rows not equal", Arrays.equals(m.getRow(), ((String) t.get(0)).getBytes())); List<ColumnUpdate> colUpdates = m.getUpdates(); Assert.assertEquals(5, colUpdates.size()); ColumnUpdate update = colUpdates.get(0); Assert.assertEquals("col1", new String(update.getColumnFamily())); Assert.assertEquals("", new String(update.getColumnQualifier())); Assert.assertEquals("value1", new String(update.getValue())); Map<Entry<String, String>, String> expectations = Maps.newHashMap(); expectations.put(Maps.immutableEntry("col2", "mapcol1"), "mapval1"); expectations.put(Maps.immutableEntry("col2", "mapcol2"), "mapval2"); expectations.put(Maps.immutableEntry("col2", "mapcol3"), "mapval3"); expectations.put(Maps.immutableEntry("col2", "mapcol4"), "mapval4"); for (int i = 1; i < 5; i++) { update = colUpdates.get(i); Entry<String, String> key = Maps.immutableEntry( new String(update.getColumnFamily()), new String(update.getColumnQualifier())); String value = new String(update.getValue()); Assert.assertTrue("Did not find expected key: " + key, expectations.containsKey(key)); String actual = expectations.remove(key); Assert.assertEquals(value, actual); } Assert.assertTrue("Did not find all expectations", expectations.isEmpty()); }
Example 2
Source File: TestAccumuloStorage.java From spork with Apache License 2.0 | 4 votes |
@Test public void testWriteMapWithColFamWithColon() throws IOException, ParseException { AccumuloStorage storage = new AccumuloStorage("col:"); Map<String, Object> map = Maps.newHashMap(); map.put("mapcol1", "mapval1"); map.put("mapcol2", "mapval2"); map.put("mapcol3", "mapval3"); map.put("mapcol4", "mapval4"); Tuple t = TupleFactory.getInstance().newTuple(2); t.set(0, "row"); t.set(1, map); Collection<Mutation> mutations = storage.getMutations(t); Assert.assertEquals(1, mutations.size()); Mutation m = mutations.iterator().next(); Assert.assertTrue("Rows not equal", Arrays.equals(m.getRow(), ((String) t.get(0)).getBytes())); List<ColumnUpdate> colUpdates = m.getUpdates(); Assert.assertEquals(4, colUpdates.size()); Map<Entry<String, String>, String> expectations = Maps.newHashMap(); expectations.put(Maps.immutableEntry("col", "mapcol1"), "mapval1"); expectations.put(Maps.immutableEntry("col", "mapcol2"), "mapval2"); expectations.put(Maps.immutableEntry("col", "mapcol3"), "mapval3"); expectations.put(Maps.immutableEntry("col", "mapcol4"), "mapval4"); for (ColumnUpdate update : colUpdates) { Entry<String, String> key = Maps.immutableEntry( new String(update.getColumnFamily()), new String(update.getColumnQualifier())); String value = new String(update.getValue()); Assert.assertTrue("Did not find expected key: " + key, expectations.containsKey(key)); String actual = expectations.remove(key); Assert.assertEquals(value, actual); } Assert.assertTrue("Did not find all expectations", expectations.isEmpty()); }
Example 3
Source File: TestAccumuloStorage.java From spork with Apache License 2.0 | 4 votes |
@Test public void testWriteMapWithColFamWithColonAsterisk() throws IOException, ParseException { AccumuloStorage storage = new AccumuloStorage("col:*"); Map<String, Object> map = Maps.newHashMap(); map.put("mapcol1", "mapval1"); map.put("mapcol2", "mapval2"); map.put("mapcol3", "mapval3"); map.put("mapcol4", "mapval4"); Tuple t = TupleFactory.getInstance().newTuple(2); t.set(0, "row"); t.set(1, map); Collection<Mutation> mutations = storage.getMutations(t); Assert.assertEquals(1, mutations.size()); Mutation m = mutations.iterator().next(); Assert.assertTrue("Rows not equal", Arrays.equals(m.getRow(), ((String) t.get(0)).getBytes())); List<ColumnUpdate> colUpdates = m.getUpdates(); Assert.assertEquals(4, colUpdates.size()); Map<Entry<String, String>, String> expectations = Maps.newHashMap(); expectations.put(Maps.immutableEntry("col", "mapcol1"), "mapval1"); expectations.put(Maps.immutableEntry("col", "mapcol2"), "mapval2"); expectations.put(Maps.immutableEntry("col", "mapcol3"), "mapval3"); expectations.put(Maps.immutableEntry("col", "mapcol4"), "mapval4"); for (ColumnUpdate update : colUpdates) { Entry<String, String> key = Maps.immutableEntry( new String(update.getColumnFamily()), new String(update.getColumnQualifier())); String value = new String(update.getValue()); Assert.assertTrue("Did not find expected key: " + key, expectations.containsKey(key)); String actual = expectations.remove(key); Assert.assertEquals(value, actual); } Assert.assertTrue("Did not find all expectations", expectations.isEmpty()); }
Example 4
Source File: TestAccumuloStorage.java From spork with Apache License 2.0 | 4 votes |
@Test public void testWriteMapWithColFamColQualPrefix() throws IOException, ParseException { AccumuloStorage storage = new AccumuloStorage("col:qual_*"); Map<String, Object> map = Maps.newHashMap(); map.put("mapcol1", "mapval1"); map.put("mapcol2", "mapval2"); map.put("mapcol3", "mapval3"); map.put("mapcol4", "mapval4"); Tuple t = TupleFactory.getInstance().newTuple(2); t.set(0, "row"); t.set(1, map); Collection<Mutation> mutations = storage.getMutations(t); Assert.assertEquals(1, mutations.size()); Mutation m = mutations.iterator().next(); Assert.assertTrue("Rows not equal", Arrays.equals(m.getRow(), ((String) t.get(0)).getBytes())); List<ColumnUpdate> colUpdates = m.getUpdates(); Assert.assertEquals(4, colUpdates.size()); Map<Entry<String, String>, String> expectations = Maps.newHashMap(); expectations.put(Maps.immutableEntry("col", "qual_mapcol1"), "mapval1"); expectations.put(Maps.immutableEntry("col", "qual_mapcol2"), "mapval2"); expectations.put(Maps.immutableEntry("col", "qual_mapcol3"), "mapval3"); expectations.put(Maps.immutableEntry("col", "qual_mapcol4"), "mapval4"); for (ColumnUpdate update : colUpdates) { Entry<String, String> key = Maps.immutableEntry( new String(update.getColumnFamily()), new String(update.getColumnQualifier())); String value = new String(update.getValue()); Assert.assertTrue(expectations.containsKey(key)); String actual = expectations.remove(key); Assert.assertEquals(value, actual); } Assert.assertTrue("Did not find all expectations", expectations.isEmpty()); }