2 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.tie;
20 import java.util.List;
22 import com.mysql.clusterj.core.store.Column;
24 import com.mysql.clusterj.core.util.I18NHelper;
25 import com.mysql.clusterj.core.util.Logger;
26 import com.mysql.clusterj.core.util.LoggerFactoryService;
27 import com.mysql.clusterj.tie.DbImpl.BufferManager;
29 import com.mysql.ndbjtie.ndbapi.NdbScanOperation;
34 class ScanResultDataImpl extends ResultDataImpl {
36 /** My message translator */
37 static final I18NHelper local = I18NHelper
38 .getInstance(ScanResultDataImpl.class);
41 static final Logger logger = LoggerFactoryService.getFactory()
42 .getInstance(ScanResultDataImpl.class);
44 private NdbScanOperation ndbScanOperation = null;
47 /** Flags for iterating a scan */
48 protected final int RESULT_READY = 0;
49 protected final int SCAN_FINISHED = 1;
50 protected final int CACHE_EMPTY = 2;
52 public ScanResultDataImpl(NdbScanOperation ndbScanOperation, List<Column> storeColumns,
53 int maximumColumnId, int bufferSize, int[] offsets, int[] lengths, int maximumColumnLength,
54 BufferManager bufferManager) {
55 super(ndbScanOperation, storeColumns, maximumColumnId, bufferSize, offsets, lengths,
56 bufferManager, false);
57 this.ndbScanOperation = ndbScanOperation;
61 public boolean next() {
62 // NdbScanOperation may have many results.
64 boolean fetch = false;
65 boolean force = true; // always true for scans
67 int result = ndbScanOperation.nextResult(fetch, force);
72 ndbScanOperation.close(true, true);
78 Utility.throwError(result, ndbScanOperation.getNdbError());
81 return true; // this statement is needed to make the compiler happy but it's never executed