2010-01-25 80 views
-2

我想在Google大表格中使用java和servelt代码创建表格? 如何创建表并插入Google大表数据库? 我想样品编码在谷歌大表中创建表?如何在Google Bigtable中创建表格

+0

“我想” 没有得到:) – MarkR 2010-01-26 08:34:37

回答

1

六年后,现在可以。看看这个快速入门页面,了解如何获取Bigtable实例并开始写入它 https://cloud.google.com/bigtable/docs/quickstart

然后这里是一个示例“Hello,World!”应用 https://cloud.google.com/bigtable/docs/samples-java-hello

例如

try (Connection connection = BigtableConfiguration.connect(projectId, instanceId)) { 

     Admin admin = connection.getAdmin(); 

     HTableDescriptor descriptor = new HTableDescriptor(TableName.valueOf(TABLE_NAME)); 
     descriptor.addFamily(new HColumnDescriptor(COLUMN_FAMILY_NAME)); 

     print("Create table " + descriptor.getNameAsString()); 
     admin.createTable(descriptor); 

     Table table = connection.getTable(TableName.valueOf(TABLE_NAME)); 

     print("Write some greetings to the table"); 
     for (int i = 0; i < GREETINGS.length; i++) { 
     String rowKey = "greeting" + i; 

     Put put = new Put(Bytes.toBytes(rowKey)); 
     put.addColumn(COLUMN_FAMILY_NAME, COLUMN_NAME, Bytes.toBytes(GREETINGS[i])); 
     table.put(put); 
     } 

     String rowKey = "greeting0"; 
     Result getResult = table.get(new Get(Bytes.toBytes(rowKey))); 
}