本文整理匯總了Java中com.taobao.tddl.executor.record.CloneableRecord類的典型用法代碼示例。如果您正苦於以下問題:Java CloneableRecord類的具體用法?Java CloneableRecord怎麽用?Java CloneableRecord使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CloneableRecord類屬於com.taobao.tddl.executor.record包,在下文中一共展示了CloneableRecord類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRecordMap
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@SuppressWarnings("unused")
private Map<String, Object> getRecordMap(CloneableRecord key, CloneableRecord value) {
int size = 0;
if (value != null) {
size += value.getColumnList().size();
}
if (key != null) {
size += key.getColumnList().size();
}
Map<String, Object> eachRow = new HashMap<String, Object>(size);
if (value != null) {
eachRow.putAll(value.getMap());
}
if (key != null) {
eachRow.putAll(key.getMap());
}
return eachRow;
}
示例2: getPair
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
public String getPair(CloneableRecord record) {
if (columns.size() == 1) {
return String.valueOf(record.get(columns.get(0)));
}
boolean first = true;
StringBuilder b = new StringBuilder();
b.append("(");
for (String column : columns) {
if (first) {
first = false;
} else {
b.append(",");
}
b.append(record.get(column));
}
b.append(")");
return b.toString();
}
示例3: mgetWithDuplicate
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
Map<CloneableRecord, DuplicateKVPair> map = super.mgetWithDuplicate(keys, prefixMatch, keyFilterOrValueFilter);
if (map == null) {
return null;
}
Map<CloneableRecord, DuplicateKVPair> retMap = new HashMap<CloneableRecord, DuplicateKVPair>(map.size());
Iterator<Entry<CloneableRecord, DuplicateKVPair>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Entry<CloneableRecord, DuplicateKVPair> entry = iterator.next();
DuplicateKVPair dkv = entry.getValue();
dkv = allow(filter, dkv);
if (dkv != null) {
retMap.put(entry.getKey(), dkv);
}
}
return retMap;
}
示例4: encode
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public byte[] encode(CloneableRecord record) {
int length = calculateEncodedLength(record, columns);
byte[] dst = new byte[length];
int offset = 0;
for (ColumnMeta c : columns) {
Object v = record.get(c.getName());
DataType t = c.getDataType();
if (v == null && !c.isNullable()) {
throw new RuntimeException(c + " is not nullable.");
}
offset += t.encodeToBytes(v, dst, offset);
// offset += encode1(v, t, dst, offset);
}
return dst;
}
示例5: blockNestedLoopJoin
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
private void blockNestedLoopJoin(List<CloneableRecord> leftJoinOnColumnCache, IColumn rightColumn,
IValueFilterCursor vfc, Map<CloneableRecord, DuplicateKVPair> records)
throws TddlException {
IRowSet kv = null;
while ((kv = vfc.next()) != null) {
kv = ExecUtils.fromIRowSetToArrayRowSet(kv);
Object rightValue = ExecUtils.getValueByIColumn(kv, rightColumn);
for (CloneableRecord record : leftJoinOnColumnCache) {
Comparable comp = (Comparable) record.getMap().values().iterator().next();
if (rightValue.equals(comp)) {
buildDuplicate(records, kv, record);
break;
}
}
}
}
示例6: get
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public CloneableRecord get(ExecutionContext context, CloneableRecord key, IndexMeta indexMeta, String dbName) {
DatabaseEntry keyEntry = new DatabaseEntry();
DatabaseEntry valueEntry = new DatabaseEntry();
keyEntry.setData(indexCodecMap.get(indexMeta.getName()).getKey_codec().encode(key));
OperationStatus status = getDatabase(dbName).get(context.getTransaction() == null ? null : ((JE_Transaction) context.getTransaction()).txn,
keyEntry,
valueEntry,
LockMode.DEFAULT);
if (OperationStatus.SUCCESS != status) {
return null;
}
if (valueEntry.getSize() != 0) {
return indexCodecMap.get(indexMeta.getName()).getValue_codec().decode(valueEntry.getData());
} else {
return null;
}
}
示例7: clone
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public Object clone() {
KVPair o = null;
try {
o = (KVPair) super.clone();
if (key != null) {
o.key = (CloneableRecord) key.clone();
}
if (value != null) {
o.value = (CloneableRecord) value.clone();
}
} catch (CloneNotSupportedException ex) {
throw new RuntimeException("Clone not supported: " + ex.getMessage());
}
return o;
}
示例8: buildRowFunction
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
private IFunction buildRowFunction(Collection values, boolean isColumn, CloneableRecord record) {
IFunction func = ASTNodeFactory.getInstance().createFunction();
func.setFunctionName("ROW");
StringBuilder columnName = new StringBuilder();
columnName.append('(').append(StringUtils.join(values, ',')).append(')');
func.setColumnName(columnName.toString());
if (isColumn) {
List<IColumn> columns = new ArrayList<IColumn>(values.size());
for (Object value : values) {
IColumn col = ASTNodeFactory.getInstance()
.createColumn()
.setColumnName((String) value)
.setDataType(record.getType((String) value));
columns.add(col);
}
func.setArgs(columns);
} else {
func.setArgs(new ArrayList(values));
}
return func;
}
示例9: fillCache
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
/**
* 將left cursor 取出 sizeKeyLimination個。 放到緩存裏
*
* @param leftJoinOnColumnCache
* @param leftKVPair
* @return
* @throws TddlException
* @throws InterruptedException
*/
private boolean fillCache(List<CloneableRecord> leftJoinOnColumnCache, List<IRowSet> leftKVPair, boolean forward)
throws TddlException {
int currentSize = 0;
boolean hasMore = false;
while (getOneLeftCursor(forward) != null) {
// 有一個,就算has
hasMore = true;
GeneralUtil.checkInterrupted();
putLeftCursorValueIntoReturnVal();
// 上麵的方法用來找到left Join on columns ,然後放入key裏麵,這裏就直接利用這個key,去右邊查詢
leftJoinOnColumnCache.add(right_key);
leftKVPair.add(left);
currentSize++;
if (sizeKeyLimination <= currentSize) {
return true;
}
}
// 用後,清空,其他地方還可能會用到這兩個類變量
left = null;
left_key = null;
// 耗盡
return hasMore;
}
示例10: skipTo
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public boolean skipTo(CloneableRecord skip_key) {
key.setData(key_codec.encode(skip_key));
if (OperationStatus.SUCCESS == je_cursor.getSearchKeyRange(key, value, lockMode)) {
setKV();
// CloneableRecord cr = current.getKey();
// boolean equals = isEquals(skip_key, cr);
// if(!equals)
// {//當SearchKeyRange 取到的數據
// 不等於當前數據的時候,實際上指針是在數據之前的。所以需要額外next一次。不過不確定。。有問題再說吧。。
// next();
// }
// //System.out.println("skip true:"+skip_key+",,,current="+current);
return true;
}
// //System.out.println("skip false:"+skip_key);
return false;
}
示例11: mgetWithDuplicate
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public Map<CloneableRecord, DuplicateKVPair> mgetWithDuplicate(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
if (keyFilterOrValueFilter == false) throw new UnsupportedOperationException("BDB的valueFilter的mget還未實現");
Map<CloneableRecord, DuplicateKVPair> retMap = new HashMap<CloneableRecord, DuplicateKVPair>(64);
if (keys == null) {
keys = Collections.emptyList();
}
for (CloneableRecord cr : keys) {
if (prefixMatch) {
throw new UnsupportedOperationException("not supported yet ");
} else {
dontPrefixMatch(retMap, cr);
}
}
return retMap;
}
示例12: mgetWithDuplicateList
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public List<DuplicateKVPair> mgetWithDuplicateList(List<CloneableRecord> keys, boolean prefixMatch,
boolean keyFilterOrValueFilter) throws TddlException {
if (keyFilterOrValueFilter == false) throw new UnsupportedOperationException("BDB的valueFilter的mget還未實現");
List<DuplicateKVPair> retList = new ArrayList<DuplicateKVPair>(64);
if (keys == null) {
keys = Collections.emptyList();
}
for (CloneableRecord cr : keys) {
if (prefixMatch) {
throw new UnsupportedOperationException("not supported yet ");
} else {
dontPrefixMatchList(retList, cr);
}
}
return retList;
}
示例13: getOperationString
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@Override
public String getOperationString() {
StringBuilder columnsStr = new StringBuilder();
if (columns.size() == 1) {
columnsStr.append(columns.get(0));
} else {
columnsStr.append("(");
boolean first = true;
for (String column : columns) {
if (first) {
first = false;
} else {
columnsStr.append(",");
}
columnsStr.append(column);
}
columnsStr.append(")");
}
StringBuilder valuesStr = new StringBuilder();
boolean firstValue = true;
for (CloneableRecord record : left) {
if (firstValue) {
firstValue = false;
} else {
valuesStr.append(",");
}
valuesStr.append(getPair(record));
}
return message.format(new String[] { columnsStr.toString(), valuesStr.toString() });
}
示例14: executePut
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
@Override
protected int executePut(ExecutionContext executionContext, IPut put, ITable table, IndexMeta meta)
throws Exception {
ITransaction transaction = executionContext.getTransaction();
int affect_rows = 0;
IPut delete = put;
ISchematicCursor conditionCursor = null;
IRowSet rowSet = null;
CloneableRecord key = CodecFactory.getInstance(CodecFactory.FIXED_LENGTH)
.getCodec(meta.getKeyColumns())
.newEmptyRecord();
try {
conditionCursor = ExecutorContext.getContext()
.getTopologyExecutor()
.execByExecPlanNode(delete.getQueryTree(), executionContext);
while ((rowSet = conditionCursor.next()) != null) {
affect_rows++;
for (ColumnMeta cm : meta.getKeyColumns()) {
Object val = getValByColumnMeta(rowSet, cm);
key.put(cm.getName(), val);
}
// CloneableRecord key =
// ExecUtils.convertToClonableRecord(rowSet);
prepare(transaction, table, rowSet, null, null, PUT_TYPE.DELETE);
table.delete(executionContext, key, meta, put.getTableName());
}
} catch (Exception e) {
throw e;
} finally {
if (conditionCursor != null) {
List<TddlException> exs = new ArrayList();
exs = conditionCursor.close(exs);
if (!exs.isEmpty()) {
throw GeneralUtil.mergeException(exs);
}
}
}
return affect_rows;
}
示例15: getMoreRecord
import com.taobao.tddl.executor.record.CloneableRecord; //導入依賴的package包/類
private boolean getMoreRecord(boolean forward) throws TddlException {
List<CloneableRecord> leftJoinOnColumnCache = new ArrayList<CloneableRecord>(sizeKeyLimination);
List<IRowSet> liftKVPair = new ArrayList<IRowSet>(sizeKeyLimination);
boolean hasMore = fillCache(leftJoinOnColumnCache, liftKVPair, forward);
if (!hasMore) {
return false;
}
// 如果使用index nest loop .那麽右表一定是按主key進行查詢的。
rightPairs = getRecordFromRight(leftJoinOnColumnCache);
leftIterator = liftKVPair.iterator();
leftJoinOnColumnCacheIterator = leftJoinOnColumnCache.iterator();
return true;
}