大数据技术 hbase协处理器编码实例
沉沙 2018-09-25 来源 : 阅读 1657 评论 0

摘要:本篇教程探讨了大数据技术 hbase协处理器编码实例,希望阅读本篇文章以后大家有所收获,帮助大家对大数据技术的理解更加深入。

本篇教程探讨了大数据技术 hbase协处理器编码实例,希望阅读本篇文章以后大家有所收获,帮助大家对大数据技术的理解更加深入。

<

Observer协处理器通常在一个特定的事件(诸如Get或Put)之前或之后发生,相当于RDBMS中的触发器。Endpoint协处理器则类似于RDBMS中的存储过程,因为它可以让你在RegionServer上对数据执行自定义计算,而不是在客户端上执行计算。
本文是以上两者的简单实例,使用的环境:环境 jdk1.8 hadoop2.6.5 hbase1.2.4。
1、Endpoint实例  1> 编写适用于protobuf的proto文件,如下,尽量不要带注释,因为编译时可能出现乱码

option java_package = "com.endpoint.test";
option java_outer_classname = "Sum";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
option optimize_for = SPEED;

message SumRequest {
    required string family = 1;    
    required string column = 2;    
}
message SumResponse {
    required int64 sum = 1 [default = 0];
}
service SumService {
    rpc getSum(SumRequest)
        returns (SumResponse);
}

 2> 编译上面的proto文件使用protoc程序进行编译,linux下或者windows均可,protoc程序可以直接从github下载:https://github.com/google/protobuf/releases,也可以自己编译生成,参见protobuf的编译安装
注意,编译的版本要与hadoop以及hbase使用的版本相同,或者略高,但最好不要过高,hadoop2.6.5 hbase1.2.4使用的都是protobuf2.5.0的版本,写此篇文章时的最新版为3.1.0
(高版本必须指定syntax,例如proto3的syntax在第一行非空白非注释行,必须写:syntax = "proto3",字段规则移除了 “required”,并把 “optional” 改名为 “singular”,移除了 default 选项。可搜索Protobuf 的 proto3 与 proto2 的区别进行了解。)下载的话选择带win或linux的版本,这是编译好的版本。有很多带具体语言的版本,是一些具体某种语言的发行版源码包。为了与hbase以及hadoop统一起来,此处用的是protoc-2.5.0-win32.zip。
解压文件:
 
 使用windows命令行进入上面的目录,执行以下命令即可:

protoc.exe sum1.proto --java_out=./

高版本有编译好的适用于linux下的protoc程序文件,低版本没有。在linux下执行以下命令:

protoc sum.proto --java_out=./

 结果都一样,生成的代码参见折叠部分,有很多,因为上面文件中指定java_outer_classname = "Sum",所以会生成Sum类,将这个类引入到项目中,注意项目的包名称与上面文件中指定(option java_package = "com.endpoint.test")的名称要一致。


   1 // Generated by the protocol buffer compiler.  DO NOT EDIT!
   2 // source: sumcode.proto
   3 
   4 package com.endpoint.test;
   5 
   6 public final class Sum {
   7   private Sum() {}
   8   public static void registerAllExtensions(
   9       com.google.protobuf.ExtensionRegistry registry) {
  10   }
  11   public interface SumRequestOrBuilder
  12       extends com.google.protobuf.MessageOrBuilder {
  13 
  14     // required string family = 1;
  15     /**
  16      * <code>required string family = 1;</code>
  17      */
  18     boolean hasFamily();
  19     /**
  20      * <code>required string family = 1;</code>
  21      */
  22     java.lang.String getFamily();
  23     /**
  24      * <code>required string family = 1;</code>
  25      */
  26     com.google.protobuf.ByteString
  27         getFamilyBytes();
  28 
  29     // required string column = 2;
  30     /**
  31      * <code>required string column = 2;</code>
  32      */
  33     boolean hasColumn();
  34     /**
  35      * <code>required string column = 2;</code>
  36      */
  37     java.lang.String getColumn();
  38     /**
  39      * <code>required string column = 2;</code>
  40      */
  41     com.google.protobuf.ByteString
  42         getColumnBytes();
  43   }
  44   /**
  45    * Protobuf type {@code SumRequest}
  46    */
  47   public static final class SumRequest extends
  48       com.google.protobuf.GeneratedMessage
  49       implements SumRequestOrBuilder {
  50     // Use SumRequest.newBuilder() to construct.
  51     private SumRequest(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
  52       super(builder);
  53       this.unknownFields = builder.getUnknownFields();
  54     }
  55     private SumRequest(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
  56 
  57     private static final SumRequest defaultInstance;
  58     public static SumRequest getDefaultInstance() {
  59       return defaultInstance;
  60     }
  61 
  62     public SumRequest getDefaultInstanceForType() {
  63       return defaultInstance;
  64     }
  65 
  66     private final com.google.protobuf.UnknownFieldSet unknownFields;
  67     @java.lang.Override
  68     public final com.google.protobuf.UnknownFieldSet
  69         getUnknownFields() {
  70       return this.unknownFields;
  71     }
  72     private SumRequest(
  73         com.google.protobuf.CodedInputStream input,
  74         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
  75         throws com.google.protobuf.InvalidProtocolBufferException {
  76       initFields();
  77       int mutable_bitField0_ = 0;
  78       com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  79           com.google.protobuf.UnknownFieldSet.newBuilder();
  80       try {
  81         boolean done = false;
  82         while (!done) {
  83           int tag = input.readTag();
  84           switch (tag) {
  85             case 0:
  86               done = true;
  87               break;
  88             default: {
  89               if (!parseUnknownField(input, unknownFields,
  90                                      extensionRegistry, tag)) {
  91                 done = true;
  92               }
  93               break;
  94             }
  95             case 10: {
  96               bitField0_ |= 0x00000001;
  97               family_ = input.readBytes();
  98               break;
  99             }
 100             case 18: {
 101               bitField0_ |= 0x00000002;
 102               column_ = input.readBytes();
 103               break;
 104             }
 105           }
 106         }
 107       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
 108         throw e.setUnfinishedMessage(this);
 109       } catch (java.io.IOException e) {
 110         throw new com.google.protobuf.InvalidProtocolBufferException(
 111             e.getMessage()).setUnfinishedMessage(this);
 112       } finally {
 113         this.unknownFields = unknownFields.build();
 114         makeExtensionsImmutable();
 115       }
 116     }
 117     public static final com.google.protobuf.Descriptors.Descriptor
 118         getDescriptor() {
 119       return com.endpoint.test.Sum.internal_static_SumRequest_descriptor;
 120     }
 121 
 122     protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
 123         internalGetFieldAccessorTable() {
 124       return com.endpoint.test.Sum.internal_static_SumRequest_fieldAccessorTable
 125           .ensureFieldAccessorsInitialized(
 126               com.endpoint.test.Sum.SumRequest.class, com.endpoint.test.Sum.SumRequest.Builder.class);
 127     }
 128 
 129     public static com.google.protobuf.Parser<SumRequest> PARSER =
 130         new com.google.protobuf.AbstractParser<SumRequest>() {
 131       public SumRequest parsePartialFrom(
 132           com.google.protobuf.CodedInputStream input,
 133           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 134           throws com.google.protobuf.InvalidProtocolBufferException {
 135         return new SumRequest(input, extensionRegistry);
 136       }
 137     };
 138 
 139     @java.lang.Override
 140     public com.google.protobuf.Parser<SumRequest> getParserForType() {
 141       return PARSER;
 142     }
 143 
 144     private int bitField0_;
 145     // required string family = 1;
 146     public static final int FAMILY_FIELD_NUMBER = 1;
 147     private java.lang.Object family_;
 148     /**
 149      * <code>required string family = 1;</code>
 150      */
 151     public boolean hasFamily() {
 152       return ((bitField0_ & 0x00000001) == 0x00000001);
 153     }
 154     /**
 155      * <code>required string family = 1;</code>
 156      */
 157     public java.lang.String getFamily() {
 158       java.lang.Object ref = family_;
 159       if (ref instanceof java.lang.String) {
 160         return (java.lang.String) ref;
 161       } else {
 162         com.google.protobuf.ByteString bs = 
 163             (com.google.protobuf.ByteString) ref;
 164         java.lang.String s = bs.toStringUtf8();
 165         if (bs.isValidUtf8()) {
 166           family_ = s;
 167         }
 168         return s;
 169       }
 170     }
 171     /**
 172      * <code>required string family = 1;</code>
 173      */
 174     public com.google.protobuf.ByteString
 175         getFamilyBytes() {
 176       java.lang.Object ref = family_;
 177       if (ref instanceof java.lang.String) {
 178         com.google.protobuf.ByteString b = 
 179             com.google.protobuf.ByteString.copyFromUtf8(
 180                 (java.lang.String) ref);
 181         family_ = b;
 182         return b;
 183       } else {
 184         return (com.google.protobuf.ByteString) ref;
 185       }
 186     }
 187 
 188     // required string column = 2;
 189     public static final int COLUMN_FIELD_NUMBER = 2;
 190     private java.lang.Object column_;
 191     /**
 192      * <code>required string column = 2;</code>
 193      */
 194     public boolean hasColumn() {
 195       return ((bitField0_ & 0x00000002) == 0x00000002);
 196     }
 197     /**
 198      * <code>required string column = 2;</code>
 199      */
 200     public java.lang.String getColumn() {
 201       java.lang.Object ref = column_;
 202       if (ref instanceof java.lang.String) {
 203         return (java.lang.String) ref;
 204       } else {
 205         com.google.protobuf.ByteString bs = 
 206             (com.google.protobuf.ByteString) ref;
 207         java.lang.String s = bs.toStringUtf8();
 208         if (bs.isValidUtf8()) {
 209           column_ = s;
 210         }
 211         return s;
 212       }
 213     }
 214     /**
 215      * <code>required string column = 2;</code>
 216      */
 217     public com.google.protobuf.ByteString
 218         getColumnBytes() {
 219       java.lang.Object ref = column_;
 220       if (ref instanceof java.lang.String) {
 221         com.google.protobuf.ByteString b = 
 222             com.google.protobuf.ByteString.copyFromUtf8(
 223                 (java.lang.String) ref);
 224         column_ = b;
 225         return b;
 226       } else {
 227         return (com.google.protobuf.ByteString) ref;
 228       }
 229     }
 230 
 231     private void initFields() {
 232       family_ = "";
 233       column_ = "";
 234     }
 235     private byte memoizedIsInitialized = -1;
 236     public final boolean isInitialized() {
 237       byte isInitialized = memoizedIsInitialized;
 238       if (isInitialized != -1) return isInitialized == 1;
 239 
 240       if (!hasFamily()) {
 241         memoizedIsInitialized = 0;
 242         return false;
 243       }
 244       if (!hasColumn()) {
 245         memoizedIsInitialized = 0;
 246         return false;
 247       }
 248       memoizedIsInitialized = 1;
 249       return true;
 250     }
 251 
 252     public void writeTo(com.google.protobuf.CodedOutputStream output)
 253                         throws java.io.IOException {
 254       getSerializedSize();
 255       if (((bitField0_ & 0x00000001) == 0x00000001)) {
 256         output.writeBytes(1, getFamilyBytes());
 257       }
 258       if (((bitField0_ & 0x00000002) == 0x00000002)) {
 259         output.writeBytes(2, getColumnBytes());
 260       }
 261       getUnknownFields().writeTo(output);
 262     }
 263 
 264     private int memoizedSerializedSize = -1;
 265     public int getSerializedSize() {
 266       int size = memoizedSerializedSize;
 267       if (size != -1) return size;
 268 
 269       size = 0;
 270       if (((bitField0_ & 0x00000001) == 0x00000001)) {
 271         size += com.google.protobuf.CodedOutputStream
 272           .computeBytesSize(1, getFamilyBytes());
 273       }
 274       if (((bitField0_ & 0x00000002) == 0x00000002)) {
 275         size += com.google.protobuf.CodedOutputStream
 276           .computeBytesSize(2, getColumnBytes());
 277       }
 278       size += getUnknownFields().getSerializedSize();
 279       memoizedSerializedSize = size;
 280       return size;
 281     }
 282 
 283     private static final long serialVersionUID = 0L;
 284     @java.lang.Override
 285     protected java.lang.Object writeReplace()
 286         throws java.io.ObjectStreamException {
 287       return super.writeReplace();
 288     }
 289 
 290     @java.lang.Override
 291     public boolean equals(final java.lang.Object obj) {
 292       if (obj == this) {
 293        return true;
 294       }
 295       if (!(obj instanceof com.endpoint.test.Sum.SumRequest)) {
 296         return super.equals(obj);
 297       }
 298       com.endpoint.test.Sum.SumRequest other = (com.endpoint.test.Sum.SumRequest) obj;
 299 
 300       boolean result = true;
 301       result = result && (hasFamily() == other.hasFamily());
 302       if (hasFamily()) {
 303         result = result && getFamily()
 304             .equals(other.getFamily());
 305       }
 306       result = result && (hasColumn() == other.hasColumn());
 307       if (hasColumn()) {
 308         result = result && getColumn()
 309             .equals(other.getColumn());
 310       }
 311       result = result &&
 312           getUnknownFields().equals(other.getUnknownFields());
 313       return result;
 314     }
 315 
 316     private int memoizedHashCode = 0;
 317     @java.lang.Override
 318     public int hashCode() {
 319       if (memoizedHashCode != 0) {
 320         return memoizedHashCode;
 321       }
 322       int hash = 41;
 323       hash = (19 * hash) + getDescriptorForType().hashCode();
 324       if (hasFamily()) {
 325         hash = (37 * hash) + FAMILY_FIELD_NUMBER;
 326         hash = (53 * hash) + getFamily().hashCode();
 327       }
 328       if (hasColumn()) {
 329         hash = (37 * hash) + COLUMN_FIELD_NUMBER;
 330         hash = (53 * hash) + getColumn().hashCode();
 331       }
 332       hash = (29 * hash) + getUnknownFields().hashCode();
 333       memoizedHashCode = hash;
 334       return hash;
 335     }
 336 
 337     public static com.endpoint.test.Sum.SumRequest parseFrom(
 338         com.google.protobuf.ByteString data)
 339         throws com.google.protobuf.InvalidProtocolBufferException {
 340       return PARSER.parseFrom(data);
 341     }
 342     public static com.endpoint.test.Sum.SumRequest parseFrom(
 343         com.google.protobuf.ByteString data,
 344         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 345         throws com.google.protobuf.InvalidProtocolBufferException {
 346       return PARSER.parseFrom(data, extensionRegistry);
 347     }
 348     public static com.endpoint.test.Sum.SumRequest parseFrom(byte[] data)
 349         throws com.google.protobuf.InvalidProtocolBufferException {
 350       return PARSER.parseFrom(data);
 351     }
 352     public static com.endpoint.test.Sum.SumRequest parseFrom(
 353         byte[] data,
 354         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 355         throws com.google.protobuf.InvalidProtocolBufferException {
 356       return PARSER.parseFrom(data, extensionRegistry);
 357     }
 358     public static com.endpoint.test.Sum.SumRequest parseFrom(java.io.InputStream input)
 359         throws java.io.IOException {
 360       return PARSER.parseFrom(input);
 361     }
 362     public static com.endpoint.test.Sum.SumRequest parseFrom(
 363         java.io.InputStream input,
 364         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 365         throws java.io.IOException {
 366       return PARSER.parseFrom(input, extensionRegistry);
 367     }
 368     public static com.endpoint.test.Sum.SumRequest parseDelimitedFrom(java.io.InputStream input)
 369         throws java.io.IOException {
 370       return PARSER.parseDelimitedFrom(input);
 371     }
 372     public static com.endpoint.test.Sum.SumRequest parseDelimitedFrom(
 373         java.io.InputStream input,
 374         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 375         throws java.io.IOException {
 376       return PARSER.parseDelimitedFrom(input, extensionRegistry);
 377     }
 378     public static com.endpoint.test.Sum.SumRequest parseFrom(
 379         com.google.protobuf.CodedInputStream input)
 380         throws java.io.IOException {
 381       return PARSER.parseFrom(input);
 382     }
 383     public static com.endpoint.test.Sum.SumRequest parseFrom(
 384         com.google.protobuf.CodedInputStream input,
 385         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 386         throws java.io.IOException {
 387       return PARSER.parseFrom(input, extensionRegistry);
 388     }
 389 
 390     public static Builder newBuilder() { return Builder.create(); }
 391     public Builder newBuilderForType() { return newBuilder(); }
 392     public static Builder newBuilder(com.endpoint.test.Sum.SumRequest prototype) {
 393       return newBuilder().mergeFrom(prototype);
 394     }
 395     public Builder toBuilder() { return newBuilder(this); }
 396 
 397     @java.lang.Override
 398     protected Builder newBuilderForType(
 399         com.google.protobuf.GeneratedMessage.BuilderParent parent) {
 400       Builder builder = new Builder(parent);
 401       return builder;
 402     }
 403     /**
 404      * Protobuf type {@code SumRequest}
 405      */
 406     public static final class Builder extends
 407         com.google.protobuf.GeneratedMessage.Builder<Builder>
 408        implements com.endpoint.test.Sum.SumRequestOrBuilder {
 409       public static final com.google.protobuf.Descriptors.Descriptor
 410           getDescriptor() {
 411         return com.endpoint.test.Sum.internal_static_SumRequest_descriptor;
 412       }
 413 
 414       protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
 415           internalGetFieldAccessorTable() {
 416         return com.endpoint.test.Sum.internal_static_SumRequest_fieldAccessorTable
 417             .ensureFieldAccessorsInitialized(
 418                 com.endpoint.test.Sum.SumRequest.class, com.endpoint.test.Sum.SumRequest.Builder.class);
 419       }
 420 
 421       // Construct using com.endpoint.test.Sum.SumRequest.newBuilder()
 422       private Builder() {
 423         maybeForceBuilderInitialization();
 424       }
 425 
 426       private Builder(
 427           com.google.protobuf.GeneratedMessage.BuilderParent parent) {
 428         super(parent);
 429         maybeForceBuilderInitialization();
 430       }
 431       private void maybeForceBuilderInitialization() {
 432         if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
 433         }
 434       }
 435       private static Builder create() {
 436         return new Builder();
 437       }
 438 
 439       public Builder clear() {
 440         super.clear();
 441         family_ = "";
 442         bitField0_ = (bitField0_ & ~0x00000001);
 443         column_ = "";
 444         bitField0_ = (bitField0_ & ~0x00000002);
 445         return this;
 446       }
 447 
 448       public Builder clone() {
 449         return create().mergeFrom(buildPartial());
 450       }
 451 
 452       public com.google.protobuf.Descriptors.Descriptor
 453           getDescriptorForType() {
 454         return com.endpoint.test.Sum.internal_static_SumRequest_descriptor;
 455       }
 456 
 457       public com.endpoint.test.Sum.SumRequest getDefaultInstanceForType() {
 458         return com.endpoint.test.Sum.SumRequest.getDefaultInstance();
 459       }
 460 
 461       public com.endpoint.test.Sum.SumRequest build() {
 462         com.endpoint.test.Sum.SumRequest result = buildPartial();
 463         if (!result.isInitialized()) {
 464           throw newUninitializedMessageException(result);
 465         }
 466         return result;
 467       }
 468 
 469       public com.endpoint.test.Sum.SumRequest buildPartial() {
 470         com.endpoint.test.Sum.SumRequest result = new com.endpoint.test.Sum.SumRequest(this);
 471         int from_bitField0_ = bitField0_;
 472         int to_bitField0_ = 0;
 473         if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
 474           to_bitField0_ |= 0x00000001;
 475         }
 476         result.family_ = family_;
 477         if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
 478           to_bitField0_ |= 0x00000002;
 479         }
 480         result.column_ = column_;
 481         result.bitField0_ = to_bitField0_;
 482         onBuilt();
 483         return result;
 484       }
 485 
 486       public Builder mergeFrom(com.google.protobuf.Message other) {
 487         if (other instanceof com.endpoint.test.Sum.SumRequest) {
 488           return mergeFrom((com.endpoint.test.Sum.SumRequest)other);
 489         } else {
 490           super.mergeFrom(other);
 491           return this;
 492         }
 493       }
 494 
 495       public Builder mergeFrom(com.endpoint.test.Sum.SumRequest other) {
 496         if (other == com.endpoint.test.Sum.SumRequest.getDefaultInstance()) return this;
 497         if (other.hasFamily()) {
 498           bitField0_ |= 0x00000001;
 499           family_ = other.family_;
 500           onChanged();
 501         }
 502         if (other.hasColumn()) {
 503           bitField0_ |= 0x00000002;
 504           column_ = other.column_;
 505           onChanged();
 506         }
 507         this.mergeUnknownFields(other.getUnknownFields());
 508         return this;
 509       }
 510 
 511       public final boolean isInitialized() {
 512         if (!hasFamily()) {
 513           
 514           return false;
 515         }
 516         if (!hasColumn()) {
 517           
 518           return false;
 519         }
 520         return true;
 521       }
 522 
 523       public Builder mergeFrom(
 524           com.google.protobuf.CodedInputStream input,
 525           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 526           throws java.io.IOException {
 527         com.endpoint.test.Sum.SumRequest parsedMessage = null;
 528         try {
 529           parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
 530         } catch (com.google.protobuf.InvalidProtocolBufferException e) {
 531           parsedMessage = (com.endpoint.test.Sum.SumRequest) e.getUnfinishedMessage();
 532           throw e;
 533         } finally {
 534           if (parsedMessage != null) {
 535             mergeFrom(parsedMessage);
 536           }
 537         }
 538         return this;
 539       }
 540       private int bitField0_;
 541 
 542       // required string family = 1;
 543       private java.lang.Object family_ = "";
 544       /**
 545        * <code>required string family = 1;</code>
 546        */
 547       public boolean hasFamily() {
 548         return ((bitField0_ & 0x00000001) == 0x00000001);
 549       }
 550       /**
 551        * <code>required string family = 1;</code>
 552        */
 553       public java.lang.String getFamily() {
 554         java.lang.Object ref = family_;
 555         if (!(ref instanceof java.lang.String)) {
 556           java.lang.String s = ((com.google.protobuf.ByteString) ref)
 557               .toStringUtf8();
 558           family_ = s;
 559           return s;
 560         } else {
 561           return (java.lang.String) ref;
 562         }
 563       }
 564       /**
 565        * <code>required string family = 1;</code>
 566        */
 567       public com.google.protobuf.ByteString
 568           getFamilyBytes() {
 569         java.lang.Object ref = family_;
 570         if (ref instanceof String) {
 571           com.google.protobuf.ByteString b = 
 572               com.google.protobuf.ByteString.copyFromUtf8(
 573                   (java.lang.String) ref);
 574           family_ = b;
 575           return b;
 576         } else {
 577           return (com.google.protobuf.ByteString) ref;
 578         }
 579       }
 580       /**
 581        * <code>required string family = 1;</code>
 582        */
 583       public Builder setFamily(
 584           java.lang.String value) {
 585         if (value == null) {
 586     throw new NullPointerException();
 587   }
 588   bitField0_ |= 0x00000001;
 589         family_ = value;
 590         onChanged();
 591         return this;
 592       }
 593       /**
 594        * <code>required string family = 1;</code>
 595        */
 596       public Builder clearFamily() {
 597         bitField0_ = (bitField0_ & ~0x00000001);
 598         family_ = getDefaultInstance().getFamily();
 599         onChanged();
 600         return this;
 601       }
 602       /**
 603        * <code>required string family = 1;</code>
 604        */
 605       public Builder setFamilyBytes(
 606           com.google.protobuf.ByteString value) {
 607         if (value == null) {
 608     throw new NullPointerException();
 609   }
 610   bitField0_ |= 0x00000001;
 611         family_ = value;
 612         onChanged();
 613         return this;
 614       }
 615 
 616       // required string column = 2;
 617       private java.lang.Object column_ = "";
 618       /**
 619        * <code>required string column = 2;</code>
 620        */
 621       public boolean hasColumn() {
 622         return ((bitField0_ & 0x00000002) == 0x00000002);
 623       }
 624       /**
 625        * <code>required string column = 2;</code>
 626        */
 627       public java.lang.String getColumn() {
 628         java.lang.Object ref = column_;
 629         if (!(ref instanceof java.lang.String)) {
 630           java.lang.String s = ((com.google.protobuf.ByteString) ref)
 631               .toStringUtf8();
 632           column_ = s;
 633           return s;
 634         } else {
 635           return (java.lang.String) ref;
 636         }
 637       }
 638       /**
 639        * <code>required string column = 2;</code>
 640        */
 641       public com.google.protobuf.ByteString
 642           getColumnBytes() {
 643         java.lang.Object ref = column_;
 644         if (ref instanceof String) {
 645           com.google.protobuf.ByteString b = 
 646               com.google.protobuf.ByteString.copyFromUtf8(
 647                   (java.lang.String) ref);
 648           column_ = b;
 649           return b;
 650         } else {
 651           return (com.google.protobuf.ByteString) ref;
 652         }
 653       }
 654       /**
 655        * <code>required string column = 2;</code>
 656        */
 657       public Builder setColumn(
 658           java.lang.String value) {
 659         if (value == null) {
 660     throw new NullPointerException();
 661   }
 662   bitField0_ |= 0x00000002;
 663         column_ = value;
 664         onChanged();
 665         return this;
 666       }
 667       /**
 668        * <code>required string column = 2;</code>
 669        */
 670       public Builder clearColumn() {
 671         bitField0_ = (bitField0_ & ~0x00000002);
 672         column_ = getDefaultInstance().getColumn();
 673         onChanged();
 674         return this;
 675       }
 676       /**
 677        * <code>required string column = 2;</code>
 678        */
 679       public Builder setColumnBytes(
 680           com.google.protobuf.ByteString value) {
 681         if (value == null) {
 682     throw new NullPointerException();
 683   }
 684   bitField0_ |= 0x00000002;
 685         column_ = value;
 686         onChanged();
 687         return this;
 688       }
 689 
 690       // @@protoc_insertion_point(builder_scope:SumRequest)
 691     }
 692 
 693     static {
 694       defaultInstance = new SumRequest(true);
 695       defaultInstance.initFields();
 696     }
 697 
 698     // @@protoc_insertion_point(class_scope:SumRequest)
 699   }
 700 
 701   public interface SumResponseOrBuilder
 702       extends com.google.protobuf.MessageOrBuilder {
 703 
 704     // required int64 sum = 1 [default = 0];
 705     /**
 706      * <code>required int64 sum = 1 [default = 0];</code>
 707      */
 708     boolean hasSum();
 709     /**
 710      * <code>required int64 sum = 1 [default = 0];</code>
 711      */
 712     long getSum();
 713   }
 714   /**
 715    * Protobuf type {@code SumResponse}
 716    */
 717   public static final class SumResponse extends
 718       com.google.protobuf.GeneratedMessage
 719       implements SumResponseOrBuilder {
 720     // Use SumResponse.newBuilder() to construct.
 721     private SumResponse(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
 722       super(builder);
 723       this.unknownFields = builder.getUnknownFields();
 724     }
 725     private SumResponse(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
 726 
 727     private static final SumResponse defaultInstance;
 728     public static SumResponse getDefaultInstance() {
 729       return defaultInstance;
 730     }
 731 
 732     public SumResponse getDefaultInstanceForType() {
 733       return defaultInstance;
 734     }
 735 
 736     private final com.google.protobuf.UnknownFieldSet unknownFields;
 737     @java.lang.Override
 738     public final com.google.protobuf.UnknownFieldSet
 739         getUnknownFields() {
 740       return this.unknownFields;
 741     }
 742     private SumResponse(
 743         com.google.protobuf.CodedInputStream input,
 744         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 745         throws com.google.protobuf.InvalidProtocolBufferException {
 746       initFields();
 747       int mutable_bitField0_ = 0;
 748       com.google.protobuf.UnknownFieldSet.Builder unknownFields =
 749           com.google.protobuf.UnknownFieldSet.newBuilder();
 750       try {
 751         boolean done = false;
 752         while (!done) {
 753           int tag = input.readTag();
 754           switch (tag) {
 755             case 0:
 756               done = true;
 757               break;
 758             default: {
 759               if (!parseUnknownField(input, unknownFields,
 760                                      extensionRegistry, tag)) {
 761                 done = true;
 762               }
 763               break;
 764             }
 765             case 8: {
 766               bitField0_ |= 0x00000001;
 767               sum_ = input.readInt64();
 768               break;
 769             }
 770           }
 771         }
 772       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
 773         throw e.setUnfinishedMessage(this);
 774       } catch (java.io.IOException e) {
 775         throw new com.google.protobuf.InvalidProtocolBufferException(
 776             e.getMessage()).setUnfinishedMessage(this);
 777       } finally {
 778         this.unknownFields = unknownFields.build();
 779         makeExtensionsImmutable();
 780       }
 781     }
 782     public static final com.google.protobuf.Descriptors.Descriptor
 783         getDescriptor() {
 784       return com.endpoint.test.Sum.internal_static_SumResponse_descriptor;
 785     }
 786 
 787     protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
 788         internalGetFieldAccessorTable() {
 789       return com.endpoint.test.Sum.internal_static_SumResponse_fieldAccessorTable
 790           .ensureFieldAccessorsInitialized(
 791               com.endpoint.test.Sum.SumResponse.class, com.endpoint.test.Sum.SumResponse.Builder.class);
 792     }
 793 
 794     public static com.google.protobuf.Parser<SumResponse> PARSER =
 795         new com.google.protobuf.AbstractParser<SumResponse>() {
 796       public SumResponse parsePartialFrom(
 797           com.google.protobuf.CodedInputStream input,
 798           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
 799           throws com.google.protobuf.InvalidProtocolBufferException {
 800         return new SumResponse(input, extensionRegistry);
 801       }
 802     };
 803 
 804     @java.lang.Override
 805     public com.google.protobuf.Parser<SumResponse> getParserForType() {
 806       return PARSER;
 807     }
 808 
 809     private int bitField0_;
 810     // required int64 sum = 1 [default = 0];
 811     public static final int SUM_FIELD_NUMBER = 1;
 812     private long sum_;
 813     /**
 814      * <code>required int64 sum = 1 [default = 0];</code>
 815      */
 816     public boolean hasSum() {
 817       return ((bitField0_ & 0x00000001) == 0x00000001);
 818     }
 819     /**
 820      * <code>required int64 sum = 1 [default = 0];</code>
 821      */
 822     public long getSum() {
 823       return sum_;
 824     }
 825 
 826     private void initFields() {
 827       sum_ = 0L;
 828     }
 829     private byte memoizedIsInitialized = -1;
 830     public final boolean isInitialized() {
 831       byte isInitialized = memoizedIsInitialized;
 832       if (isInitialized != -1) return isInitialized == 1;
 833 
 834       if (!hasSum()) {
 835         memoizedIsInitialized = 0;
 836         return false;
 837       }
 838       memoizedIsInitialized = 1;
 839       return true;
 840     }
 841 
 842     public void writeTo(com.google.protobuf.CodedOutputStream output)
 843                         throws java.io.IOException {
 844       getSerializedSize();
 845       if (((bitFie    

本文由职坐标整理发布,学习更多的大数据技术相关知识,请关注职坐标大技术云计算大技术技术频道!

本文由 @沉沙 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved