Java 类org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema 实例源码

项目:ditb    文件:HTableDescriptor.java   
/**
 * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix
 * @return An instance of {@link HTableDescriptor} made from <code>bytes</code>
 * @throws DeserializationException
 * @throws IOException
 * @see #toByteArray()
 */
public static HTableDescriptor parseFrom(final byte [] bytes)
throws DeserializationException, IOException {
  if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
    return (HTableDescriptor)Writables.getWritable(bytes, new HTableDescriptor());
  }
  int pblen = ProtobufUtil.lengthOfPBMagic();
  TableSchema.Builder builder = TableSchema.newBuilder();
  TableSchema ts;
  try {
    ProtobufUtil.mergeFrom(builder, bytes, pblen, bytes.length - pblen);
    ts = builder.build();
  } catch (IOException e) {
    throw new DeserializationException(e);
  }
  return convert(ts);
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * Get list of table descriptors by namespace
 * @param name namespace name
 * @return A descriptor
 * @throws IOException
 */
@Override
public HTableDescriptor[] listTableDescriptorsByNamespace(final String name) throws IOException {
  return
      executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) {
        @Override
        public HTableDescriptor[] call(int callTimeout) throws Exception {
          PayloadCarryingRpcController controller = rpcControllerFactory.newController();
          controller.setCallTimeout(callTimeout);
          List<TableSchema> list =
              master.listTableDescriptorsByNamespace(controller,
                ListTableDescriptorsByNamespaceRequest.newBuilder().setNamespaceName(name)
                .build()).getTableSchemaList();
          HTableDescriptor[] res = new HTableDescriptor[list.size()];
          for(int i=0; i < list.size(); i++) {

            res[i] = HTableDescriptor.convert(list.get(i));
          }
          return res;
        }
      });
}
项目:pbase    文件:HTableDescriptor.java   
/**
 * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix
 * @return An instance of {@link HTableDescriptor} made from <code>bytes</code>
 * @throws DeserializationException
 * @throws IOException
 * @see #toByteArray()
 */
public static HTableDescriptor parseFrom(final byte [] bytes)
throws DeserializationException, IOException {
  if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
    return (HTableDescriptor)Writables.getWritable(bytes, new HTableDescriptor());
  }
  int pblen = ProtobufUtil.lengthOfPBMagic();
  TableSchema.Builder builder = TableSchema.newBuilder();
  TableSchema ts;
  try {
    ts = builder.mergeFrom(bytes, pblen, bytes.length - pblen).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return convert(ts);
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * Get list of table descriptors by namespace
 * @param name namespace name
 * @return A descriptor
 * @throws IOException
 */
@Override
public HTableDescriptor[] listTableDescriptorsByNamespace(final String name) throws IOException {
  return
      executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) {
        @Override
        public HTableDescriptor[] call(int callTimeout) throws Exception {
          List<TableSchema> list =
            master.listTableDescriptorsByNamespace(null, ListTableDescriptorsByNamespaceRequest.
              newBuilder().setNamespaceName(name).build()).getTableSchemaList();
          HTableDescriptor[] res = new HTableDescriptor[list.size()];
          for(int i=0; i < list.size(); i++) {

            res[i] = HTableDescriptor.convert(list.get(i));
          }
          return res;
        }
      });
}
项目:HIndex    文件:HTableDescriptor.java   
/**
 * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix
 * @return An instance of {@link HTableDescriptor} made from <code>bytes</code>
 * @throws DeserializationException
 * @throws IOException
 * @see #toByteArray()
 */
public static HTableDescriptor parseFrom(final byte [] bytes)
throws DeserializationException, IOException {
  if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
    return (HTableDescriptor)Writables.getWritable(bytes, new HTableDescriptor());
  }
  int pblen = ProtobufUtil.lengthOfPBMagic();
  TableSchema.Builder builder = TableSchema.newBuilder();
  TableSchema ts;
  try {
    ts = builder.mergeFrom(bytes, pblen, bytes.length - pblen).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return convert(ts);
}
项目:HIndex    文件:HBaseAdmin.java   
/**
 * Get list of table descriptors by namespace
 * @param name namespace name
 * @return A descriptor
 * @throws IOException
 */
public HTableDescriptor[] listTableDescriptorsByNamespace(final String name) throws IOException {
  return
      executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) {
        @Override
        public HTableDescriptor[] call() throws Exception {
          List<TableSchema> list =
            master.listTableDescriptorsByNamespace(null, ListTableDescriptorsByNamespaceRequest.
              newBuilder().setNamespaceName(name).build()).getTableSchemaList();
          HTableDescriptor[] res = new HTableDescriptor[list.size()];
          for(int i=0; i < list.size(); i++) {

            res[i] = HTableDescriptor.convert(list.get(i));
          }
          return res;
        }
      });
}
项目:PyroDB    文件:HTableDescriptor.java   
/**
 * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix
 * @return An instance of {@link HTableDescriptor} made from <code>bytes</code>
 * @throws DeserializationException
 * @throws IOException
 * @see #toByteArray()
 */
public static HTableDescriptor parseFrom(final byte [] bytes)
throws DeserializationException, IOException {
  if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
    return (HTableDescriptor)Writables.getWritable(bytes, new HTableDescriptor());
  }
  int pblen = ProtobufUtil.lengthOfPBMagic();
  TableSchema.Builder builder = TableSchema.newBuilder();
  TableSchema ts;
  try {
    ts = builder.mergeFrom(bytes, pblen, bytes.length - pblen).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return convert(ts);
}
项目:PyroDB    文件:HBaseAdmin.java   
/**
 * Get list of table descriptors by namespace
 * @param name namespace name
 * @return A descriptor
 * @throws IOException
 */
public HTableDescriptor[] listTableDescriptorsByNamespace(final String name) throws IOException {
  return
      executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) {
        @Override
        public HTableDescriptor[] call(int callTimeout) throws Exception {
          List<TableSchema> list =
            master.listTableDescriptorsByNamespace(null, ListTableDescriptorsByNamespaceRequest.
              newBuilder().setNamespaceName(name).build()).getTableSchemaList();
          HTableDescriptor[] res = new HTableDescriptor[list.size()];
          for(int i=0; i < list.size(); i++) {

            res[i] = HTableDescriptor.convert(list.get(i));
          }
          return res;
        }
      });
}
项目:c5    文件:HTableDescriptor.java   
/**
 * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix
 * @return An instance of {@link HTableDescriptor} made from <code>bytes</code>
 * @throws DeserializationException
 * @throws IOException
 * @see #toByteArray()
 */
public static HTableDescriptor parseFrom(final byte [] bytes)
throws DeserializationException, IOException {
  if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
    return (HTableDescriptor)Writables.getWritable(bytes, new HTableDescriptor());
  }
  int pblen = ProtobufUtil.lengthOfPBMagic();
  TableSchema.Builder builder = TableSchema.newBuilder();
  TableSchema ts;
  try {
    ts = builder.mergeFrom(bytes, pblen, bytes.length - pblen).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return convert(ts);
}
项目:c5    文件:HBaseAdmin.java   
/**
 * Get list of table descriptors by namespace
 * @param name namespace name
 * @return A descriptor
 * @throws IOException
 */
public HTableDescriptor[] listTableDescriptorsByNamespace(final String name) throws IOException {
  return
      executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) {
        @Override
        public HTableDescriptor[] call() throws Exception {
          List<TableSchema> list =
            master.listTableDescriptorsByNamespace(null, ListTableDescriptorsByNamespaceRequest.
              newBuilder().setNamespaceName(name).build()).getTableSchemaList();
          HTableDescriptor[] res = new HTableDescriptor[list.size()];
          for(int i=0; i < list.size(); i++) {

            res[i] = HTableDescriptor.convert(list.get(i));
          }
          return res;
        }
      });
}
项目:DominoHBase    文件:HTableDescriptor.java   
/**
 * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix
 * @return An instance of {@link HTableDescriptor} made from <code>bytes</code>
 * @throws DeserializationException
 * @throws IOException 
 * @see #toByteArray()
 */
public static HTableDescriptor parseFrom(final byte [] bytes)
throws DeserializationException, IOException {
  if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
    return (HTableDescriptor)Writables.getWritable(bytes, new HTableDescriptor());
  }
  int pblen = ProtobufUtil.lengthOfPBMagic();
  TableSchema.Builder builder = TableSchema.newBuilder();
  TableSchema ts;
  try {
    ts = builder.mergeFrom(bytes, pblen, bytes.length - pblen).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return convert(ts);
}
项目:DominoHBase    文件:HTableDescriptor.java   
/**
 * @return Convert the current {@link HTableDescriptor} into a pb TableSchema instance.
 */
public TableSchema convert() {
  TableSchema.Builder builder = TableSchema.newBuilder();
  builder.setName(ByteString.copyFrom(getName()));
  for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e: this.values.entrySet()) {
    BytesBytesPair.Builder aBuilder = BytesBytesPair.newBuilder();
    aBuilder.setFirst(ByteString.copyFrom(e.getKey().get()));
    aBuilder.setSecond(ByteString.copyFrom(e.getValue().get()));
    builder.addAttributes(aBuilder.build());
  }
  for (HColumnDescriptor hcd: getColumnFamilies()) {
    builder.addColumnFamilies(hcd.convert());
  }
  return builder.build();
}
项目:DominoHBase    文件:HTableDescriptor.java   
/**
 * @param ts A pb TableSchema instance.
 * @return An {@link HTableDescriptor} made from the passed in pb <code>ts</code>.
 */
public static HTableDescriptor convert(final TableSchema ts) {
  List<ColumnFamilySchema> list = ts.getColumnFamiliesList();
  HColumnDescriptor [] hcds = new HColumnDescriptor[list.size()];
  int index = 0;
  for (ColumnFamilySchema cfs: list) {
    hcds[index++] = HColumnDescriptor.convert(cfs);
  }
  HTableDescriptor htd = new HTableDescriptor(ts.getName().toByteArray(), hcds);
  for (BytesBytesPair a: ts.getAttributesList()) {
    htd.setValue(a.getFirst().toByteArray(), a.getSecond().toByteArray());
  }
  return htd;
}
项目:DominoHBase    文件:HConnectionManager.java   
/**
 * Connects to the master to get the table descriptor.
 * @param tableName table name
 * @return
 * @throws IOException if the connection to master fails or if the table
 *  is not found.
 */
@Override
public HTableDescriptor getHTableDescriptor(final byte[] tableName)
throws IOException {
  if (tableName == null || tableName.length == 0) return null;
  if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
    return new UnmodifyableHTableDescriptor(HTableDescriptor.ROOT_TABLEDESC);
  }
  if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
    return HTableDescriptor.META_TABLEDESC;
  }
  MasterMonitorKeepAliveConnection master = getKeepAliveMasterMonitor();
  GetTableDescriptorsResponse htds;
  try {
    GetTableDescriptorsRequest req =
      RequestConverter.buildGetTableDescriptorsRequest(null);
    htds = master.getTableDescriptors(null, req);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  } finally {
    master.close();
  }
  for (TableSchema ts : htds.getTableSchemaList()) {
    if (Bytes.equals(tableName, ts.getName().toByteArray())) {
      return HTableDescriptor.convert(ts);
    }
  }
  throw new TableNotFoundException(Bytes.toString(tableName));
}