Java Code Examples for org.apache.geode.cache.query.SelectResults#iterator()
The following examples show how to use
org.apache.geode.cache.query.SelectResults#iterator() .
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: GeodeEnumerator.java From calcite with Apache License 2.0 | 5 votes |
/** * Creates a GeodeEnumerator. * * @param results Geode result set ({@link SelectResults}) * @param protoRowType The type of resulting rows */ GeodeEnumerator(SelectResults results, RelProtoDataType protoRowType) { if (results == null) { LOGGER.warn("Null OQL results!"); } this.iterator = (results == null) ? Collections.emptyIterator() : results.iterator(); this.current = null; final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); this.fieldTypes = protoRowType.apply(typeFactory).getFieldList(); }
Example 2
Source File: GeodeOqlInterpreter.java From zeppelin with Apache License 2.0 | 4 votes |
private InterpreterResult executeOql(String oql) { try { if (getExceptionOnConnect() != null) { return new InterpreterResult(Code.ERROR, getExceptionOnConnect().getMessage()); } @SuppressWarnings("unchecked") SelectResults<Object> results = (SelectResults<Object>) getQueryService().newQuery(oql).execute(); StringBuilder msg = new StringBuilder(TABLE_MAGIC_TAG); boolean isTableHeaderSet = false; Iterator<Object> iterator = results.iterator(); int rowDisplayCount = 0; while (iterator.hasNext() && (rowDisplayCount < getMaxResult())) { Object entry = iterator.next(); rowDisplayCount++; if (entry instanceof Number) { handleNumberEntry(isTableHeaderSet, entry, msg); } else if (entry instanceof Struct) { handleStructEntry(isTableHeaderSet, entry, msg); } else if (entry instanceof PdxInstance) { handlePdxInstanceEntry(isTableHeaderSet, entry, msg); } else { handleUnsupportedTypeEntry(isTableHeaderSet, entry, msg); } isTableHeaderSet = true; msg.append(NEWLINE); } return new InterpreterResult(Code.SUCCESS, msg.toString()); } catch (Exception ex) { logger.error("Cannot run " + oql, ex); return new InterpreterResult(Code.ERROR, ex.getMessage()); } }