org.apache.commons.collections.iterators.EmptyListIterator Java Examples

The following examples show how to use org.apache.commons.collections.iterators.EmptyListIterator. 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: BulkInsertRowIndexGenerationFunction.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Iterator<Tuple2<Long,Tuple2<byte[], byte[]>>> call(ExecRow execRow) throws Exception {
    if (!initialized) {
        encoder = new PairEncoder(getKeyEncoder(), getRowHash(), dataType);
        int i = 0;
        indexTransformFunctions = new IndexTransformFunction[tentativeIndices.size()];
        for (DDLMessage.TentativeIndex index: tentativeIndices) {
            indexTransformFunctions[i] = new IndexTransformFunction(index);
            i++;
        }
        initialized = true;
    }

    try {
        ArrayList<Tuple2<Long,Tuple2<byte[], byte[]>>> list = new ArrayList();
        KVPair mainRow = encoder.encode(execRow);
        list.add(new Tuple2<>(heapConglom,new Tuple2<>(mainRow.getRowKey(), mainRow.getValue())));
        for (int i = 0; i< indexTransformFunctions.length; i++) {
            ExecRow indexRow = getIndexRow(indexTransformFunctions[i], execRow);
            indexRow.setKey(mainRow.rowKeySlice().array());
            Long indexConglomerate = indexTransformFunctions[i].getIndexConglomerateId();
            KVPair indexKVPair = indexTransformFunctions[i].call(indexRow);
            if (indexKVPair != null) // Supports Null and Default Expression Indexes
                list.add(new Tuple2<>(indexConglomerate, new Tuple2<>(indexKVPair.getRowKey(), indexKVPair.getValue())));
        }
        return list.iterator();

    } catch (Exception e) {
        if (operationContext!=null && operationContext.isPermissive()) {
            operationContext.recordBadRecord(e.getLocalizedMessage() + execRow.toString(), e);
            return EmptyListIterator.INSTANCE;
        }
        throw Exceptions.parseException(e);
    }
}
 
Example #2
Source File: ReturnEmptyListIterator.java    From levelup-java-examples with Apache License 2.0 5 votes vote down vote up
/**
 * Used for exception example
 */
@SuppressWarnings({ "unchecked", "unused" })
private void return_empty_list_iterator_apache_commons_exception () {
	
	DomainObject domain = null; // dao populate domain

	ListIterator<String> strings;
	if (domain != null && !CollectionUtils.sizeIsEmpty(domain.getStrings())) {
		strings = domain.getStrings();
	} else {
		strings = EmptyListIterator.INSTANCE;
	}

	//...
}