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) {
}
}
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);
}
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));
}
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));
}
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());
}
Aggregations