本文整理汇总了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;
}
示例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
}
示例3: processForUpsert
import org.apache.kudu.client.Upsert; //导入依赖的package包/类
protected void processForUpsert(KuduExecutionContext kuduExecutionContext)
{
Upsert thisUpsert = kuduTable.newUpsert();
performCommonProcessing(thisUpsert,kuduExecutionContext);
}