Search in sources :

Example 6 with EncodedColumnQualiferCellsList

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

the class EncodedColumnQualifierCellsListTest method testGetIndex.

@Test
public void testGetIndex() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    Cell[] cells = new Cell[7];
    populateListAndArray(list, cells);
    for (int i = 0; i < cells.length; i++) {
        assertEquals(cells[i], list.get(i));
    }
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 7 with EncodedColumnQualiferCellsList

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

the class EncodedColumnQualifierCellsListTest method testSize.

@Test
public void testSize() {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    assertEquals(0, list.size());
    populateList(list);
    assertEquals(7, list.size());
    int originalSize = list.size();
    Iterator itr = list.iterator();
    while (itr.hasNext()) {
        itr.next();
        itr.remove();
        assertEquals(--originalSize, list.size());
    }
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) Test(org.junit.Test)

Example 8 with EncodedColumnQualiferCellsList

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

the class EncodedColumnQualifierCellsListTest method testFailFastIterator.

@Test
public void testFailFastIterator() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list);
    int i = 0;
    Iterator<Cell> itr = list.iterator();
    while (itr.hasNext()) {
        i++;
        try {
            itr.next();
            list.add(KeyValue.createFirstOnRow(row, cf, FOUR_BYTE_QUALIFIERS.encode(0)));
            if (i == 2) {
                fail("ConcurrentModificationException should have been thrown as the list is being modified while being iterated through");
            }
        } catch (ConcurrentModificationException expected) {
            assertEquals("Exception should have been thrown when getting the second element", 2, i);
            break;
        }
    }
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) ConcurrentModificationException(java.util.ConcurrentModificationException) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 9 with EncodedColumnQualiferCellsList

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

the class EncodedColumnQualifierCellsListTest method testToArrayWithoutParam.

@Test
public void testToArrayWithoutParam() throws Exception {
    EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    Cell[] cells = new Cell[7];
    populateListAndArray(list, cells);
    Object[] array = list.toArray();
    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 10 with EncodedColumnQualiferCellsList

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

the class EncodedColumnQualifierCellsListTest method testRetainAll.

@Test
public void testRetainAll() throws Exception {
    EncodedColumnQualiferCellsList list1 = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list1);
    EncodedColumnQualiferCellsList list2 = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS);
    populateList(list2);
    // retainAll won't be modifying the list1 since they both have the same elements equality wise
    assertFalse(list1.retainAll(list2));
    list2.remove(KeyValue.createFirstOnRow(row, cf, FOUR_BYTE_QUALIFIERS.encode(12)));
    assertTrue(list1.retainAll(list2));
    assertEquals(list1.size(), list2.size());
    for (Cell c : list1) {
        assertTrue(list2.contains(c));
    }
}
Also used : EncodedColumnQualiferCellsList(org.apache.phoenix.schema.tuple.EncodedColumnQualiferCellsList) Cell(org.apache.hadoop.hbase.Cell) 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