Search in sources :

Example 96 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class BigDecimalCombinerTest method testSums.

@Test
public void testSums() throws IOException {
    ai = new BigDecimalCombiner.BigDecimalSummingCombiner();
    IteratorSetting is = new IteratorSetting(1, BigDecimalCombiner.BigDecimalSummingCombiner.class);
    Combiner.setColumns(is, columns);
    ai.init(new SortedMapIterator(tm1), is.getOptions(), CombinerTest.SCAN_IE);
    ai.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(ai.hasTop());
    assertEquals(CombinerTest.newKey(1, 1, 1, 3), ai.getTopKey());
    assertEquals(-9.7, encoder.decode(ai.getTopValue().get()).doubleValue(), delta);
    verify();
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 97 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testBothExclusive.

@Test
public void testBothExclusive() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", false, "20080204", false);
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_3));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_6));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 98 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testStartExclusiveEndInclusive.

@Test
public void testStartExclusiveEndInclusive() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", false, "20080204", true);
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_3));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_6));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_4));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 99 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testBasic.

@Test
public void testBasic() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", "20080204");
    assertTrue(columnSliceFilter.validateOptions(is.getOptions()));
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, true);
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_2));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_3));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_6));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 100 with SortedMapIterator

use of org.apache.accumulo.core.iterators.SortedMapIterator in project accumulo by apache.

the class ColumnSliceFilterTest method testNullEnd.

@Test
public void testNullEnd() throws IOException {
    ColumnSliceFilter.setSlice(is, "20080202", null);
    columnSliceFilter.validateOptions(is.getOptions());
    columnSliceFilter.init(new SortedMapIterator(TEST_DATA), is.getOptions(), iteratorEnvironment);
    columnSliceFilter.seek(new Range(), EMPTY_COL_FAMS, false);
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_2));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_3));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_6));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_4));
    columnSliceFilter.next();
    assertTrue(columnSliceFilter.hasTop());
    assertTrue(columnSliceFilter.getTopKey().equals(KEY_5));
    columnSliceFilter.next();
    assertFalse(columnSliceFilter.hasTop());
}
Also used : SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Aggregations

SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)100 Range (org.apache.accumulo.core.data.Range)86 Key (org.apache.accumulo.core.data.Key)82 Value (org.apache.accumulo.core.data.Value)82 TreeMap (java.util.TreeMap)74 Test (org.junit.Test)61 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)38 Text (org.apache.hadoop.io.Text)29 PartialKey (org.apache.accumulo.core.data.PartialKey)16 Combiner (org.apache.accumulo.core.iterators.Combiner)12 LongCombiner (org.apache.accumulo.core.iterators.LongCombiner)12 TypedValueCombiner (org.apache.accumulo.core.iterators.TypedValueCombiner)12 ArrayList (java.util.ArrayList)10 HashSet (java.util.HashSet)9 DefaultIteratorEnvironment (org.apache.accumulo.core.iterators.DefaultIteratorEnvironment)8 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)7 IOException (java.io.IOException)6 ByteSequence (org.apache.accumulo.core.data.ByteSequence)6 HashMap (java.util.HashMap)5 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)5