Tabnine Logo
ResultIterator.next
Code IndexAdd Tabnine to your IDE (free)

How to use
next
method
in
org.apache.phoenix.iterate.ResultIterator

Best Java code snippets using org.apache.phoenix.iterate.ResultIterator.next (Showing top 20 results out of 315)

origin: apache/phoenix

  @Override
  protected Tuple advance() throws SQLException {
    return iterator.next();
  }
};
origin: apache/phoenix

@Override
public Tuple next() throws SQLException {
  return delegate.next();
}
origin: apache/phoenix

private void init() throws SQLException {
  nextLhsTuple = lhsIterator.next();
  if (nextLhsTuple != null) {
    nextLhsKey.evaluate(nextLhsTuple);
  }
  advance(true);
  nextRhsTuple = rhsIterator.next();
  if (nextRhsTuple != null) {
    nextRhsKey.evaluate(nextRhsTuple);
  }
  advance(false);
  initialized = true;
}

origin: apache/phoenix

  private void advance(boolean lhs) throws SQLException {
    if (lhs) {
      lhsTuple = lhsIterator.next();
      if (lhsTuple != null) {
        lhsKey.evaluate(lhsTuple);
      } else {
        lhsKey.clear();
      }
    } else {
      rhsTuple = rhsIterator.next();
      if (rhsTuple != null) {
        rhsKey.evaluate(rhsTuple);
      } else {
        rhsKey.clear();
      }
    }
  }
}
origin: apache/phoenix

@Override
public Tuple next() throws SQLException {
  if (chunkComplete || lastKey == null) {
    return null;
  }
  Tuple next = delegate.next();
  if (next != null) {
    // We actually keep going past the chunk size until the row key changes. This is
    // necessary for (at least) hash joins, as they can return multiple rows with the
    // same row key. Stopping a chunk at a row key boundary is necessary in order to
    // be able to start the next chunk on the next row key
    if (rowCount == chunkSize) {
      next.getKey(lastKey);
    } else if (rowCount > chunkSize && rowKeyChanged(next)) {
      chunkComplete = true;
      return null;
    }
    rowCount++;
  } else {
    lastKey = null;
  }
  return next;
}
origin: apache/phoenix

@Override
protected Tuple advance() throws SQLException {
  Tuple next;
  do {
    next = delegate.next();
    expression.reset();
  } while (next != null && (!expression.evaluate(next, ptr) || ptr.getLength() == 0 || !Boolean.TRUE.equals(expression.getDataType().toObject(ptr))));
  return next;
}

origin: apache/phoenix

private HashMap<ImmutableBytesWritable, Aggregator[]> populateHash() throws SQLException {
  hash = new HashMap<ImmutableBytesWritable, Aggregator[]>(HASH_AGG_INIT_SIZE, 0.75f);
  final int aggSize = aggregators.getEstimatedByteSize();
  long keySize = 0;
  for (Tuple result = resultIterator.next(); result != null; result = resultIterator.next()) {
    ImmutableBytesWritable key = new ImmutableBytesWritable(UNITIALIZED_KEY_BUFFER);
    key = getGroupingKey(result, key);
    Aggregator[] rowAggregators = hash.get(key);
    if (rowAggregators == null) {
      keySize += key.getSize();
      long hashSize = SizedUtil.sizeOfMap(hash.size() + 1, SizedUtil.IMMUTABLE_BYTES_WRITABLE_SIZE, aggSize) + keySize;
      if (hashSize > memoryChunk.getSize() + CLIENT_HASH_AGG_MEMORY_CHUNK_SIZE) {
        // This will throw InsufficientMemoryException if necessary
        memoryChunk.resize(hashSize + CLIENT_HASH_AGG_MEMORY_CHUNK_SIZE);
      }
      rowAggregators = aggregators.newAggregators();
      hash.put(key, rowAggregators);
    }
    aggregators.aggregate(rowAggregators, result);
  }
  return hash;
}
origin: apache/phoenix

public static void assertResults(ResultIterator scanner, AssertingIterator iterator) throws Exception {
  try {
    for (Tuple result = scanner.next(); result != null; result = scanner.next()) {
      iterator.assertNext(result);
    }
    iterator.assertDone();
  } finally {
    scanner.close();
  }
}

origin: apache/phoenix

private void advance(boolean lhs) throws SQLException {
  if (lhs) {
    lhsTuple = nextLhsTuple;
    lhsKey.set(nextLhsKey);
    if (lhsTuple != null) {
      nextLhsTuple = lhsIterator.next();
      if (nextLhsTuple != null) {
        nextLhsKey.evaluate(nextLhsTuple);
      } else {
        nextLhsKey.clear();
      }
    }
  } else {
    rhsTuple = nextRhsTuple;
    rhsKey.set(nextRhsKey);
    if (rhsTuple != null) {
      nextRhsTuple = rhsIterator.next();
      if (nextRhsTuple != null) {
        nextRhsKey.evaluate(nextRhsTuple);
      } else {
        nextRhsKey.clear();
      }
    }                    
  }
}

origin: apache/phoenix

@Override
public Tuple next() throws SQLException {
 while (true) {
  if (!initSnapshotScanner())
   return null;
  try {
   lastTuple = scanIterator.next();
   if (lastTuple != null) {
    ImmutableBytesWritable ptr = new ImmutableBytesWritable();
    lastTuple.getKey(ptr);
    return lastTuple;
   }
  } finally {
   if (lastTuple == null) {
    scanIterator.close();
    scanIterator = UNINITIALIZED_SCANNER;
   }
  }
 }
}
origin: apache/phoenix

rhsCurrent = rhsIter.next();
if (rhsCurrent == null) {
  rhsIter.close();
current = iter.next();
if (current == null) {
  close();
rhsCurrent = rhsIter.next();
if ((rhsCurrent == null && (joinType == JoinType.Inner || joinType == JoinType.Semi))
    || (rhsCurrent != null && joinType == JoinType.Anti)) {
origin: apache/phoenix

int rowCount = 0;
PDataType baseType = PVarbinary.INSTANCE;
for (Tuple tuple = iterator.next(); tuple != null; tuple = iterator.next()) {
  if (expectSingleRow && rowCount >= 1)
    throw new SQLExceptionInfo.Builder(SQLExceptionCode.SINGLE_ROW_SUBQUERY_RETURNS_MULTIPLE_ROWS).build().buildException();
origin: apache/phoenix

@Override
public MutationState execute() throws SQLException {
  connection.getMutationState().commitDDLFence(dataTable);
  Tuple tuple = plan.iterator().next();
  long rowCount = 0;
  if (tuple != null) {
    Cell kv = tuple.getValue(0);
    ImmutableBytesWritable tmpPtr = new ImmutableBytesWritable(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength());
    // A single Cell will be returned with the count(*) - we decode that here
    rowCount = PLong.INSTANCE.getCodec().decodeLong(tmpPtr, SortOrder.getDefault());
  }
  // The contract is to return a MutationState that contains the number of rows modified. In this
  // case, it's the number of rows in the data table which corresponds to the number of index
  // rows that were added.
  return new MutationState(0, 0, connection, rowCount);
}
origin: apache/phoenix

private void testLiteralResultIteratorPlan(Object[][] expectedResult, Integer offset, Integer limit)
    throws SQLException {
  QueryPlan plan = newLiteralResultIterationPlan(offset, limit);
  ResultIterator iter = plan.iterator();
  ImmutableBytesWritable ptr = new ImmutableBytesWritable();
  for (Object[] row : expectedResult) {
    Tuple next = iter.next();
    assertNotNull(next);
    for (int i = 0; i < row.length; i++) {
      PColumn column = table.getColumns().get(i);
      boolean eval = new ProjectedColumnExpression(column, table, column.getName().getString()).evaluate(next,
          ptr);
      Object o = eval ? column.getDataType().toObject(ptr) : null;
      assertEquals(row[i], o);
    }
  }
  assertNull(iter.next());
}
origin: apache/phoenix

  parallelIteratorFactory.setProjectedTableRef(projectedTableRef);
while ((tuple=iterator.next()) != null) {// Runs query
  Cell kv = tuple.getValue(0);
  totalRowCount += PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(), kv.getValueOffset(), SortOrder.getDefault());
origin: apache/phoenix

long totalRowCount = 0;
StatementContext context = queryPlan.getContext();
while ((tuple=iterator.next()) != null) {// Runs query
  Cell kv = tuple.getValue(0);
  totalRowCount += PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(), kv.getValueOffset(), SortOrder.getDefault());
origin: apache/phoenix

Tuple row = iterator.next();
final long mutationCount = (Long) aggProjector.getColumnProjector(0).getValue(row,
    PLong.INSTANCE, ptr);
origin: apache/phoenix

ResultIterator iterator = plan.iterator();
for (Object[] o : flatten(arrays)) {
  Tuple tuple = iterator.next();
  assertNotNull(tuple);
  assertTrue(elemExpr.evaluate(tuple, ptr));
assertNull(iterator.next());
origin: apache/phoenix

Tuple row = iterator.next();
final long mutationCount = (Long) projector.getColumnProjector(0).getValue(row, PLong.INSTANCE, ptr);
return new MutationState(maxSize, maxSizeBytes, connection) {
origin: apache/phoenix

private void testCorrelatePlan(Object[][] leftRelation, Object[][] rightRelation, int leftCorrelColumn,
    int rightCorrelColumn, JoinType type, Object[][] expectedResult, Integer offset) throws SQLException {
  TableRef leftTable = createProjectedTableFromLiterals(leftRelation[0]);
  TableRef rightTable = createProjectedTableFromLiterals(rightRelation[0]);
  String varName = "$cor0";
  RuntimeContext runtimeContext = new RuntimeContextImpl();
  runtimeContext.defineCorrelateVariable(varName, leftTable);
  QueryPlan leftPlan = newLiteralResultIterationPlan(leftRelation, offset);
  QueryPlan rightPlan = newLiteralResultIterationPlan(rightRelation, offset);
  Expression columnExpr = new ColumnRef(rightTable, rightCorrelColumn).newColumnExpression();
  Expression fieldAccess = new CorrelateVariableFieldAccessExpression(runtimeContext, varName, new ColumnRef(leftTable, leftCorrelColumn).newColumnExpression());
  Expression filter = ComparisonExpression.create(CompareOp.EQUAL, Arrays.asList(columnExpr, fieldAccess), CONTEXT.getTempPtr(), false);
  rightPlan = new ClientScanPlan(CONTEXT, SelectStatement.SELECT_ONE, rightTable, RowProjector.EMPTY_PROJECTOR,
      null, null, filter, OrderBy.EMPTY_ORDER_BY, rightPlan);
  PTable joinedTable = JoinCompiler.joinProjectedTables(leftTable.getTable(), rightTable.getTable(), type);
  CorrelatePlan correlatePlan = new CorrelatePlan(leftPlan, rightPlan, varName, type, false, runtimeContext, joinedTable, leftTable.getTable(), rightTable.getTable(), leftTable.getTable().getColumns().size());
  ResultIterator iter = correlatePlan.iterator();
  ImmutableBytesWritable ptr = new ImmutableBytesWritable();
  for (Object[] row : expectedResult) {
    Tuple next = iter.next();
    assertNotNull(next);
    for (int i = 0; i < row.length; i++) {
      PColumn column = joinedTable.getColumns().get(i);
      boolean eval = new ProjectedColumnExpression(column, joinedTable, column.getName().getString()).evaluate(next, ptr);
      Object o = eval ? column.getDataType().toObject(ptr) : null;
      assertEquals(row[i], o);
    }
  }
}
org.apache.phoenix.iterateResultIteratornext

Javadoc

Grab the next row's worth of values. The iterator will return a Tuple.

Popular methods of ResultIterator

  • close
  • explain

Popular in Java

  • Start an intent from android
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now