本文整理汇总了Java中com.facebook.presto.spi.RecordCursor类的典型用法代码示例。如果您正苦于以下问题:Java RecordCursor类的具体用法?Java RecordCursor怎么用?Java RecordCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RecordCursor类属于com.facebook.presto.spi包,在下文中一共展示了RecordCursor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGetRecordSet
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Test
public void testGetRecordSet()
throws Exception
{
ExampleRecordSetProvider recordSetProvider = new ExampleRecordSetProvider(new ExampleConnectorId("test"));
RecordSet recordSet = recordSetProvider.getRecordSet(SESSION, new ExampleSplit("test", "schema", "table", dataUri), ImmutableList.of(
new ExampleColumnHandle("test", "text", VARCHAR, 0),
new ExampleColumnHandle("test", "value", BIGINT, 1)));
assertNotNull(recordSet, "recordSet is null");
RecordCursor cursor = recordSet.cursor();
assertNotNull(cursor, "cursor is null");
Map<String, Long> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getLong(1));
}
assertEquals(data, ImmutableMap.<String, Long>builder()
.put("ten", 10L)
.put("eleven", 11L)
.put("twelve", 12L)
.build());
}
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:TestExampleRecordSetProvider.java
示例2: testCursorSimple
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Test
public void testCursorSimple()
throws Exception
{
RecordSet recordSet = new ExampleRecordSet(new ExampleSplit("test", "schema", "table", dataUri), ImmutableList.of(
new ExampleColumnHandle("test", "text", VARCHAR, 0),
new ExampleColumnHandle("test", "value", BIGINT, 1)));
RecordCursor cursor = recordSet.cursor();
assertEquals(cursor.getType(0), VARCHAR);
assertEquals(cursor.getType(1), BIGINT);
Map<String, Long> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getLong(1));
assertFalse(cursor.isNull(0));
assertFalse(cursor.isNull(1));
}
assertEquals(data, ImmutableMap.<String, Long>builder()
.put("ten", 10L)
.put("eleven", 11L)
.put("twelve", 12L)
.build());
}
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:TestExampleRecordSet.java
示例3: testCursorMixedOrder
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Test
public void testCursorMixedOrder()
throws Exception
{
RecordSet recordSet = new ExampleRecordSet(new ExampleSplit("test", "schema", "table", dataUri), ImmutableList.of(
new ExampleColumnHandle("test", "value", BIGINT, 1),
new ExampleColumnHandle("test", "value", BIGINT, 1),
new ExampleColumnHandle("test", "text", VARCHAR, 0)));
RecordCursor cursor = recordSet.cursor();
Map<String, Long> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertEquals(cursor.getLong(0), cursor.getLong(1));
data.put(cursor.getSlice(2).toStringUtf8(), cursor.getLong(0));
}
assertEquals(data, ImmutableMap.<String, Long>builder()
.put("ten", 10L)
.put("eleven", 11L)
.put("twelve", 12L)
.build());
}
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TestExampleRecordSet.java
示例4: indexTable
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private static IndexedTable indexTable(RecordSet recordSet, final List<String> outputColumns, List<String> keyColumns)
{
List<Integer> keyPositions = FluentIterable.from(keyColumns)
.transform(columnName -> {
int position = outputColumns.indexOf(columnName);
checkState(position != -1);
return position;
})
.toList();
ImmutableListMultimap.Builder<MaterializedTuple, MaterializedTuple> indexedValuesBuilder = ImmutableListMultimap.builder();
List<Type> outputTypes = recordSet.getColumnTypes();
List<Type> keyTypes = extractPositionValues(outputTypes, keyPositions);
RecordCursor cursor = recordSet.cursor();
while (cursor.advanceNextPosition()) {
List<Object> values = extractValues(cursor, outputTypes);
List<Object> keyValues = extractPositionValues(values, keyPositions);
indexedValuesBuilder.put(new MaterializedTuple(keyValues), new MaterializedTuple(values));
}
return new IndexedTable(keyColumns, keyTypes, outputColumns, outputTypes, indexedValuesBuilder.build());
}
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:TpchIndexedData.java
示例5: extractObject
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private static Object extractObject(RecordCursor cursor, int field, Type type)
{
if (cursor.isNull(field)) {
return null;
}
Class<?> javaType = type.getJavaType();
if (javaType == boolean.class) {
return cursor.getBoolean(field);
}
else if (javaType == long.class) {
return cursor.getLong(field);
}
else if (javaType == double.class) {
return cursor.getDouble(field);
}
else if (javaType == Slice.class) {
return cursor.getSlice(field).toStringUtf8();
}
throw new AssertionError("Unsupported type: " + type);
}
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TpchIndexedData.java
示例6: tupleIterable
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private static Iterable<MaterializedTuple> tupleIterable(final RecordSet recordSet)
{
return () -> new AbstractIterator<MaterializedTuple>()
{
private final RecordCursor cursor = recordSet.cursor();
@Override
protected MaterializedTuple computeNext()
{
if (!cursor.advanceNextPosition()) {
return endOfData();
}
return new MaterializedTuple(extractValues(cursor, recordSet.getColumnTypes()));
}
};
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TpchIndexedData.java
示例7: testRecordSetProvider
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Test
public void testRecordSetProvider()
throws Exception
{
for (SchemaTableName schemaTableName : metadata.listTables(SESSION, "jmx")) {
JmxTableHandle tableHandle = metadata.getTableHandle(SESSION, schemaTableName);
List<ColumnHandle> columnHandles = ImmutableList.copyOf(metadata.getColumnHandles(SESSION, tableHandle).values());
ConnectorTableLayoutHandle layout = new JmxTableLayoutHandle(tableHandle, TupleDomain.all());
ConnectorSplitSource splitSource = splitManager.getSplits(JmxTransactionHandle.INSTANCE, SESSION, layout);
List<ConnectorSplit> allSplits = getAllSplits(splitSource);
assertEquals(allSplits.size(), nodes.size());
ConnectorSplit split = allSplits.get(0);
RecordSet recordSet = recordSetProvider.getRecordSet(JmxTransactionHandle.INSTANCE, SESSION, split, columnHandles);
try (RecordCursor cursor = recordSet.cursor()) {
while (cursor.advanceNextPosition()) {
for (int i = 0; i < recordSet.getColumnTypes().size(); i++) {
cursor.isNull(i);
}
}
}
}
}
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:TestJmxSplitManager.java
示例8: testGetRecordSet
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Test
public void testGetRecordSet()
throws Exception
{
JdbcRecordSetProvider recordSetProvider = new JdbcRecordSetProvider(jdbcClient);
RecordSet recordSet = recordSetProvider.getRecordSet(SESSION, split, ImmutableList.of(textColumn, valueColumn));
assertNotNull(recordSet, "recordSet is null");
RecordCursor cursor = recordSet.cursor();
assertNotNull(cursor, "cursor is null");
Map<String, Long> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getLong(1));
}
assertEquals(data, ImmutableMap.<String, Long>builder()
.put("one", 1L)
.put("two", 2L)
.put("three", 3L)
.put("ten", 10L)
.put("eleven", 11L)
.put("twelve", 12L)
.build());
}
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:TestJdbcRecordSetProvider.java
示例9: cursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
GlobalSystemTransactionHandle transaction = checkType(transactionHandle, GlobalSystemTransactionHandle.class, "transaction");
Session session = toSession(transaction.getTransactionId(), connectorSession);
Optional<String> catalogFilter = stringFilter(constraint, 0);
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);
Builder table = InMemoryRecordSet.builder(METADATA);
for (String catalog : filter(metadata.getCatalogNames().keySet(), catalogFilter)) {
QualifiedTablePrefix prefix = FilterUtil.tablePrefix(catalog, schemaFilter, tableFilter);
for (Entry<QualifiedObjectName, List<ColumnMetadata>> entry : metadata.listTableColumns(session, prefix).entrySet()) {
addColumnRows(table, entry.getKey(), entry.getValue());
}
}
return table.build().cursor();
}
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:ColumnJdbcTable.java
示例10: cursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
{
Builder table = InMemoryRecordSet.builder(transactionsTable);
for (TransactionInfo info : transactionManager.getAllTransactionInfos()) {
table.addRow(
info.getTransactionId().toString(),
info.getIsolationLevel().toString(),
info.isReadOnly(),
info.isAutoCommitContext(),
info.getCreateTime().getMillis(),
(long) info.getIdleTime().getValue(TimeUnit.SECONDS),
info.getWrittenConnectorId().orElse(null),
createStringsBlock(info.getConnectorIds()));
}
return table.build().cursor();
}
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:TransactionsSystemTable.java
示例11: toRecordSet
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private static RecordSet toRecordSet(ConnectorTransactionHandle sourceTransaction, SystemTable table, ConnectorSession session, TupleDomain<Integer> constraint)
{
return new RecordSet()
{
private final List<Type> types = table.getTableMetadata().getColumns().stream()
.map(ColumnMetadata::getType)
.collect(toImmutableList());
@Override
public List<Type> getColumnTypes()
{
return types;
}
@Override
public RecordCursor cursor()
{
return table.cursor(sourceTransaction, session, constraint);
}
};
}
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:SystemRecordSetProvider.java
示例12: cursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
{
Builder table = InMemoryRecordSet.builder(TABLE_PROPERTIES_TABLE);
Map<String, Map<String, PropertyMetadata<?>>> tableProperties = new TreeMap<>(metadata.getTablePropertyManager().getAllTableProperties());
for (Entry<String, Map<String, PropertyMetadata<?>>> entry : tableProperties.entrySet()) {
String catalog = entry.getKey();
Map<String, PropertyMetadata<?>> properties = new TreeMap<>(entry.getValue());
for (PropertyMetadata<?> propertyMetadata : properties.values()) {
table.addRow(
catalog,
propertyMetadata.getName(),
firstNonNull(propertyMetadata.getDefaultValue(), "").toString(),
propertyMetadata.getSqlType().toString(),
propertyMetadata.getDescription());
}
}
return table.build().cursor();
}
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:TablePropertiesSystemTable.java
示例13: cursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
{
Builder table = InMemoryRecordSet.builder(QUERY_TABLE);
for (QueryInfo queryInfo : queryManager.getAllQueryInfo()) {
QueryStats queryStats = queryInfo.getQueryStats();
table.addRow(
nodeId,
queryInfo.getQueryId().toString(),
queryInfo.getState().toString(),
queryInfo.getSession().getUser(),
queryInfo.getSession().getSource().orElse(null),
queryInfo.getQuery(),
toMillis(queryStats.getQueuedTime()),
toMillis(queryStats.getAnalysisTime()),
toMillis(queryStats.getDistributedPlanningTime()),
toTimeStamp(queryStats.getCreateTime()),
toTimeStamp(queryStats.getExecutionStartTime()),
toTimeStamp(queryStats.getLastHeartbeat()),
toTimeStamp(queryStats.getEndTime()));
}
return table.build().cursor();
}
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:QuerySystemTable.java
示例14: process
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public int process(ConnectorSession session, RecordCursor cursor, int count, PageBuilder pageBuilder)
{
checkArgument(!pageBuilder.isFull(), "page builder can't be full");
checkArgument(count > 0, "count must be > 0");
int position = 0;
for (; position < count; position++) {
if (pageBuilder.isFull()) {
break;
}
if (!cursor.advanceNextPosition()) {
break;
}
if (filterFunction.filter(cursor)) {
pageBuilder.declarePosition();
for (int channel = 0; channel < projections.size(); channel++) {
// todo: if the projection function increases the size of the data significantly, this could cause the servers to OOM
projections.get(channel).project(cursor, pageBuilder.getBlockBuilder(channel));
}
}
}
return position;
}
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:GenericCursorProcessor.java
示例15: generateProjectMethod
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private void generateProjectMethod(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, CachedInstanceBinder cachedInstanceBinder, String methodName, RowExpression projection)
{
Parameter session = arg("session", ConnectorSession.class);
Parameter cursor = arg("cursor", RecordCursor.class);
Parameter output = arg("output", BlockBuilder.class);
MethodDefinition method = classDefinition.declareMethod(a(PUBLIC), methodName, type(void.class), session, cursor, output);
method.comment("Projection: %s", projection.toString());
Scope scope = method.getScope();
Variable wasNullVariable = scope.declareVariable(type(boolean.class), "wasNull");
BytecodeBlock body = method.getBody()
.comment("boolean wasNull = false;")
.putVariable(wasNullVariable, false);
BytecodeExpressionVisitor visitor = new BytecodeExpressionVisitor(callSiteBinder, cachedInstanceBinder, fieldReferenceCompiler(cursor, wasNullVariable), metadata.getFunctionRegistry());
body.getVariable(output)
.comment("evaluate projection: " + projection.toString())
.append(projection.accept(visitor, scope))
.append(generateWrite(callSiteBinder, scope, wasNullVariable, projection.getType()))
.ret();
}
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:CursorProcessorCompiler.java
示例16: test
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Test
public void test()
{
ArrayType arrayOfBigintType = new ArrayType(BIGINT);
FieldSetFilteringRecordSet fieldSetFilteringRecordSet = new FieldSetFilteringRecordSet(
FUNCTION_REGISTRY,
new InMemoryRecordSet(
ImmutableList.of(BIGINT, BIGINT, TIMESTAMP_WITH_TIME_ZONE, TIMESTAMP_WITH_TIME_ZONE, arrayOfBigintType, arrayOfBigintType),
ImmutableList.of(
ImmutableList.of(
100L,
100L,
// test same time in different time zone to make sure equal check was done properly
packDateTimeWithZone(100, getTimeZoneKeyForOffset(123)),
packDateTimeWithZone(100, getTimeZoneKeyForOffset(234)),
// test structural type
arrayBlockOf(BIGINT, 12, 34, 56),
arrayBlockOf(BIGINT, 12, 34, 56)
))),
ImmutableList.of(ImmutableSet.of(0, 1), ImmutableSet.of(2, 3), ImmutableSet.of(4, 5)));
RecordCursor recordCursor = fieldSetFilteringRecordSet.cursor();
assertTrue(recordCursor.advanceNextPosition());
}
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:TestFieldSetFilteringRecordSet.java
示例17: cursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public RecordCursor cursor() {
EthBlock block = null;
try {
block = web3j.ethGetBlockByNumber(DefaultBlockParameter.valueOf(BigInteger.valueOf(split.getBlockId())), true).send();
} catch (IOException e) {
e.printStackTrace();
}
return new EthereumRecordCursor(columnHandles, block, split.getTable(), web3j);
}
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:11,代码来源:EthereumRecordSet.java
示例18: getMaterializedResults
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private static List<MaterializedRow> getMaterializedResults(RecordCursor cursor, List<ColumnMetadata> columns)
{
List<Type> types = columns.stream().map(ColumnMetadata::getType).collect(toList());
ImmutableList.Builder<MaterializedRow> rowBuilder = ImmutableList.builder();
for (int i = 0; i < types.size(); i++) {
assertEquals(cursor.getType(i), types.get(i));
}
while (cursor.advanceNextPosition()) {
List<Object> values = new ArrayList<>(types.size());
for (int i = 0; i < columns.size(); i++) {
Type type = columns.get(i).getType();
Class<?> javaType = type.getJavaType();
if (cursor.isNull(i)) {
continue;
}
if (javaType == boolean.class) {
values.add(i, cursor.getBoolean(i));
}
else if (javaType == long.class) {
values.add(i, cursor.getLong(i));
}
else if (javaType == double.class) {
values.add(i, cursor.getDouble(i));
}
else if (javaType == Slice.class) {
values.add(i, cursor.getSlice(i));
}
}
rowBuilder.add(new MaterializedRow(DEFAULT_PRECISION, values));
}
return rowBuilder.build();
}
开发者ID:y-lan,项目名称:presto,代码行数:35,代码来源:TestShardMetadataRecordCursor.java
示例19: AppendingRecordCursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
private AppendingRecordCursor(RecordCursor delegate, int delegateFieldCount, List<Object> appendedValues, List<Type> appendedTypes)
{
this.delegate = requireNonNull(delegate, "delegate is null");
this.delegateFieldCount = delegateFieldCount;
checkArgument(delegateFieldCount >= 0, "delegateFieldCount must be greater than or equal to zero");
this.appendedValues = requireNonNull(appendedValues, "appendedValues is null"); // May contain null elements
this.appendedTypes = ImmutableList.copyOf(requireNonNull(appendedTypes, "appendedTypes is null"));
checkArgument(appendedValues.size() == appendedTypes.size(), "appendedValues must have the same size as appendedTypes");
}
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:AppendingRecordSet.java
示例20: cursor
import com.facebook.presto.spi.RecordCursor; //导入依赖的package包/类
@Override
public RecordCursor cursor()
{
// NOTE: the ConcatRecordCursor implementation relies on the fact that the
// cursor creation in the Iterable is lazy so DO NOT materialize this into
// an ImmutableList
Iterable<RecordCursor> recordCursors = transform(recordSets, RecordSet::cursor);
return new ConcatRecordCursor(recordCursors.iterator(), types);
}
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:ConcatRecordSet.java
注:本文中的com.facebook.presto.spi.RecordCursor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论