/** * 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; } //... }
@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); } }