Adding fields in Thrift to allow for easier paging through Rows on fetch.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/b220118d Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/b220118d Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/b220118d Branch: refs/heads/master Commit: b220118d6e7eb0eab847fe33cef27ae55427771e Parents: ae1f96c Author: Aaron McCurry <[email protected]> Authored: Mon Jan 13 12:52:09 2014 -0500 Committer: Aaron McCurry <[email protected]> Committed: Wed Jan 15 17:02:19 2014 -0500 ---------------------------------------------------------------------- .../org/apache/blur/manager/IndexManager.java | 6 +- .../blur/manager/writer/MutatableAction.java | 26 +- .../java/org/apache/blur/utils/BlurUtil.java | 14 +- .../apache/blur/manager/IndexManagerTest.java | 9 + .../org/apache/blur/utils/BlurUtilsTest.java | 15 +- .../org/apache/blur/mapreduce/BlurReducer.java | 7 +- .../blur/thrift/generated/FetchRowResult.java | 336 ++++++++++++- .../blur/thrift/generated/SafeClientGen.java | 472 +++++++++---------- .../apache/blur/thrift/generated/Selector.java | 8 +- .../blur/thrift/util/GenerateSafeClient.java | 16 + .../src/main/scripts/interface/Blur.thrift | 16 +- .../main/scripts/interface/gen-html/Blur.html | 8 +- .../blur/thrift/generated/FetchRowResult.java | 336 ++++++++++++- .../apache/blur/thrift/generated/Selector.java | 8 +- .../main/scripts/interface/gen-js/Blur_types.js | 49 +- .../scripts/interface/gen-perl/Blur/Types.pm | 47 +- .../main/scripts/interface/gen-rb/blur_types.rb | 13 +- docs/Blur.html | 8 +- 18 files changed, 1118 insertions(+), 276 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java index 15ca93c..2d49a61 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java +++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java @@ -689,6 +689,7 @@ public class IndexManager { fetchResult.rowResult.row = new Row(rowId, null, recordCount); } else { List<Document> docs; + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); if (highlightQuery != null && fieldManager != null) { String rowId = selector.getRowId(); if (rowId == null) { @@ -705,11 +706,12 @@ public class IndexManager { } else { Tracer docTrace = Trace.trace("fetchRow - Document read"); docs = BlurUtil.fetchDocuments(reader, fieldVisitor, selector, maxHeap, table + "/" + shard, - tableContext.getDefaultPrimeDocTerm(), filter); + tableContext.getDefaultPrimeDocTerm(), filter, moreDocsToFetch); docTrace.done(); } Tracer rowTrace = Trace.trace("fetchRow - Row create"); - fetchResult.rowResult = new FetchRowResult(getRow(docs)); + fetchResult.rowResult = new FetchRowResult(getRow(docs), selector.getStartRecord(), + selector.getMaxRecordsToFetch(), moreDocsToFetch.get()); rowTrace.done(); } return; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java b/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java index b8dc858..4e91c1c 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java +++ b/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.blur.analysis.FieldManager; import org.apache.blur.manager.IndexManager; @@ -111,9 +112,12 @@ public class MutatableAction { selector.setMaxRecordsToFetch(Integer.MAX_VALUE); selector.setLocationId(_shard + "/" + topDocs.scoreDocs[0].doc); ResetableDocumentStoredFieldVisitor fieldVisitor = IndexManager.getFieldSelector(selector); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = new ArrayList<Document>(BlurUtil.fetchDocuments(reader, fieldVisitor, selector, - _maxHeap, _table + "/" + _shard, _primeDocTerm, null)); - + _maxHeap, _table + "/" + _shard, _primeDocTerm, null, moreDocsToFetch)); + if (moreDocsToFetch.get()) { + throw new IOException("Row too large to update."); + } boolean found = false; for (int i = 0; i < docs.size(); i++) { Document document = docs.get(i); @@ -161,8 +165,12 @@ public class MutatableAction { selector.setMaxRecordsToFetch(Integer.MAX_VALUE); selector.setLocationId(_shard + "/" + topDocs.scoreDocs[0].doc); ResetableDocumentStoredFieldVisitor fieldVisitor = IndexManager.getFieldSelector(selector); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = new ArrayList<Document>(BlurUtil.fetchDocuments(reader, fieldVisitor, selector, - _maxHeap, _table + "/" + _shard, _primeDocTerm, null)); + _maxHeap, _table + "/" + _shard, _primeDocTerm, null, moreDocsToFetch)); + if (moreDocsToFetch.get()) { + throw new IOException("Row too large to update."); + } List<Field> doc = RowDocumentUtil.getDoc(_fieldManager, rowId, record); for (int i = 0; i < docs.size(); i++) { @@ -215,8 +223,12 @@ public class MutatableAction { selector.setMaxRecordsToFetch(Integer.MAX_VALUE); selector.setLocationId(_shard + "/" + topDocs.scoreDocs[0].doc); ResetableDocumentStoredFieldVisitor fieldVisitor = IndexManager.getFieldSelector(selector); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = new ArrayList<Document>(BlurUtil.fetchDocuments(reader, fieldVisitor, selector, - _maxHeap, _table + "/" + _shard, _primeDocTerm, null)); + _maxHeap, _table + "/" + _shard, _primeDocTerm, null, moreDocsToFetch)); + if (moreDocsToFetch.get()) { + throw new IOException("Row too large to update."); + } BlurThriftRecord existingRecord = new BlurThriftRecord(); for (int i = 0; i < docs.size(); i++) { Document document = docs.get(i); @@ -281,8 +293,12 @@ public class MutatableAction { selector.setMaxRecordsToFetch(Integer.MAX_VALUE); selector.setLocationId(_shard + "/" + topDocs.scoreDocs[0].doc); ResetableDocumentStoredFieldVisitor fieldVisitor = IndexManager.getFieldSelector(selector); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = new ArrayList<Document>(BlurUtil.fetchDocuments(reader, fieldVisitor, selector, - _maxHeap, _table + "/" + _shard, _primeDocTerm, null)); + _maxHeap, _table + "/" + _shard, _primeDocTerm, null, moreDocsToFetch)); + if (moreDocsToFetch.get()) { + throw new IOException("Row too large to update."); + } BlurThriftRecord existingRecord = new BlurThriftRecord(); for (int i = 0; i < docs.size(); i++) { Document document = docs.get(i); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java index 1c521df..87d5b4f 100644 --- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java +++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java @@ -55,6 +55,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLongArray; import java.util.regex.Pattern; @@ -777,7 +778,8 @@ public class BlurUtil { */ @SuppressWarnings("unchecked") public static List<Document> fetchDocuments(IndexReader reader, ResetableDocumentStoredFieldVisitor fieldSelector, - Selector selector, int maxHeap, String context, Term primeDocTerm, Filter filter) throws IOException { + Selector selector, int maxHeap, String context, Term primeDocTerm, Filter filter, AtomicBoolean moreToFetch) + throws IOException { if (reader instanceof BaseCompositeReader) { BaseCompositeReader<IndexReader> indexReader = (BaseCompositeReader<IndexReader>) reader; List<? extends IndexReader> sequentialSubReaders = BaseCompositeReaderUtil.getSequentialSubReaders(indexReader); @@ -816,8 +818,9 @@ public class BlurUtil { } int totalHeap = 0; Tracer trace2 = Trace.trace("fetching docs from index"); + int cursor = 0; try { - for (int i = startingPosition; i < numberOfDocsInRow; i++) { + for (cursor = startingPosition; cursor < numberOfDocsInRow; cursor++) { if (maxDocsToFetch <= 0) { return docs; } @@ -826,15 +829,18 @@ public class BlurUtil { totalHeap, maxHeap, context, selector); return docs; } - if (docsInRowSpanToFetch.fastGet(i)) { + if (docsInRowSpanToFetch.fastGet(cursor)) { maxDocsToFetch--; - segmentReader.document(primeDocId + i, fieldSelector); + segmentReader.document(primeDocId + cursor, fieldSelector); docs.add(fieldSelector.getDocument()); totalHeap += fieldSelector.getSize(); fieldSelector.reset(); } } } finally { + if (docsInRowSpanToFetch.nextSetBit(cursor) != -1) { + moreToFetch.set(true); + } trace2.done(); } return orderDocsBasedOnFamilyOrder(docs, selector); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java index b44a26b..3ae25f7 100644 --- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java +++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java @@ -671,6 +671,9 @@ public class IndexManagerTest { fetchResult = new FetchResult(); indexManager.fetchRow(TABLE, selector, fetchResult); assertNotNull(fetchResult.rowResult.row); + assertTrue(fetchResult.rowResult.moreRecordsToFetch); + assertEquals(0, fetchResult.rowResult.startRecord); + assertEquals(1, fetchResult.rowResult.maxRecordsToFetch); Row row1 = newRow("row-6", newRecord(FAMILY, "record-6A", newColumn("testcol12", "value110"), newColumn("testcol13", "value102"))); @@ -681,6 +684,9 @@ public class IndexManagerTest { fetchResult = new FetchResult(); indexManager.fetchRow(TABLE, selector, fetchResult); assertNotNull(fetchResult.rowResult.row); + assertTrue(fetchResult.rowResult.moreRecordsToFetch); + assertEquals(1, fetchResult.rowResult.startRecord); + assertEquals(1, fetchResult.rowResult.maxRecordsToFetch); Row row2 = newRow("row-6", newRecord(FAMILY, "record-6B", newColumn("testcol12", "value101"), newColumn("testcol13", "value104"))); @@ -691,6 +697,9 @@ public class IndexManagerTest { fetchResult = new FetchResult(); indexManager.fetchRow(TABLE, selector, fetchResult); assertNotNull(fetchResult.rowResult.row); + assertFalse(fetchResult.rowResult.moreRecordsToFetch); + assertEquals(2, fetchResult.rowResult.startRecord); + assertEquals(1, fetchResult.rowResult.maxRecordsToFetch); Row row3 = newRow("row-6", newRecord(FAMILY2, "record-6C", newColumn("testcol18", "value501"))); row3.recordCount = 1; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-core/src/test/java/org/apache/blur/utils/BlurUtilsTest.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/utils/BlurUtilsTest.java b/blur-core/src/test/java/org/apache/blur/utils/BlurUtilsTest.java index 8585117..27c31e8 100644 --- a/blur-core/src/test/java/org/apache/blur/utils/BlurUtilsTest.java +++ b/blur-core/src/test/java/org/apache/blur/utils/BlurUtilsTest.java @@ -19,6 +19,7 @@ package org.apache.blur.utils; import static org.apache.blur.lucene.LuceneVersionConstant.LUCENE_VERSION; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.File; @@ -26,6 +27,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.blur.thrift.generated.Selector; import org.apache.hadoop.conf.Configuration; @@ -173,9 +175,11 @@ public class BlurUtilsTest { // Term("a","b"), resetableDocumentStoredFieldVisitor, selector, 10000000, // "test-context", new // Term(BlurConstants.PRIME_DOC,BlurConstants.PRIME_DOC_VALUE)); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = BlurUtil.fetchDocuments(getReader(), resetableDocumentStoredFieldVisitor, selector, 10000000, - "test-context", new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE), null); + "test-context", new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE), null, moreDocsToFetch); assertEquals(docs.size(), 1); + assertFalse(moreDocsToFetch.get()); } @Test @@ -189,11 +193,14 @@ public class BlurUtilsTest { selector.setColumnFamiliesToFetch(columnFamiliesToFetch); ResetableDocumentStoredFieldVisitor resetableDocumentStoredFieldVisitor = new ResetableDocumentStoredFieldVisitor(); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = BlurUtil.fetchDocuments(getReaderWithDocsHavingFamily(), resetableDocumentStoredFieldVisitor, - selector, 10000000, "test-context", new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE), null); + selector, 10000000, "test-context", new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE), null, + moreDocsToFetch); assertEquals(docs.size(), 2); assertEquals(docs.get(0).getField("family").stringValue(), "f1"); assertEquals(docs.get(1).getField("family").stringValue(), "f2"); + assertFalse(moreDocsToFetch.get()); } @Test @@ -201,9 +208,11 @@ public class BlurUtilsTest { Selector selector = new Selector(); selector.setLocationId("shard/0"); ResetableDocumentStoredFieldVisitor resetableDocumentStoredFieldVisitor = new ResetableDocumentStoredFieldVisitor(); + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = BlurUtil.fetchDocuments(getReader(), resetableDocumentStoredFieldVisitor, selector, 10000000, - "test-context", new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE), null); + "test-context", new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE), null, moreDocsToFetch); assertEquals(docs.size(), 2); + assertFalse(moreDocsToFetch.get()); } private void rm(File file) { http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java ---------------------------------------------------------------------- diff --git a/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java b/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java index dff34c8..b9c5a53 100644 --- a/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java +++ b/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.blur.analysis.FieldManager; import org.apache.blur.log.Log; @@ -249,9 +250,13 @@ public class BlurReducer extends Reducer<Text, BlurMutate, Text, BlurMutate> { } protected void fetchOldRecords() throws IOException { + AtomicBoolean moreDocsToFetch = new AtomicBoolean(false); List<Document> docs = BlurUtil.fetchDocuments(_reader, new ResetableDocumentStoredFieldVisitor(), new Selector() .setRowId(_rowIdTerm.text()), Integer.MAX_VALUE, "reducer-context", new Term(BlurConstants.PRIME_DOC, - BlurConstants.PRIME_DOC_VALUE), null); + BlurConstants.PRIME_DOC_VALUE), null, moreDocsToFetch); + if (moreDocsToFetch.get()) { + throw new IOException("Row too large to update."); + } for (Document document : docs) { String recordId = document.get(RECORD_ID); // add them to the new records if the new records do not contain them. http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b220118d/blur-thrift/src/main/java/org/apache/blur/thrift/generated/FetchRowResult.java ---------------------------------------------------------------------- diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/FetchRowResult.java b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/FetchRowResult.java index b170a4c..b87a9da 100644 --- a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/FetchRowResult.java +++ b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/FetchRowResult.java @@ -56,6 +56,9 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct STRUCT_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct("FetchRowResult"); private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField ROW_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("row", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, (short)1); + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField START_RECORD_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("startRecord", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.I32, (short)2); + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField MAX_RECORDS_TO_FETCH_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("maxRecordsToFetch", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.I32, (short)3); + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField MORE_RECORDS_TO_FETCH_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("moreRecordsToFetch", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.BOOL, (short)4); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -67,13 +70,37 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T * The row fetched. */ public Row row; // required + /** + * See Selector startRecord. + */ + public int startRecord; // required + /** + * See Selector maxRecordsToFetch. + */ + public int maxRecordsToFetch; // required + /** + * Are there more Records to fetch based on the Selector provided. + */ + public boolean moreRecordsToFetch; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.blur.thirdparty.thrift_0_9_0.TFieldIdEnum { /** * The row fetched. */ - ROW((short)1, "row"); + ROW((short)1, "row"), + /** + * See Selector startRecord. + */ + START_RECORD((short)2, "startRecord"), + /** + * See Selector maxRecordsToFetch. + */ + MAX_RECORDS_TO_FETCH((short)3, "maxRecordsToFetch"), + /** + * Are there more Records to fetch based on the Selector provided. + */ + MORE_RECORDS_TO_FETCH((short)4, "moreRecordsToFetch"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -90,6 +117,12 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T switch(fieldId) { case 1: // ROW return ROW; + case 2: // START_RECORD + return START_RECORD; + case 3: // MAX_RECORDS_TO_FETCH + return MAX_RECORDS_TO_FETCH; + case 4: // MORE_RECORDS_TO_FETCH + return MORE_RECORDS_TO_FETCH; default: return null; } @@ -130,32 +163,61 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T } // isset id assignments + private static final int __STARTRECORD_ISSET_ID = 0; + private static final int __MAXRECORDSTOFETCH_ISSET_ID = 1; + private static final int __MORERECORDSTOFETCH_ISSET_ID = 2; + private byte __isset_bitfield = 0; public static final Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ROW, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("row", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, Row.class))); + tmpMap.put(_Fields.START_RECORD, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("startRecord", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.I32))); + tmpMap.put(_Fields.MAX_RECORDS_TO_FETCH, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("maxRecordsToFetch", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.I32))); + tmpMap.put(_Fields.MORE_RECORDS_TO_FETCH, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("moreRecordsToFetch", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.BOOL))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData.addStructMetaDataMap(FetchRowResult.class, metaDataMap); } public FetchRowResult() { + this.startRecord = -1; + + this.maxRecordsToFetch = -1; + + this.moreRecordsToFetch = false; + } public FetchRowResult( - Row row) + Row row, + int startRecord, + int maxRecordsToFetch, + boolean moreRecordsToFetch) { this(); this.row = row; + this.startRecord = startRecord; + setStartRecordIsSet(true); + this.maxRecordsToFetch = maxRecordsToFetch; + setMaxRecordsToFetchIsSet(true); + this.moreRecordsToFetch = moreRecordsToFetch; + setMoreRecordsToFetchIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public FetchRowResult(FetchRowResult other) { + __isset_bitfield = other.__isset_bitfield; if (other.isSetRow()) { this.row = new Row(other.row); } + this.startRecord = other.startRecord; + this.maxRecordsToFetch = other.maxRecordsToFetch; + this.moreRecordsToFetch = other.moreRecordsToFetch; } public FetchRowResult deepCopy() { @@ -165,6 +227,12 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T @Override public void clear() { this.row = null; + this.startRecord = -1; + + this.maxRecordsToFetch = -1; + + this.moreRecordsToFetch = false; + } /** @@ -197,6 +265,93 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T } } + /** + * See Selector startRecord. + */ + public int getStartRecord() { + return this.startRecord; + } + + /** + * See Selector startRecord. + */ + public FetchRowResult setStartRecord(int startRecord) { + this.startRecord = startRecord; + setStartRecordIsSet(true); + return this; + } + + public void unsetStartRecord() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __STARTRECORD_ISSET_ID); + } + + /** Returns true if field startRecord is set (has been assigned a value) and false otherwise */ + public boolean isSetStartRecord() { + return EncodingUtils.testBit(__isset_bitfield, __STARTRECORD_ISSET_ID); + } + + public void setStartRecordIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __STARTRECORD_ISSET_ID, value); + } + + /** + * See Selector maxRecordsToFetch. + */ + public int getMaxRecordsToFetch() { + return this.maxRecordsToFetch; + } + + /** + * See Selector maxRecordsToFetch. + */ + public FetchRowResult setMaxRecordsToFetch(int maxRecordsToFetch) { + this.maxRecordsToFetch = maxRecordsToFetch; + setMaxRecordsToFetchIsSet(true); + return this; + } + + public void unsetMaxRecordsToFetch() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MAXRECORDSTOFETCH_ISSET_ID); + } + + /** Returns true if field maxRecordsToFetch is set (has been assigned a value) and false otherwise */ + public boolean isSetMaxRecordsToFetch() { + return EncodingUtils.testBit(__isset_bitfield, __MAXRECORDSTOFETCH_ISSET_ID); + } + + public void setMaxRecordsToFetchIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MAXRECORDSTOFETCH_ISSET_ID, value); + } + + /** + * Are there more Records to fetch based on the Selector provided. + */ + public boolean isMoreRecordsToFetch() { + return this.moreRecordsToFetch; + } + + /** + * Are there more Records to fetch based on the Selector provided. + */ + public FetchRowResult setMoreRecordsToFetch(boolean moreRecordsToFetch) { + this.moreRecordsToFetch = moreRecordsToFetch; + setMoreRecordsToFetchIsSet(true); + return this; + } + + public void unsetMoreRecordsToFetch() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MORERECORDSTOFETCH_ISSET_ID); + } + + /** Returns true if field moreRecordsToFetch is set (has been assigned a value) and false otherwise */ + public boolean isSetMoreRecordsToFetch() { + return EncodingUtils.testBit(__isset_bitfield, __MORERECORDSTOFETCH_ISSET_ID); + } + + public void setMoreRecordsToFetchIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MORERECORDSTOFETCH_ISSET_ID, value); + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case ROW: @@ -207,6 +362,30 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T } break; + case START_RECORD: + if (value == null) { + unsetStartRecord(); + } else { + setStartRecord((Integer)value); + } + break; + + case MAX_RECORDS_TO_FETCH: + if (value == null) { + unsetMaxRecordsToFetch(); + } else { + setMaxRecordsToFetch((Integer)value); + } + break; + + case MORE_RECORDS_TO_FETCH: + if (value == null) { + unsetMoreRecordsToFetch(); + } else { + setMoreRecordsToFetch((Boolean)value); + } + break; + } } @@ -215,6 +394,15 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T case ROW: return getRow(); + case START_RECORD: + return Integer.valueOf(getStartRecord()); + + case MAX_RECORDS_TO_FETCH: + return Integer.valueOf(getMaxRecordsToFetch()); + + case MORE_RECORDS_TO_FETCH: + return Boolean.valueOf(isMoreRecordsToFetch()); + } throw new IllegalStateException(); } @@ -228,6 +416,12 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T switch (field) { case ROW: return isSetRow(); + case START_RECORD: + return isSetStartRecord(); + case MAX_RECORDS_TO_FETCH: + return isSetMaxRecordsToFetch(); + case MORE_RECORDS_TO_FETCH: + return isSetMoreRecordsToFetch(); } throw new IllegalStateException(); } @@ -254,6 +448,33 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T return false; } + boolean this_present_startRecord = true; + boolean that_present_startRecord = true; + if (this_present_startRecord || that_present_startRecord) { + if (!(this_present_startRecord && that_present_startRecord)) + return false; + if (this.startRecord != that.startRecord) + return false; + } + + boolean this_present_maxRecordsToFetch = true; + boolean that_present_maxRecordsToFetch = true; + if (this_present_maxRecordsToFetch || that_present_maxRecordsToFetch) { + if (!(this_present_maxRecordsToFetch && that_present_maxRecordsToFetch)) + return false; + if (this.maxRecordsToFetch != that.maxRecordsToFetch) + return false; + } + + boolean this_present_moreRecordsToFetch = true; + boolean that_present_moreRecordsToFetch = true; + if (this_present_moreRecordsToFetch || that_present_moreRecordsToFetch) { + if (!(this_present_moreRecordsToFetch && that_present_moreRecordsToFetch)) + return false; + if (this.moreRecordsToFetch != that.moreRecordsToFetch) + return false; + } + return true; } @@ -280,6 +501,36 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T return lastComparison; } } + lastComparison = Boolean.valueOf(isSetStartRecord()).compareTo(typedOther.isSetStartRecord()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStartRecord()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.startRecord, typedOther.startRecord); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMaxRecordsToFetch()).compareTo(typedOther.isSetMaxRecordsToFetch()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMaxRecordsToFetch()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.maxRecordsToFetch, typedOther.maxRecordsToFetch); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMoreRecordsToFetch()).compareTo(typedOther.isSetMoreRecordsToFetch()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMoreRecordsToFetch()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.moreRecordsToFetch, typedOther.moreRecordsToFetch); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -307,6 +558,18 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T sb.append(this.row); } first = false; + if (!first) sb.append(", "); + sb.append("startRecord:"); + sb.append(this.startRecord); + first = false; + if (!first) sb.append(", "); + sb.append("maxRecordsToFetch:"); + sb.append(this.maxRecordsToFetch); + first = false; + if (!first) sb.append(", "); + sb.append("moreRecordsToFetch:"); + sb.append(this.moreRecordsToFetch); + first = false; sb.append(")"); return sb.toString(); } @@ -329,6 +592,8 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; read(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(in))); } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { throw new java.io.IOException(te); @@ -362,6 +627,30 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 2: // START_RECORD + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.I32) { + struct.startRecord = iprot.readI32(); + struct.setStartRecordIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // MAX_RECORDS_TO_FETCH + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.I32) { + struct.maxRecordsToFetch = iprot.readI32(); + struct.setMaxRecordsToFetchIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // MORE_RECORDS_TO_FETCH + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.BOOL) { + struct.moreRecordsToFetch = iprot.readBool(); + struct.setMoreRecordsToFetchIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -382,6 +671,15 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T struct.row.write(oprot); oprot.writeFieldEnd(); } + oprot.writeFieldBegin(START_RECORD_FIELD_DESC); + oprot.writeI32(struct.startRecord); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(MAX_RECORDS_TO_FETCH_FIELD_DESC); + oprot.writeI32(struct.maxRecordsToFetch); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(MORE_RECORDS_TO_FETCH_FIELD_DESC); + oprot.writeBool(struct.moreRecordsToFetch); + oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -403,21 +701,51 @@ public class FetchRowResult implements org.apache.blur.thirdparty.thrift_0_9_0.T if (struct.isSetRow()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetStartRecord()) { + optionals.set(1); + } + if (struct.isSetMaxRecordsToFetch()) { + optionals.set(2); + } + if (struct.isSetMoreRecordsToFetch()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); if (struct.isSetRow()) { struct.row.write(oprot); } + if (struct.isSetStartRecord()) { + oprot.writeI32(struct.startRecord); + } + if (struct.isSetMaxRecordsToFetch()) { + oprot.writeI32(struct.maxRecordsToFetch); + } + if (struct.isSetMoreRecordsToFetch()) { + oprot.writeBool(struct.moreRecordsToFetch); + } } @Override public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, FetchRowResult struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.row = new Row(); struct.row.read(iprot); struct.setRowIsSet(true); } + if (incoming.get(1)) { + struct.startRecord = iprot.readI32(); + struct.setStartRecordIsSet(true); + } + if (incoming.get(2)) { + struct.maxRecordsToFetch = iprot.readI32(); + struct.setMaxRecordsToFetchIsSet(true); + } + if (incoming.get(3)) { + struct.moreRecordsToFetch = iprot.readBool(); + struct.setMoreRecordsToFetchIsSet(true); + } } }
