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


Java Upsert类代码示例

本文整理汇总了Java中org.apache.kudu.client.Upsert的典型用法代码示例。如果您正苦于以下问题:Java Upsert类的具体用法?Java Upsert怎么用?Java Upsert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: insertDatapoint

import org.apache.kudu.client.Upsert; //导入依赖的package包/类
public Upsert insertDatapoint(final String metric,
                              final int tagsetID,
                              final long time,
                              final double value) {
  Upsert insert = table.newUpsert();
  insert.getRow().addString(Tables.METRICS_METRIC_INDEX, metric);
  insert.getRow().addInt(Tables.METRICS_TAGSET_ID_INDEX, tagsetID);
  insert.getRow().addLong(Tables.METRICS_TIME_INDEX, time);
  insert.getRow().addDouble(Tables.METRICS_VALUE_INDEX, value);
  return insert;
}
 
开发者ID:danburkert,项目名称:kudu-ts,代码行数:12,代码来源:Metrics.java

示例2: addTestDataRows

import org.apache.kudu.client.Upsert; //导入依赖的package包/类
public void addTestDataRows(int numRowsInEachPartition) throws Exception
{
  int intRowKeyStepsize = Integer.MAX_VALUE / SPLIT_COUNT_FOR_INT_ROW_KEY;
  int splitBoundaryForIntRowKey = intRowKeyStepsize;
  int[] inputrowkeyPartitionEntries = new int[SPLIT_COUNT_FOR_INT_ROW_KEY + 1];
  // setting the int keys that will fall in the range of all partitions
  for ( int i = 0; i < SPLIT_COUNT_FOR_INT_ROW_KEY; i++) {
    inputrowkeyPartitionEntries[i] = splitBoundaryForIntRowKey + 3; // 3 to fall into the partition next to boundary
    splitBoundaryForIntRowKey += intRowKeyStepsize;
  }
  inputrowkeyPartitionEntries[SPLIT_COUNT_FOR_INT_ROW_KEY] = splitBoundaryForIntRowKey + 3;
  AbstractKuduPartitionScanner<UnitTestTablePojo,InputOperatorControlTuple> scannerForAddingRows =
      unitTestStepwiseScanInputOperator.getScanner();
  ApexKuduConnection aCurrentConnection = scannerForAddingRows.getConnectionPoolForThreads().get(0);
  KuduSession aSessionForInserts = aCurrentConnection.getKuduClient().newSession();
  KuduTable currentTable = aCurrentConnection.getKuduTable();
  long seedValueForTimestampRowKey = 0L; // constant to allow for data landing on first partition for unit tests
  for ( int i = 0; i <= SPLIT_COUNT_FOR_INT_ROW_KEY; i++) { // range key iterator
    int intRowKeyBaseValue = inputrowkeyPartitionEntries[i] + i;
    for ( int k = 0; k < 2; k++) { // hash key iterator . The table defines two hash partitions
      long timestampRowKeyValue = seedValueForTimestampRowKey + k; // to avoid spilling to another tablet
      String stringRowKeyValue = "" + timestampRowKeyValue + k; // to avoid spilling to another tablet randomly
      for ( int y = 0; y < numRowsInEachPartition; y++) {
        Upsert aNewRow = currentTable.newUpsert();
        PartialRow rowValue  = aNewRow.getRow();
        // Start assigning row keys below the current split boundary.
        rowValue.addInt("introwkey",intRowKeyBaseValue - y - 1);
        rowValue.addString("stringrowkey",stringRowKeyValue);
        rowValue.addLong("timestamprowkey",timestampRowKeyValue);
        rowValue.addLong("longdata",(seedValueForTimestampRowKey + y));
        rowValue.addString("stringdata", ("" + seedValueForTimestampRowKey + y));
        OperationResponse response = aSessionForInserts.apply(aNewRow);
      }
    }
  }
  List<OperationResponse> insertResponse = aSessionForInserts.flush();
  aSessionForInserts.close();
  Thread.sleep(2000); // Sleep to allow for scans to complete
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:40,代码来源:KuduInputOperatorCommons.java

示例3: processForUpsert

import org.apache.kudu.client.Upsert; //导入依赖的package包/类
protected void processForUpsert(KuduExecutionContext kuduExecutionContext)
{
  Upsert thisUpsert = kuduTable.newUpsert();
  performCommonProcessing(thisUpsert,kuduExecutionContext);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:6,代码来源:AbstractKuduOutputOperator.java


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