本文整理匯總了Java中com.taobao.tddl.executor.record.CloneableRecord.getMap方法的典型用法代碼示例。如果您正苦於以下問題:Java CloneableRecord.getMap方法的具體用法?Java CloneableRecord.getMap怎麽用?Java CloneableRecord.getMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.taobao.tddl.executor.record.CloneableRecord
的用法示例。
在下文中一共展示了CloneableRecord.getMap方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: delete
import com.taobao.tddl.executor.record.CloneableRecord; //導入方法依賴的package包/類
@Override
public void delete(ExecutionContext executionContext, CloneableRecord key, IndexMeta indexMeta, String dbName)
throws TddlException {
List<HbData> opDatas = new ArrayList<HbData>();
Map<String, Object> cvs = key.getMap();
Map<String, Object> rowKeyColumnValues = new HashMap();
for (String rowKeyColumn : this.physicalSchema.getRowKey()) {
rowKeyColumnValues.put(rowKeyColumn, key.get(rowKeyColumn));
}
byte[] rowKey = this.physicalSchema.getRowKeyGenerator().encodeRowKey(rowKeyColumnValues);
for (Map.Entry<String, Object> entry : cvs.entrySet()) {
if (!this.physicalSchema.getRowKey().contains(entry.getKey())) {
String[] familyAndCol = physicalSchema.getRealColumn(entry.getKey()).split(HbConstant.CF_COL_SPLITOR);
HbData opData = new HbData();
opData.setRowKey(rowKey);
opData.setTableName(dbName);
opData.addColumn(new HbColumn(familyAndCol[0], familyAndCol[1]));
opDatas.add(opData);
}
}
hbOperate.mdelete(opDatas);
}
示例2: put
import com.taobao.tddl.executor.record.CloneableRecord; //導入方法依賴的package包/類
@Override
public void put(ExecutionContext executionContext, CloneableRecord key, CloneableRecord value, IndexMeta indexMeta,
String dbName) throws TddlException {
Map<String, Object> cvs = value.getMap();
List<HbData> opDatas = new ArrayList<HbData>();
Map<String, Object> rowKeyColumnsAndValues = new HashMap();
for (ColumnMeta keyColumn : schema.getPrimaryKey()) {
rowKeyColumnsAndValues.put(keyColumn.getName(), key.get(keyColumn.getName()));
}
byte[] rowKey = physicalSchema.getRowKeyGenerator().encodeRowKey(rowKeyColumnsAndValues);
for (Map.Entry<String, Object> entry : cvs.entrySet()) {
String[] familyAndColumn = physicalSchema.getRealColumn(entry.getKey()).split(HbConstant.CF_COL_SPLITOR);
HbData opData = new HbData();
// opData.setRowKey(HbResultConvertor.changeToBytes(key.get(HbConstant.ROWKEY),
// schema.getColumn(HbConstant.ROWKEY)));
opData.setRowKey(rowKey);
opData.setTableName(dbName);
ColumnMeta cm = schema.getColumn(entry.getKey());
byte[] columnByteValue = null;
columnByteValue = this.physicalSchema.getColumnCoders()
.get(cm.getName())
.encodeToBytes(cm.getDataType(), entry.getValue());
opData.addColumn(new HbColumn(familyAndColumn[0], familyAndColumn[1], columnByteValue));
opDatas.add(opData);
}
hbOperate.mput(opDatas);
}
示例3: getRecordFromRightByValueFilter
import com.taobao.tddl.executor.record.CloneableRecord; //導入方法依賴的package包/類
protected Map<CloneableRecord, DuplicateKVPair> getRecordFromRightByValueFilter(List<CloneableRecord> leftJoinOnColumnCache)
throws TddlException {
right_cursor.beforeFirst();
if (isLeftOutJoin() && this.rightCursorMeta == null) {
IRowSet kv = right_cursor.next();
if (kv != null) {
this.rightCursorMeta = kv.getParentCursorMeta();
} else {
rightCursorMeta = CursorMetaImp.buildNew(right_cursor.getReturnColumns());
}
right_cursor.beforeFirst();
}
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setOperation(OPERATION.IN);
ibf.setValues(new ArrayList<Object>());
for (CloneableRecord record : leftJoinOnColumnCache) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() == 1) {
// 單字段in
Entry<String, Object> entry = recordMap.entrySet().iterator().next();
Object comp = entry.getValue();
ibf.setColumn(this.rightJoinOnColumns.get(0).copy());
ibf.getValues().add(comp);
} else {
// 多字段in
if (ibf.getColumn() == null) {
ibf.setColumn(buildRowFunction(recordMap.keySet(), true, record));
}
ibf.getValues().add(buildRowFunction(recordMap.values(), false, record));
}
}
IColumn rightColumn = (IColumn) this.rightJoinOnColumns.get(0);
IValueFilterCursor vfc = this.cursorFactory.valueFilterCursor(executionContext, right_cursor, ibf);
Map<CloneableRecord, DuplicateKVPair> records = new HashMap();
if (isLeftOutJoin() && !isRightOutJoin()) {
blockNestedLoopJoin(leftJoinOnColumnCache, rightColumn, vfc, records);
} else if (!isLeftOutJoin() && !isRightOutJoin()) {
// inner join
blockNestedLoopJoin(leftJoinOnColumnCache, rightColumn, vfc, records);
} else {
throw new UnsupportedOperationException("leftOutJoin:" + isLeftOutJoin() + " ; rightOutJoin:"
+ isRightOutJoin());
}
return records;
}
示例4: mgetWithDuplicate
import com.taobao.tddl.executor.record.CloneableRecord; //導入方法依賴的package包/類
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
init();
if (prefixMatch) {
throw new UnsupportedOperationException("not supported yet");
} else {
// 這裏列的別名也丟了吧 似乎解決了
IQuery iquery = (IQuery) merge.getSubNode();
OptimizerContext optimizerContext = OptimizerContext.getContext();
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setOperation(OPERATION.IN);
ibf.setValues(new ArrayList<Object>());
String colName = null;
for (CloneableRecord record : keys) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() == 1) {
// 單字段in
Entry<String, Object> entry = recordMap.entrySet().iterator().next();
Object comp = entry.getValue();
colName = entry.getKey();
IColumn col = ASTNodeFactory.getInstance()
.createColumn()
.setColumnName(colName)
.setDataType(record.getType(0));
col.setTableName(iquery.getAlias());
ibf.setColumn(col);
ibf.getValues().add(comp);
} else {
// 多字段in
if (ibf.getColumn() == null) {
ibf.setColumn(buildRowFunction(recordMap.keySet(), true, record));
}
ibf.getValues().add(buildRowFunction(recordMap.values(), false, record));
}
}
KVIndexNode query = (KVIndexNode) OptimizerUtils.convertPlanToAst(iquery);
if (keyFilterOrValueFilter) {
query.keyQuery(FilterUtils.and(removeDupFilter(query.getKeyFilter(), ibf), ibf));
} else {
query.valueQuery(FilterUtils.and(removeDupFilter(query.getResultFilter(), ibf), ibf));
}
query.build();
// 優化做法,將數據分配掉。
Integer currentThread = merge.getThread();
executionContext.getExtraCmds().put("initThread", currentThread);
IDataNodeExecutor idne = optimizerContext.getOptimizer().optimizePlan(query,
executionContext.getParams(),
executionContext.getExtraCmds());
ISchematicCursor cursor = null;
Map<CloneableRecord, DuplicateKVPair> duplicateKeyMap = null;
try {
cursor = ExecutorContext.getContext().getTopologyExecutor().execByExecPlanNode(idne, executionContext);
// 用於關閉,統一管理
this.returnColumns = cursor.getReturnColumns();
List<IColumn> cols = new ArrayList<IColumn>();
if (ibf.getColumn() instanceof IColumn) {
cols.add((IColumn) ibf.getColumn());
} else {
cols.addAll(((IFunction) ibf.getColumn()).getArgs());
}
duplicateKeyMap = buildDuplicateKVPairMap(cols, cursor);
} finally {
if (cursor != null) {
List<TddlException> exs = new ArrayList();
exs = cursor.close(exs);
if (!exs.isEmpty()) {
throw GeneralUtil.mergeException(exs);
}
}
}
return duplicateKeyMap;
}
}
示例5: mgetWithDuplicate
import com.taobao.tddl.executor.record.CloneableRecord; //導入方法依賴的package包/類
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
IQuery tmpQuery = (IQuery) query.copy();
IBooleanFilter ibf = ASTNodeFactory.getInstance().createBooleanFilter();
ibf.setOperation(OPERATION.IN);
ibf.setValues(new ArrayList<Object>());
String colName = null;
for (CloneableRecord record : keys) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() == 1) {
// 單字段in
Entry<String, Object> entry = recordMap.entrySet().iterator().next();
Object comp = entry.getValue();
colName = entry.getKey();
IColumn col = ASTNodeFactory.getInstance()
.createColumn()
.setColumnName(colName)
.setDataType(record.getType(0));
col.setTableName(tmpQuery.getAlias());
ibf.setColumn(col);
ibf.getValues().add(comp);
} else {
// 多字段in
if (ibf.getColumn() == null) {
ibf.setColumn(buildRowFunction(recordMap.keySet(), true, record));
}
ibf.getValues().add(buildRowFunction(recordMap.values(), false, record));
}
}
tmpQuery.setKeyFilter(FilterUtils.and(tmpQuery.getKeyFilter(), ibf));
myJdbcHandler.setPlan(tmpQuery);
try {
myJdbcHandler.executeQuery(this.meta, isStreaming);
} catch (SQLException e) {
throw new TddlException(e);
}
buildReturnColumns();
Map<CloneableRecord, DuplicateKVPair> res = buildDuplicateKVPair(keys);
return res;
}
示例6: getRecordFromRightByValueFilter
import com.taobao.tddl.executor.record.CloneableRecord; //導入方法依賴的package包/類
protected Map<CloneableRecord, DuplicateKVPair> getRecordFromRightByValueFilter(List<CloneableRecord> leftJoinOnColumnCache)
throws TddlException {
right_cursor.beforeFirst();
if (isLeftOutJoin() && this.rightCursorMeta == null) {
IRowSet kv = right_cursor.next();
if (kv != null) {
this.rightCursorMeta = kv.getParentCursorMeta();
} else {
rightCursorMeta = CursorMetaImp.buildNew(right_cursor.getReturnColumns());
}
right_cursor.beforeFirst();
}
IBooleanFilter filter = ASTNodeFactory.getInstance().createBooleanFilter();
List<Object> values = new ArrayList<Object>();
for (CloneableRecord record : leftJoinOnColumnCache) {
Map<String, Object> recordMap = record.getMap();
if (recordMap.size() != 1) {
throw new IllegalArgumentException("目前隻支持單值查詢吧。。簡化一點");
}
Comparable comp = (Comparable) record.getMap().values().iterator().next();
values.add(comp);
}
filter.setOperation(OPERATION.IN);
filter.setValues(values);
filter.setColumn(this.rightJoinOnColumns.get(0));
IColumn rightColumn = (IColumn) this.rightJoinOnColumns.get(0);
IValueFilterCursor vfc = this.cursorFactory.valueFilterCursor(executionContext, right_cursor, filter);
Map<CloneableRecord, DuplicateKVPair> records = new HashMap();
if (isLeftOutJoin() && !isRightOutJoin()) {
blockNestedLoopJoin(leftJoinOnColumnCache, rightColumn, vfc, records);
} else if (!isLeftOutJoin() && !isRightOutJoin()) {
// inner join
blockNestedLoopJoin(leftJoinOnColumnCache, rightColumn, vfc, records);
} else {
throw new UnsupportedOperationException("不支持該操作 leftOutJoin:" + isLeftOutJoin() + " ; rightOutJoin:"
+ isRightOutJoin());
}
return records;
}