Exemplo n.º 1
0
 /** Test method for {@link org.eclipse.stem.jobs.batch.BatchManager#getSequenceNumber()}. */
 @Test
 public void testGetSequenceNumber() {
   // Test that the sequence number is incremented.
   final BatchManager fixture = getFixture();
   assertTrue(fixture.getSequenceNumber() == 0);
   fixture.createBatch(ExperimentTest.createFixture());
   assertTrue(fixture.getSequenceNumber() == 1);
 } // testGetSequenceNumber
Exemplo n.º 2
0
 /**
  * Get the batch containing the given row. NOTE: the returned batch may be empty or may begin with
  * a row other than the one specified.
  *
  * @param row
  * @return
  * @throws TeiidComponentException
  *     <p>TODO: a method to get the raw batch
  */
 public TupleBatch getBatch(int row) throws TeiidComponentException {
   TupleBatch result = null;
   if (row > rowCount) {
     result = new TupleBatch(rowCount + 1, new List[] {});
   } else if (this.batchBuffer != null && row > rowCount - this.batchBuffer.size()) {
     result = new TupleBatch(rowCount - this.batchBuffer.size() + 1, batchBuffer);
     if (forwardOnly) {
       this.batchBuffer = null;
     }
   } else {
     if (this.batchBuffer != null && !this.batchBuffer.isEmpty()) {
       // this is just a sanity check to ensure we're not holding too many
       // hard references to batches.
       saveBatch(false);
     }
     Map.Entry<Integer, Long> entry = batches.floorEntry(row);
     Assertion.isNotNull(entry);
     Long batch = entry.getValue();
     List<List<?>> rows = manager.getBatch(batch, !forwardOnly);
     result = new TupleBatch(entry.getKey(), rows);
     if (isFinal && result.getEndRow() == rowCount) {
       result.setTerminationFlag(true);
     }
     if (forwardOnly) {
       batches.remove(entry.getKey());
     }
   }
   if (isFinal && result.getEndRow() == rowCount) {
     result.setTerminationFlag(true);
   }
   return result;
 }
Exemplo n.º 3
0
 void saveBatch(boolean force) throws TeiidComponentException {
   Assertion.assertTrue(!this.isRemoved());
   if (batchBuffer == null
       || batchBuffer.isEmpty()
       || (!force && batchBuffer.size() < Math.max(1, batchSize / 32))) {
     return;
   }
   Long mbatch = manager.createManagedBatch(batchBuffer, null, false);
   this.batches.put(rowCount - batchBuffer.size() + 1, mbatch);
   batchBuffer = null;
 }
Exemplo n.º 4
0
 public String[] getTypes() {
   return manager.getTypes();
 }
Exemplo n.º 5
0
 /** Test method for {@link org.eclipse.stem.jobs.batch.BatchManager#getActiveBatches()}. */
 @Test
 public void testGetBatches() {
   // This isn't much of a test.
   final BatchManager fixture = getFixture();
   assertTrue(fixture.getActiveBatches().size() == 0);
 } // testGetBatches
Exemplo n.º 6
0
 /** @return the {@link BatchManager} to be used for testing. */
 public static BatchManager createFixture() {
   BatchManager.resetBatchManager();
   return BatchManager.INSTANCE;
 } // createFixture