本文整理汇总了Java中org.apache.kudu.client.OperationResponse类的典型用法代码示例。如果您正苦于以下问题:Java OperationResponse类的具体用法?Java OperationResponse怎么用?Java OperationResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperationResponse类属于org.apache.kudu.client包,在下文中一共展示了OperationResponse类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: insertTagset
import org.apache.kudu.client.OperationResponse; //导入依赖的package包/类
/**
* Attempts to insert the provided tagset and ID. Returns {@code true} if the
* write was successful, or {@code false} if the write failed due to a tagset
* with the same ID already existing in the table.
*
* @param tagset the tagset to insert
* @param id the ID to insert the tagset with
* @return whether the write succeeded
*/
private Deferred<Boolean> insertTagset(final SerializedTagset tagset, final int id) throws KuduException {
final class InsertTagsetCB implements Callback<Deferred<Boolean>, OperationResponse> {
@Override
public Deferred<Boolean> call(OperationResponse response) {
if (response.hasRowError()) {
if (response.getRowError().getErrorStatus().isAlreadyPresent()) {
LOG.info("Attempted to insert duplicate tagset; id: {}, tagset: {}", id, tagset);
// TODO: Consider adding a backoff with jitter before attempting
// the insert again (if the lookup fails).
return Deferred.fromResult(false);
}
return Deferred.fromError(new RuntimeException(
String.format("Unable to insert tagset; id: %s, tagset: %s, error: %s",
id, tagset, response.getRowError())));
} else {
return Deferred.fromResult(true);
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).toString();
}
}
LOG.debug("Inserting tagset; id: {}, tags: {}", id, tagset);
final AsyncKuduSession session = client.newSession();
try {
// We don't have to handle PleaseThrottleException because we are only
// inserting a single row.
final Insert insert = tagsetsTable.newInsert();
insert.getRow().addInt(Tables.TAGSETS_ID_INDEX, id);
insert.getRow().addBinary(Tables.TAGSETS_TAGSET_INDEX, tagset.getBytes());
return session.apply(insert).addCallbackDeferring(new InsertTagsetCB());
} finally {
session.close();
}
}
开发者ID:danburkert,项目名称:kudu-ts,代码行数:47,代码来源:Tagsets.java
示例2: writeDatapoint
import org.apache.kudu.client.OperationResponse; //导入依赖的package包/类
public OperationResponse writeDatapoint(final String metric,
SortedMap<String, String> tags,
final long time,
final double value) throws Exception {
int tagsetID = tagsets.getTagsetID(tags)
.joinUninterruptibly(session.getTimeoutMillis());
return session.apply(metrics.insertDatapoint(metric, tagsetID, time, value));
}
开发者ID:danburkert,项目名称:kudu-ts,代码行数:9,代码来源:WriteBatch.java
示例3: flush
import org.apache.kudu.client.OperationResponse; //导入依赖的package包/类
private void flush() throws IOException {
try {
// context.getStats().startWait();
List<OperationResponse> responses = session.flush();
for (OperationResponse response : responses) {
if (response.hasRowError()) {
throw new IOException(response.getRowError().toString());
}
}
} catch (Exception e) {
throw new IOException(e);
} finally {
// context.getStats().stopWait();
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:16,代码来源:KuduRecordWriterImpl.java
示例4: addTestDataRows
import org.apache.kudu.client.OperationResponse; //导入依赖的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
示例5: insertTagset
import org.apache.kudu.client.OperationResponse; //导入依赖的package包/类
/**
* Insert a tagset into the {@code tags} table.
* @param id the tagset ID.
* @param tagset the tagset.
* @return The tagset ID.
*/
public Deferred<Integer> insertTagset(final int id, final SortedMap<String, String> tagset)
throws KuduException {
if (tagset.isEmpty()) { return Deferred.fromResult(id); }
LOG.debug("Inserting tags; tagsetID: {}, tags: {}", id, tagset);
final AsyncKuduSession session = client.newSession();
class InsertTagsetCB implements Callback<Deferred<Integer>, List<OperationResponse>> {
@Override
public Deferred<Integer> call(List<OperationResponse> responses) {
try {
for (OperationResponse response : responses) {
if (response.hasRowError()) {
return Deferred.fromError(new RuntimeException(
String.format("Unable to insert tag: %s", response.getRowError())));
}
}
return Deferred.fromResult(id);
} finally {
session.close();
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("tags", tagset)
.toString();
}
}
if (tagset.size() > 1000) {
session.setMutationBufferSpace(tagset.size());
}
session.setMutationBufferLowWatermark(1.0f);
// buffer all of the tags into the session, and ensure that we don't get
// a PleaseThrottleException. In practice the number of tags should be
// small.
session.setMutationBufferSpace(tagset.size());
session.setMutationBufferLowWatermark(1.0f);
session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
for (Map.Entry<String, String> tag : tagset.entrySet()) {
Insert insert = table.newInsert();
// TODO: check with JD that if the inserts below fail, the error will
// also be returned in the flush call.
insert.getRow().addString(Tables.TAGS_KEY_INDEX, tag.getKey());
insert.getRow().addString(Tables.TAGS_VALUE_INDEX, tag.getValue());
insert.getRow().addInt(Tables.TAGS_TAGSET_ID_INDEX, id);
session.apply(insert);
}
return session.flush().addCallbackDeferring(new InsertTagsetCB());
}
开发者ID:danburkert,项目名称:kudu-ts,代码行数:59,代码来源:Tags.java
示例6: flush
import org.apache.kudu.client.OperationResponse; //导入依赖的package包/类
/**
* Blocking call that force flushes this batch's buffers. Data is persisted
* when this call returns, else it will throw an exception.
* @return a list of OperationResponse, one per datapoint that was flushed
* @throws Exception if anything went wrong. If it's an issue with some or all batches,
* it will be of type DeferredGroupException.
*/
public List<OperationResponse> flush() throws Exception {
return session.flush();
}
开发者ID:danburkert,项目名称:kudu-ts,代码行数:11,代码来源:WriteBatch.java
示例7: close
import org.apache.kudu.client.OperationResponse; //导入依赖的package包/类
/**
* Blocking call that flushes the buffers (see {@link #flush} and closes the batch.
* @return List of OperationResponse, one per datapoint that was flushed
* @throws Exception if anything went wrong. If it's an issue with some or all batches,
* it will be of type DeferredGroupException.
*/
public List<OperationResponse> close() throws Exception {
return session.close();
}
开发者ID:danburkert,项目名称:kudu-ts,代码行数:10,代码来源:WriteBatch.java
注:本文中的org.apache.kudu.client.OperationResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论