Search in sources :

Example 16 with EncodedColumnQualiferCellsList

use of org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList in project phoenix by apache.

the class EncodedColumnQualifierCellsListTest method testAddAllAtIndexFails.

@Test
public void testAddAllAtIndexFails() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list);
    try {
        list.addAll(0, new ArrayList<Cell>());
    } catch (UnsupportedOperationException expected) {
    }
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 17 with EncodedColumnQualiferCellsList

use of org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList in project phoenix by apache.

the class EncodedColumnQualifierCellsListTest method testListIteratorNextAndPrevious.

@Test
public void testListIteratorNextAndPrevious() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    Cell[] array = new Cell[7];
    populateListAndArray(list, array);
    ListIterator<Cell> itr = list.listIterator();
    try {
        itr.previous();
        fail("Call to itr.previous() should have failed since the iterator hasn't been moved forward yet");
    } catch (NoSuchElementException expected) {
    }
    Cell c = itr.next();
    Cell d = itr.previous();
    Cell e = itr.next();
    Cell f = itr.previous();
    assertTrue(c.equals(d) && c.equals(f) && c.equals(e));
    itr = list.listIterator();
    int i = 0;
    assertEquals(array[i++], itr.next());
    assertEquals(array[i++], itr.next());
    assertEquals(array[i++], itr.next());
    assertEquals(array[--i], itr.previous());
    assertEquals(array[--i], itr.previous());
    assertEquals(array[i++], itr.next());
    // move itr forward till next() is exhausted
    while (itr.hasNext()) {
        itr.next();
    }
    i = 6;
    while (itr.hasPrevious()) {
        assertEquals(array[i--], itr.previous());
    }
    assertEquals("Not all elements navigated using previous()", -1, i);
    // now that previous is exhausted, move itr() forward till next() is exhausted
    i = 0;
    while (itr.hasNext()) {
        assertEquals(array[i++], itr.next());
    }
    assertEquals("Not all elements navigated using next()", 7, i);
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Cell(org.apache.hadoop.hbase.Cell) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Example 18 with EncodedColumnQualiferCellsList

use of org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList in project phoenix by apache.

the class EncodedColumnQualifierCellsListTest method testContainsAll.

@Test
public void testContainsAll() throws Exception {
    EncodedColumnQualiferCellsList list1 = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list1);
    EncodedColumnQualiferCellsList list2 = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list2);
    assertTrue(list1.containsAll(list2));
    list2.remove(KeyValue.createFirstOnRow(row, cf, FOUR_BYTE_QUALIFIERS.encode(11)));
    assertTrue(list1.containsAll(list2));
    assertFalse(list2.containsAll(list1));
    list2.add(KeyValue.createFirstOnRow(row, cf, FOUR_BYTE_QUALIFIERS.encode(13)));
    assertFalse(list1.containsAll(list2));
    assertFalse(list2.containsAll(list1));
    List<Cell> arrayList = new ArrayList<>();
    populateList(arrayList);
    assertTrue(list1.containsAll(arrayList));
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) ArrayList(java.util.ArrayList) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 19 with EncodedColumnQualiferCellsList

use of org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList in project phoenix by apache.

the class EncodedColumnQualifierCellsListTest method testToArrayWithParam.

@Test
public void testToArrayWithParam() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    Cell[] cells = new Cell[7];
    populateListAndArray(list, cells);
    Cell[] array = list.toArray(new Cell[0]);
    assertTrue(Arrays.equals(cells, array));
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 20 with EncodedColumnQualiferCellsList

use of org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList in project phoenix by apache.

the class EncodedColumnQualifierCellsListTest method testClear.

@Test
public void testClear() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list);
    list.clear();
    assertTrue(list.isEmpty());
    assertEquals(0, list.size());
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Test(org.junit.Test)

Aggregations

EncodedColumnQualiferCellsList (org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList)26 Test (org.junit.Test)22 Cell (org.apache.hadoop.hbase.Cell)21 ArrayList (java.util.ArrayList)4 MultiKeyValueTuple (org.apache.phoenix.schema.tuple.MultiKeyValueTuple)4 PositionBasedMultiKeyValueTuple (org.apache.phoenix.schema.tuple.PositionBasedMultiKeyValueTuple)4 Tuple (org.apache.phoenix.schema.tuple.Tuple)4 Iterator (java.util.Iterator)3 ListIterator (java.util.ListIterator)3 Region (org.apache.hadoop.hbase.regionserver.Region)3 Aggregator (org.apache.phoenix.expression.aggregator.Aggregator)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 List (java.util.List)2 Configuration (org.apache.hadoop.conf.Configuration)2 KeyValue (org.apache.hadoop.hbase.KeyValue)2 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)2 RegionScanner (org.apache.hadoop.hbase.regionserver.RegionScanner)2 ImmutableBytesPtr (org.apache.phoenix.hbase.index.util.ImmutableBytesPtr)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1