本文整理汇总了Java中gnu.trove.list.array.TLongArrayList.get方法的典型用法代码示例。如果您正苦于以下问题:Java TLongArrayList.get方法的具体用法?Java TLongArrayList.get怎么用?Java TLongArrayList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.list.array.TLongArrayList
的用法示例。
在下文中一共展示了TLongArrayList.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTask
import gnu.trove.list.array.TLongArrayList; //导入方法依赖的package包/类
private void createTask(
int startPos,
int endPos,
long tableId,
TLongArrayList handles,
Pair<TiRegion, Metapb.Store> regionStorePair,
ImmutableList.Builder<RegionTask> regionTasks) {
TiRegion region = regionStorePair.first;
Store store = regionStorePair.second;
List<KeyRange> newKeyRanges = new ArrayList<>(endPos - startPos + 1);
long startHandle = handles.get(startPos);
long endHandle = startHandle;
for (int i = startPos + 1; i < endPos; i++) {
long curHandle = handles.get(i);
if (endHandle + 1 == curHandle) {
endHandle = curHandle;
} else {
newKeyRanges.add(KeyRangeUtils.makeCoprocRangeWithHandle(
tableId,
startHandle,
endHandle + 1));
startHandle = curHandle;
endHandle = startHandle;
}
}
newKeyRanges.add(KeyRangeUtils.makeCoprocRangeWithHandle(tableId, startHandle, endHandle + 1));
regionTasks.add(new RegionTask(region, store, newKeyRanges));
}
示例2: filterByElementId
import gnu.trove.list.array.TLongArrayList; //导入方法依赖的package包/类
/**
* Filters feature by element ID and element type
*
* @param feature
* @return TRUE if no filter is set or if featureId is included in filter.
* FALSE if filter is set and featureId is not included in filter
*/
private boolean filterByElementId(IVgiFeature feature) {
TLongArrayList filterList = new TLongArrayList();
if (feature.getVgiGeometryType().equals(VgiGeometryType.POINT)) {
filterList = filterNodeId;
} else if (feature.getVgiGeometryType().equals(VgiGeometryType.LINE)) {
filterList = filterWayId;
} else if (feature.getVgiGeometryType().equals(VgiGeometryType.RELATION)) {
filterList = filterRelationId;
}
if (filterList == null) {
return true;
}
do {
if (filterIdPointer == filterList.size()) {
/** End of filter list */
return false;
} else if (filterList.get(filterIdPointer) == feature.getOid()) {
/** Feature ID member of filter list > PROCESS this operation */
return true;
} else if (filterList.get(filterIdPointer) > feature.getOid()) {
/** Feature ID NO member of filter list > SKIP this operation */
return false;
}
/** Current Filter ID is too low > NEXT filter feature id */
filterIdPointer++;
} while (true);
}
示例3: splitHandlesByRegion
import gnu.trove.list.array.TLongArrayList; //导入方法依赖的package包/类
public List<RegionTask> splitHandlesByRegion(long tableId, TLongArrayList handles) {
// Max value for current index handle range
ImmutableList.Builder<RegionTask> regionTasks = ImmutableList.builder();
handles.sort();
int startPos = 0;
TableCodec.DecodeResult decodeResult = new TableCodec.DecodeResult();
while (startPos < handles.size()) {
long curHandle = handles.get(startPos);
byte[] key = TableCodec.encodeRowKeyWithHandleBytes(tableId, curHandle);
Pair<TiRegion, Metapb.Store> regionStorePair = regionManager.getRegionStorePairByKey(ByteString.copyFrom(key));
byte[] endKey = regionStorePair.first.getEndKey().toByteArray();
TableCodec.tryDecodeRowKey(tableId, endKey, decodeResult);
if (decodeResult.status == Status.MIN) {
throw new TiClientInternalException("EndKey is less than current rowKey");
} else if (decodeResult.status == Status.MAX || decodeResult.status == Status.UNKNOWN_INF) {
createTask(startPos, handles.size(), tableId, handles, regionStorePair, regionTasks);
break;
}
// Region range is a close-open range
// If region end key match exactly or slightly less than a handle,
// that handle should be excluded from current region
// If region end key is greater than the handle, that handle should be included
long regionEndHandle = decodeResult.handle;
int pos = handles.binarySearch(regionEndHandle, startPos, handles.size());
if (pos < 0) {
// not found in handles, pos is the next greater pos
// [startPos, pos) all included
pos = -(pos + 1);
} else if (decodeResult.status == Status.GREATER) {
// found handle and then further consider decode status
// End key decode to a value v: regionEndHandle < v < regionEndHandle + 1
// handle at pos included
pos ++;
}
createTask(startPos, pos, tableId, handles, regionStorePair, regionTasks);
// pos equals to start leads to an dead loop
// startPos and its handle is used for searching region in PD.
// The returning close-open range should at least include startPos's handle
// so only if PD error and startPos is not included in current region then startPos == pos
if (startPos >= pos) {
throw new TiClientInternalException("searchKey is not included in region returned by PD");
}
startPos = pos;
}
return regionTasks.build();
}
示例4: execute
import gnu.trove.list.array.TLongArrayList; //导入方法依赖的package包/类
@Override
public Object execute(FunctionParameters parameters) {
if(!checkGroupedByTableExists(parameters)){
return Functions.EXECUTION_ERROR;
}
TLongArrayList srcRowIds = getSourceRows(parameters);
if (srcRowIds == null || srcRowIds.size()==0) {
return null;
}
// get source table
ODLTableReadOnly srcTable = getSourceTable(parameters);
if(srcTable==null){
return Functions.EXECUTION_ERROR;
}
// execute the child formulae against all rows in this source table, getting geoms and weights
int nbSrcRows = srcRowIds.size();
ArrayList<Pair<ODLGeom, Double>> geoms = new ArrayList<>(nbSrcRows);
for (int i = 0; i < nbSrcRows; i++) {
long srcRowId = srcRowIds.get(i);
if (srcTable.containsRowId(srcRowId)==false) {
return Functions.EXECUTION_ERROR;
}
// get geometry
Object geomVal = executeFunctionOnSourceTable(parameters, srcRowId, child(0));
if (geomVal == Functions.EXECUTION_ERROR) {
return Functions.EXECUTION_ERROR;
}
ODLGeom geom = (ODLGeom) ColumnValueProcessor.convertToMe(ODLColumnType.GEOM, geomVal);
if (geom == null) {
return null;
}
// get weight
Object weightVal = executeFunctionOnSourceTable(parameters, srcRowId, child(1));
if (weightVal == Functions.EXECUTION_ERROR) {
return Functions.EXECUTION_ERROR;
}
Double d=1.0;
if(weightVal!=null){
d = (Double)ColumnValueProcessor.convertToMe(ODLColumnType.DOUBLE, weightVal);
if(d==null){
return null;
}
}
geoms.add(new Pair<ODLGeom, Double>(geom, d));
}
// get espg code
Object epsgVal = child(2).execute(parameters);
if(epsgVal == Functions.EXECUTION_ERROR){
return Functions.EXECUTION_ERROR;
}
// allow EPSG to be null, we then do weighted centroid in lat-long coords
String epsg = (String) ColumnValueProcessor.convertToMe(ODLColumnType.STRING, epsgVal);
return new GeomWeightedCentroid().calculate(geoms, epsg);
}