Added tablename to the session object.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/8018b062 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/8018b062 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/8018b062 Branch: refs/heads/0.2-dev Commit: 8018b0626c7175769b916a3c5f345c79f4f5f6d8 Parents: 3d131d2 Author: Aaron McCurry <[email protected]> Authored: Sat Nov 24 20:37:11 2012 -0500 Committer: Aaron McCurry <[email protected]> Committed: Sat Nov 24 20:37:11 2012 -0500 ---------------------------------------------------------------------- interface/Blur.thrift | 3 +- interface/gen-html/Blur.html | 1 + .../org/apache/blur/thrift/generated/Session.java | 108 ++++++++++++++- interface/gen-perl/Blur/Types.pm | 17 ++- interface/gen-rb/blur_types.rb | 4 +- .../org/apache/blur/thrift/BlurShardServer.java | 6 +- .../org/apache/blur/thrift/generated/Session.java | 108 ++++++++++++++- 7 files changed, 233 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/interface/Blur.thrift ---------------------------------------------------------------------- diff --git a/interface/Blur.thrift b/interface/Blur.thrift index f3d41eb..7c8f826 100644 --- a/interface/Blur.thrift +++ b/interface/Blur.thrift @@ -238,7 +238,8 @@ struct TableDescriptor { } struct Session { - 1:string sessionId + 1:string sessionId, + 2:string tableName } struct SortField { http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/interface/gen-html/Blur.html ---------------------------------------------------------------------- diff --git a/interface/gen-html/Blur.html b/interface/gen-html/Blur.html index 2cf6fde..c092863 100644 --- a/interface/gen-html/Blur.html +++ b/interface/gen-html/Blur.html @@ -176,6 +176,7 @@ trace (if any). <br/></div><div class="definition"><h3 id="Struct_Session">Struct: Session</h3> <table class="table-bordered table-striped table-condensed"><thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</th><th>Default value</th></thead> <tr><td>1</td><td>sessionId</td><td><code>string</code></td><td></td><td>default</td><td></td></tr> +<tr><td>2</td><td>tableName</td><td><code>string</code></td><td></td><td>default</td><td></td></tr> </table><br/></div><div class="definition"><h3 id="Struct_SortField">Struct: SortField</h3> <table class="table-bordered table-striped table-condensed"><thead><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</th><th>Default value</th></thead> <tr><td>1</td><td>field</td><td><code>string</code></td><td></td><td>default</td><td></td></tr> http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/interface/gen-java/org/apache/blur/thrift/generated/Session.java ---------------------------------------------------------------------- diff --git a/interface/gen-java/org/apache/blur/thrift/generated/Session.java b/interface/gen-java/org/apache/blur/thrift/generated/Session.java index 7726ff0..283736a 100644 --- a/interface/gen-java/org/apache/blur/thrift/generated/Session.java +++ b/interface/gen-java/org/apache/blur/thrift/generated/Session.java @@ -53,6 +53,7 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Session"); private static final org.apache.thrift.protocol.TField SESSION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionId", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)2); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -61,10 +62,12 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } public String sessionId; // required + public String tableName; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SESSION_ID((short)1, "sessionId"); + SESSION_ID((short)1, "sessionId"), + TABLE_NAME((short)2, "tableName"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -81,6 +84,8 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields switch(fieldId) { case 1: // SESSION_ID return SESSION_ID; + case 2: // TABLE_NAME + return TABLE_NAME; default: return null; } @@ -126,6 +131,8 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SESSION_ID, new org.apache.thrift.meta_data.FieldMetaData("sessionId", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Session.class, metaDataMap); } @@ -134,10 +141,12 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } public Session( - String sessionId) + String sessionId, + String tableName) { this(); this.sessionId = sessionId; + this.tableName = tableName; } /** @@ -147,6 +156,9 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields if (other.isSetSessionId()) { this.sessionId = other.sessionId; } + if (other.isSetTableName()) { + this.tableName = other.tableName; + } } public Session deepCopy() { @@ -156,6 +168,7 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields @Override public void clear() { this.sessionId = null; + this.tableName = null; } public String getSessionId() { @@ -182,6 +195,30 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } } + public String getTableName() { + return this.tableName; + } + + public Session setTableName(String tableName) { + this.tableName = tableName; + return this; + } + + public void unsetTableName() { + this.tableName = null; + } + + /** Returns true if field tableName is set (has been assigned a value) and false otherwise */ + public boolean isSetTableName() { + return this.tableName != null; + } + + public void setTableNameIsSet(boolean value) { + if (!value) { + this.tableName = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case SESSION_ID: @@ -192,6 +229,14 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } break; + case TABLE_NAME: + if (value == null) { + unsetTableName(); + } else { + setTableName((String)value); + } + break; + } } @@ -200,6 +245,9 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields case SESSION_ID: return getSessionId(); + case TABLE_NAME: + return getTableName(); + } throw new IllegalStateException(); } @@ -213,6 +261,8 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields switch (field) { case SESSION_ID: return isSetSessionId(); + case TABLE_NAME: + return isSetTableName(); } throw new IllegalStateException(); } @@ -239,6 +289,15 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields return false; } + boolean this_present_tableName = true && this.isSetTableName(); + boolean that_present_tableName = true && that.isSetTableName(); + if (this_present_tableName || that_present_tableName) { + if (!(this_present_tableName && that_present_tableName)) + return false; + if (!this.tableName.equals(that.tableName)) + return false; + } + return true; } @@ -265,6 +324,16 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields return lastComparison; } } + lastComparison = Boolean.valueOf(isSetTableName()).compareTo(typedOther.isSetTableName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTableName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, typedOther.tableName); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -292,6 +361,14 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields sb.append(this.sessionId); } first = false; + if (!first) sb.append(", "); + sb.append("tableName:"); + if (this.tableName == null) { + sb.append("null"); + } else { + sb.append(this.tableName); + } + first = false; sb.append(")"); return sb.toString(); } @@ -343,6 +420,14 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 2: // TABLE_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -363,6 +448,11 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields oprot.writeString(struct.sessionId); oprot.writeFieldEnd(); } + if (struct.tableName != null) { + oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC); + oprot.writeString(struct.tableName); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -384,20 +474,30 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields if (struct.isSetSessionId()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetTableName()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); if (struct.isSetSessionId()) { oprot.writeString(struct.sessionId); } + if (struct.isSetTableName()) { + oprot.writeString(struct.tableName); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, Session struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.sessionId = iprot.readString(); struct.setSessionIdIsSet(true); } + if (incoming.get(1)) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } } } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/interface/gen-perl/Blur/Types.pm ---------------------------------------------------------------------- diff --git a/interface/gen-perl/Blur/Types.pm b/interface/gen-perl/Blur/Types.pm index d234563..b73886d 100644 --- a/interface/gen-perl/Blur/Types.pm +++ b/interface/gen-perl/Blur/Types.pm @@ -1114,17 +1114,21 @@ sub write { package Blur::Session; use base qw(Class::Accessor); -Blur::Session->mk_accessors( qw( sessionId ) ); +Blur::Session->mk_accessors( qw( sessionId tableName ) ); sub new { my $classname = shift; my $self = {}; my $vals = shift || {}; $self->{sessionId} = undef; + $self->{tableName} = undef; if (UNIVERSAL::isa($vals,'HASH')) { if (defined $vals->{sessionId}) { $self->{sessionId} = $vals->{sessionId}; } + if (defined $vals->{tableName}) { + $self->{tableName} = $vals->{tableName}; + } } return bless ($self, $classname); } @@ -1154,6 +1158,12 @@ sub read { $xfer += $input->skip($ftype); } last; }; + /^2$/ && do{ if ($ftype == TType::STRING) { + $xfer += $input->readString(\$self->{tableName}); + } else { + $xfer += $input->skip($ftype); + } + last; }; $xfer += $input->skip($ftype); } $xfer += $input->readFieldEnd(); @@ -1171,6 +1181,11 @@ sub write { $xfer += $output->writeString($self->{sessionId}); $xfer += $output->writeFieldEnd(); } + if (defined $self->{tableName}) { + $xfer += $output->writeFieldBegin('tableName', TType::STRING, 2); + $xfer += $output->writeString($self->{tableName}); + $xfer += $output->writeFieldEnd(); + } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/interface/gen-rb/blur_types.rb ---------------------------------------------------------------------- diff --git a/interface/gen-rb/blur_types.rb b/interface/gen-rb/blur_types.rb index 864c44a..0fc8dc4 100644 --- a/interface/gen-rb/blur_types.rb +++ b/interface/gen-rb/blur_types.rb @@ -284,9 +284,11 @@ module Blur class Session include ::Thrift::Struct, ::Thrift::Struct_Union SESSIONID = 1 + TABLENAME = 2 FIELDS = { - SESSIONID => {:type => ::Thrift::Types::STRING, :name => 'sessionId'} + SESSIONID => {:type => ::Thrift::Types::STRING, :name => 'sessionId'}, + TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName'} } def struct_fields; FIELDS; end http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java ---------------------------------------------------------------------- diff --git a/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java b/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java index 83d2e00..5526f85 100644 --- a/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java +++ b/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java @@ -199,15 +199,15 @@ public class BlurShardServer extends TableAdmin implements Iface { } } sessions.put(uuid, sessionInfo); - return new Session(uuid); + return new Session(uuid, table); } @Override public List<TopFieldDocs> search(final Session session, final QueryArgs queryArgs) throws BlurException, TException { SessionInfo info = getSessionInfo(session); if (info == null) { - newSession("test", session.getSessionId()); - info = getSessionInfo(session); + newSession(session.getTableName(), session.getSessionId()); + info = getSessionInfo(session); } try { Map<Integer, IndexSearcher> searchers = info.getSearchers(); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8018b062/src/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Session.java ---------------------------------------------------------------------- diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Session.java b/src/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Session.java index 7726ff0..283736a 100644 --- a/src/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Session.java +++ b/src/blur-thrift/src/main/java/org/apache/blur/thrift/generated/Session.java @@ -53,6 +53,7 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Session"); private static final org.apache.thrift.protocol.TField SESSION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionId", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)2); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -61,10 +62,12 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } public String sessionId; // required + public String tableName; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SESSION_ID((short)1, "sessionId"); + SESSION_ID((short)1, "sessionId"), + TABLE_NAME((short)2, "tableName"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -81,6 +84,8 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields switch(fieldId) { case 1: // SESSION_ID return SESSION_ID; + case 2: // TABLE_NAME + return TABLE_NAME; default: return null; } @@ -126,6 +131,8 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SESSION_ID, new org.apache.thrift.meta_data.FieldMetaData("sessionId", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Session.class, metaDataMap); } @@ -134,10 +141,12 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } public Session( - String sessionId) + String sessionId, + String tableName) { this(); this.sessionId = sessionId; + this.tableName = tableName; } /** @@ -147,6 +156,9 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields if (other.isSetSessionId()) { this.sessionId = other.sessionId; } + if (other.isSetTableName()) { + this.tableName = other.tableName; + } } public Session deepCopy() { @@ -156,6 +168,7 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields @Override public void clear() { this.sessionId = null; + this.tableName = null; } public String getSessionId() { @@ -182,6 +195,30 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } } + public String getTableName() { + return this.tableName; + } + + public Session setTableName(String tableName) { + this.tableName = tableName; + return this; + } + + public void unsetTableName() { + this.tableName = null; + } + + /** Returns true if field tableName is set (has been assigned a value) and false otherwise */ + public boolean isSetTableName() { + return this.tableName != null; + } + + public void setTableNameIsSet(boolean value) { + if (!value) { + this.tableName = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case SESSION_ID: @@ -192,6 +229,14 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields } break; + case TABLE_NAME: + if (value == null) { + unsetTableName(); + } else { + setTableName((String)value); + } + break; + } } @@ -200,6 +245,9 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields case SESSION_ID: return getSessionId(); + case TABLE_NAME: + return getTableName(); + } throw new IllegalStateException(); } @@ -213,6 +261,8 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields switch (field) { case SESSION_ID: return isSetSessionId(); + case TABLE_NAME: + return isSetTableName(); } throw new IllegalStateException(); } @@ -239,6 +289,15 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields return false; } + boolean this_present_tableName = true && this.isSetTableName(); + boolean that_present_tableName = true && that.isSetTableName(); + if (this_present_tableName || that_present_tableName) { + if (!(this_present_tableName && that_present_tableName)) + return false; + if (!this.tableName.equals(that.tableName)) + return false; + } + return true; } @@ -265,6 +324,16 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields return lastComparison; } } + lastComparison = Boolean.valueOf(isSetTableName()).compareTo(typedOther.isSetTableName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTableName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, typedOther.tableName); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -292,6 +361,14 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields sb.append(this.sessionId); } first = false; + if (!first) sb.append(", "); + sb.append("tableName:"); + if (this.tableName == null) { + sb.append("null"); + } else { + sb.append(this.tableName); + } + first = false; sb.append(")"); return sb.toString(); } @@ -343,6 +420,14 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 2: // TABLE_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -363,6 +448,11 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields oprot.writeString(struct.sessionId); oprot.writeFieldEnd(); } + if (struct.tableName != null) { + oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC); + oprot.writeString(struct.tableName); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -384,20 +474,30 @@ public class Session implements org.apache.thrift.TBase<Session, Session._Fields if (struct.isSetSessionId()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetTableName()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); if (struct.isSetSessionId()) { oprot.writeString(struct.sessionId); } + if (struct.isSetTableName()) { + oprot.writeString(struct.tableName); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, Session struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.sessionId = iprot.readString(); struct.setSessionIdIsSet(true); } + if (incoming.get(1)) { + struct.tableName = iprot.readString(); + struct.setTableNameIsSet(true); + } } }
