当前位置: 首页>>代码示例>>Java>>正文


Java ByteString.toByteArray方法代码示例

本文整理汇总了Java中com.google.protobuf.ByteString.toByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java ByteString.toByteArray方法的具体用法?Java ByteString.toByteArray怎么用?Java ByteString.toByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.ByteString的用法示例。


在下文中一共展示了ByteString.toByteArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doMetaGetResponse

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
static GetResponse doMetaGetResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final GetRequest request) {
  ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
  ByteString row = request.getGet().getRow();
  Pair<HRegionInfo, ServerName> p = meta.get(row.toByteArray());
  if (p == null) {
    if (request.getGet().getClosestRowBefore()) {
      byte [] bytes = row.toByteArray();
      SortedMap<byte [], Pair<HRegionInfo, ServerName>> head =
        bytes != null? meta.headMap(bytes): meta;
      p = head == null? null: head.get(head.lastKey());
    }
  }
  if (p != null) {
    resultBuilder.addCell(getRegionInfo(row, p.getFirst()));
    resultBuilder.addCell(getServer(row, p.getSecond()));
  }
  resultBuilder.addCell(getStartCode(row));
  GetResponse.Builder builder = GetResponse.newBuilder();
  builder.setResult(resultBuilder.build());
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestClientNoCluster.java

示例2: convertUpdateIndexUseKryo

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public static int[] convertUpdateIndexUseKryo(ByteString neededColIndexes) {
  Input input = new Input(neededColIndexes.toByteArray());
  Kryo kryo = new Kryo();
  kryo.register(Integer.class);

  int size = kryo.readObject(input, Integer.class);
  int[] ret = new int[size];
  for (int i = 0; i < size; i++) {
    ret[i] = kryo.readObject(input, Integer.class);
  }
  return ret;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:ProtobufUtil.java

示例3: testBuildPartitionResult

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
/**
 * testBuildPartitionResult
 */
public void testBuildPartitionResult() throws Exception {
    Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SPECIAL_FACILITY); 
    VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
    assertNotNull(vt);
    int num_rows = 50;
    for (int i = 0; i < num_rows; i++) {
        Object row[] = new Object[catalog_tbl.getColumns().size()];
        for (int j = 0; j < row.length; j++) {
            VoltType vtype = VoltType.get(catalog_tbl.getColumns().get(j).getType());
            row[j] = VoltTypeUtil.getRandomValue(vtype, rand);
        } // FOR
        vt.addRow(row);
    } // FOR
    
    int dep_id = 10001;
    DependencySet result = new DependencySet(new int[]{ dep_id }, new VoltTable[]{ vt });
    
    RemoteTransaction ts = new RemoteTransaction(hstore_site);
    WorkResult partitionResult = executor.buildWorkResult(ts, result, Status.OK, null);
    assertNotNull(partitionResult);
    assertEquals(result.size(), partitionResult.getDepDataCount());
    
    assertEquals(1, partitionResult.getDepDataCount());
    for (int i = 0; i < partitionResult.getDepDataCount(); i++) {
        assertEquals(dep_id, partitionResult.getDepId(i));
        
        ByteString bs = partitionResult.getDepData(i);
        assertFalse(bs.isEmpty());
        System.err.println("SIZE: " + StringUtil.md5sum(bs.asReadOnlyByteBuffer()));
        
        byte serialized[] = bs.toByteArray();
        VoltTable clone = FastDeserializer.deserialize(serialized, VoltTable.class);
        assertNotNull(clone);
        assertEquals(vt.getRowCount(), clone.getRowCount());
        assertEquals(vt.getColumnCount(), clone.getColumnCount());
    } // FOR
    
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:42,代码来源:TestPartitionExecutor.java

示例4: getPropertyValue

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
/**
 * Extracts an additional property byte value from a map with immutable ByteString values.
 */
@Nullable
public static byte[] getPropertyValue(
        Map<String, ByteString> additionalProperties,
        String key) {
    ByteString value = additionalProperties.get(key);
    if (value == null) {
        return null;
    }

    return value.toByteArray();
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:15,代码来源:AdditionalPropertiesUtil.java

示例5: decodeHashDataKey

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
private Pair<ByteString, ByteString> decodeHashDataKey(ByteString rawKey) {
  checkArgument(
      KeyUtils.hasPrefix(rawKey, ByteString.copyFrom(prefix)),
      "invalid encoded hash data key prefix: " + new String(prefix));
  CodecDataInput cdi = new CodecDataInput(rawKey.toByteArray());
  cdi.skipBytes(prefix.length);
  byte[] key = BytesType.readBytes(cdi);
  long typeFlag = IntegerType.readULong(cdi);
  if (typeFlag != HASH_DATA_FLAG) {
    throw new TiClientInternalException("Invalid hash data flag: " + typeFlag);
  }
  byte[] field = BytesType.readBytes(cdi);
  return Pair.create(ByteString.copyFrom(key), ByteString.copyFrom(field));
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:15,代码来源:CatalogTransaction.java

示例6: testDe

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Test
public void testDe() {
    String msg = "brMcxcmVDxcd1IAs1z4LsXWXrZFfV+UBo37vcxL/NUY=";
    ByteString b = ByteString.copyFromUtf8(msg);
    byte[] o = b.toByteArray();
    
    byte[] r = SecurityUtils.getInstance().DecryptMsg(o);
    byte[] a =SecurityUtils.getInstance().EncryptMsg(new String(r));
    
    //System.out.println(new String(r));
    Assert.assertArrayEquals(o, a);
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:13,代码来源:SecurityUtilsTest.java

示例7: get

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Override
public byte[] get(byte[] k) {
  ByteString key = ByteString.copyFrom(k);
  ByteString bytes = cachedWrites.get(key);
  if (bytes != null) {
    // we haven't written these yet
    return bytes.toByteArray();
  }
  TiKV.GetLocation keyLocation = tiKV.getKeyLocation(key);
  Kvrpcpb.Context context = keyLocation.getContext();
  RPC kvRPC = keyLocation.getKvRPC();

  Kvrpcpb.CmdGetRequest.Builder getReq = Kvrpcpb.CmdGetRequest.newBuilder();
  getReq.setKey(key);
  if (timestamp == 0) {
    timestamp = tiKV.getTimestamp();
  }

  getReq.setVersion(timestamp);
  Msgpb.Message.Builder getMessage = Msgpb.Message.newBuilder();
  getMessage.setMsgType(Msgpb.MessageType.KvReq);
  Kvrpcpb.Request.Builder kvReq = Kvrpcpb.Request.newBuilder()
          .setContext(context)
          .setCmdGetReq(getReq)
          .setType(Kvrpcpb.MessageType.CmdGet);
  getMessage.setKvReq(kvReq);
  Msgpb.Message getResponse = null;
  try {
    getResponse = kvRPC.send(getMessage.build());
    Kvrpcpb.CmdGetResponse cmdGetResp = getResponse.getKvResp().getCmdGetResp();
    Kvrpcpb.KeyError error = cmdGetResp.getError();
    if (error != null) {
      // Need to retry transactions that retryable / restart on abort
      throw new TiException("Error getting key: " + error);
    }
    return cmdGetResp.getValue().toByteArray();
  } catch (IOException e) {
    throw new TiException("Failed to get key", e);
  }
}
 
开发者ID:spullara,项目名称:tikvclient,代码行数:41,代码来源:TiTx.java

示例8: getBytesFromResponse

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
byte[] getBytesFromResponse(ByteString response) {
  ByteBuffer bb = response.asReadOnlyByteBuffer();
  bb.rewind();
  byte[] bytes;
  if (bb.hasArray()) {
    bytes = bb.array();
  } else {
    bytes = response.toByteArray();
  }
  return bytes;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:AggregationClient.java

示例9: convert

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
@Override
public byte[] convert(ByteString value) {
    return value.toByteArray();
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:5,代码来源:ByteStringConverters.java

示例10: getLatestSchemaVersion

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public long getLatestSchemaVersion() {
  ByteString versionBytes = bytesGet(KEY_SCHEMA_VERSION);
  CodecDataInput cdi = new CodecDataInput(versionBytes.toByteArray());
  return Long.parseLong(new String(cdi.toByteArray(), StandardCharsets.UTF_8));
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:6,代码来源:CatalogTransaction.java

示例11: get

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public byte[] get(byte[] key) {
  ByteString keyString = ByteString.copyFrom(key);
  ByteString value = get(keyString);
  return value.toByteArray();
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:6,代码来源:Snapshot.java

示例12: CodecDataInput

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public CodecDataInput(ByteString data) {
  this(data.toByteArray());
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:4,代码来源:CodecDataInput.java

示例13: ByteStringToBytes

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
public static byte[] ByteStringToBytes(ByteString byteString) {
    return byteString == null ? null : byteString.toByteArray();
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:4,代码来源:_ProtobufMappers.java

示例14: rollHLogWriter

import com.google.protobuf.ByteString; //导入方法依赖的package包/类
/**
 * Roll the log writer. I.e. when using a file system based write ahead log,
 * start writing log messages to a new file.
 *
 * Note that when talking to a version 1.0+ HBase deployment, the rolling is asynchronous.
 * This method will return as soon as the roll is requested and the return value will
 * always be null. Additionally, the named region server may schedule store flushes at the
 * request of the wal handling the roll request.
 *
 * When talking to a 0.98 or older HBase deployment, the rolling is synchronous and the
 * return value may be either null or a list of encoded region names.
 *
 * @param serverName
 *          The servername of the regionserver. A server name is made of host,
 *          port and startcode. This is mandatory. Here is an example:
 *          <code> host187.example.com,60020,1289493121758</code>
 * @return a set of {@link HRegionInfo#getEncodedName()} that would allow the wal to
 *         clean up some underlying files. null if there's nothing to flush.
 * @throws IOException if a remote or network exception occurs
 * @throws FailedLogCloseException
 * @deprecated use {@link #rollWALWriter(ServerName)}
 */
@Deprecated
public synchronized byte[][] rollHLogWriter(String serverName)
    throws IOException, FailedLogCloseException {
  ServerName sn = ServerName.valueOf(serverName);
  final RollWALWriterResponse response = rollWALWriterImpl(sn);
  int regionCount = response.getRegionToFlushCount();
  if (0 == regionCount) {
    return null;
  }
  byte[][] regionsToFlush = new byte[regionCount][];
  for (int i = 0; i < regionCount; i++) {
    ByteString region = response.getRegionToFlush(i);
    regionsToFlush[i] = region.toByteArray();
  }
  return regionsToFlush;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:HBaseAdmin.java


注:本文中的com.google.protobuf.ByteString.toByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。