本文整理汇总了Java中com.facebook.presto.spi.block.Block类的典型用法代码示例。如果您正苦于以下问题:Java Block类的具体用法?Java Block怎么用?Java Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于com.facebook.presto.spi.block包,在下文中一共展示了Block类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseAgent
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@ScalarFunction("parse_agent")
@Description("Returns Map, which has keys such as 'category', 'name', 'os', 'version', 'vendor' and 'os_version'")
@SqlType("map<varchar,varchar>")
public Block parseAgent(@TypeParameter("map<varchar,varchar>") Type mapType, @SqlType(StandardTypes.VARCHAR) Slice slice) {
String argument = slice.toStringUtf8();
Map<String, String> stringMap = Classifier.parse(argument);
if (pageBuilder.isFull()) {
pageBuilder.reset();
}
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
BlockBuilder singleMapBlockBuilder = blockBuilder.beginBlockEntry();
for (Map.Entry<String, String> entry : stringMap.entrySet()) {
VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getKey()));
VARCHAR.writeSlice(singleMapBlockBuilder, Slices.utf8Slice(entry.getValue()));
}
blockBuilder.closeEntry();
pageBuilder.declarePosition();
return (Block) mapType.getObject(blockBuilder, blockBuilder.getPositionCount() - 1);
}
开发者ID:wyukawa,项目名称:presto-woothee,代码行数:23,代码来源:ParseAgentFuntion.java
示例2: load
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Override
public final void load(LazyBlock lazyBlock)
{
if (loaded) {
return;
}
checkState(batchId == expectedBatchId);
try {
Block block = parquetReader.readPrimitive(columnDescriptor, type);
lazyBlock.setBlock(block);
}
catch (IOException e) {
throw new HdfsCursorException();
}
loaded = true;
}
开发者ID:dbiir,项目名称:paraflow,代码行数:19,代码来源:HDFSPageSource.java
示例3: testPoly_contains
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Test
public void testPoly_contains() throws Exception {
double[] poly = new double[]{
45, 9.5,
45.5, 9.5,
45.5, 9,
46, 9,
46, 10,
45, 10
};
Block blockPoly = toBlock(poly);
assertFalse(PolyContains.contains(DoubleType.DOUBLE, blockPoly, 6, 3));
assertFalse(PolyContains.contains(DoubleType.DOUBLE, blockPoly, 45, 9));
assertTrue(PolyContains.contains(DoubleType.DOUBLE, blockPoly, 45.7, 9.7));
}
开发者ID:Cuebiq,项目名称:presto-cuebiq-functions,代码行数:20,代码来源:PolyContainsTest.java
示例4: addInput
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Override
public void addInput(Page page)
{
requireNonNull(page, "page is null");
checkState(state == State.RUNNING, "Operator is %s", state);
Block[] blocks = new Block[inputChannels.size()];
for (int outputChannel = 0; outputChannel < inputChannels.size(); outputChannel++) {
blocks[outputChannel] = page.getBlock(inputChannels.get(outputChannel));
}
Block sampleWeightBlock = null;
if (sampleWeightChannel.isPresent()) {
sampleWeightBlock = page.getBlock(sampleWeightChannel.get());
}
pageSink.appendPage(new Page(blocks), sampleWeightBlock);
rowCount += page.getPositionCount();
}
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:TableWriterOperator.java
示例5: testRoundTrip
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Test
public void testRoundTrip()
{
BlockBuilder expectedBlockBuilder = VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 5);
VARCHAR.writeString(expectedBlockBuilder, "alice");
VARCHAR.writeString(expectedBlockBuilder, "bob");
VARCHAR.writeString(expectedBlockBuilder, "charlie");
VARCHAR.writeString(expectedBlockBuilder, "dave");
Block expectedBlock = expectedBlockBuilder.build();
Page expectedPage = new Page(expectedBlock, expectedBlock, expectedBlock);
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
writePages(blockEncodingManager, sliceOutput, expectedPage, expectedPage, expectedPage);
List<Type> types = ImmutableList.<Type>of(VARCHAR, VARCHAR, VARCHAR);
Iterator<Page> pageIterator = readPages(blockEncodingManager, sliceOutput.slice().getInput());
assertPageEquals(types, pageIterator.next(), expectedPage);
assertPageEquals(types, pageIterator.next(), expectedPage);
assertPageEquals(types, pageIterator.next(), expectedPage);
assertFalse(pageIterator.hasNext());
}
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:TestPagesSerde.java
示例6: toArray
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
public static Block toArray(Type arrayType, ConnectorSession connectorSession, Slice json)
{
try {
List<?> array = (List<?>) stackRepresentationToObject(connectorSession, json, arrayType);
if (array == null) {
return null;
}
Type elementType = ((ArrayType) arrayType).getElementType();
BlockBuilder blockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), array.size());
for (Object element : array) {
appendToBlockBuilder(elementType, element, blockBuilder);
}
return blockBuilder.build();
}
catch (RuntimeException e) {
throw new PrestoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to " + arrayType, e);
}
}
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:JsonToArrayCast.java
示例7: IntBlockCompare
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
private static IntComparator IntBlockCompare(Type type, Block block)
{
return new AbstractIntComparator()
{
@Override
public int compare(int left, int right)
{
if (block.isNull(left) && block.isNull(right)) {
return 0;
}
if (block.isNull(left)) {
return -1;
}
if (block.isNull(right)) {
return 1;
}
return type.compareTo(block, left, block, right);
}
};
}
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:ArrayIntersectFunction.java
示例8: offsetColumns
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
private static Page[] offsetColumns(Page[] pages, int offset)
{
Page[] newPages = new Page[pages.length];
for (int i = 0; i < pages.length; i++) {
Page page = pages[i];
Block[] newBlocks = new Block[page.getChannelCount() + offset];
for (int channel = 0; channel < offset; channel++) {
newBlocks[channel] = createNullRLEBlock(page.getPositionCount());
}
for (int channel = 0; channel < page.getBlocks().length; channel++) {
newBlocks[channel + offset] = page.getBlocks()[channel];
}
newPages[i] = new Page(page.getPositionCount(), newBlocks);
}
return newPages;
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:AggregationTestUtils.java
示例9: createTestBlock
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
public static Block createTestBlock()
{
BlockBuilder blockBuilder = TIMESTAMP.createBlockBuilder(new BlockBuilderStatus(), 15);
TIMESTAMP.writeLong(blockBuilder, 1111);
TIMESTAMP.writeLong(blockBuilder, 1111);
TIMESTAMP.writeLong(blockBuilder, 1111);
TIMESTAMP.writeLong(blockBuilder, 2222);
TIMESTAMP.writeLong(blockBuilder, 2222);
TIMESTAMP.writeLong(blockBuilder, 2222);
TIMESTAMP.writeLong(blockBuilder, 2222);
TIMESTAMP.writeLong(blockBuilder, 2222);
TIMESTAMP.writeLong(blockBuilder, 3333);
TIMESTAMP.writeLong(blockBuilder, 3333);
TIMESTAMP.writeLong(blockBuilder, 4444);
return blockBuilder.build();
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TestTimestampType.java
示例10: arrayPosition
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@UsedByGeneratedCode
public static long arrayPosition(Type type, MethodHandle equalMethodHandle, Block array, boolean element)
{
int size = array.getPositionCount();
for (int i = 0; i < size; i++) {
if (!array.isNull(i)) {
boolean arrayValue = type.getBoolean(array, i);
try {
if ((boolean) equalMethodHandle.invokeExact(arrayValue, element)) {
return i + 1; // result is 1-based (instead of 0)
}
}
catch (Throwable t) {
Throwables.propagateIfInstanceOf(t, Error.class);
Throwables.propagateIfInstanceOf(t, PrestoException.class);
throw new PrestoException(INTERNAL_ERROR, t);
}
}
}
return 0;
}
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:ArrayPositionFunction.java
示例11: load
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Override
public final void load(LazyBlock lazyBlock)
{
if (loaded) {
return;
}
checkState(batchId == expectedBatchId);
try {
Block block = parquetReader.readBlock(columnDescriptor, batchSize, type);
lazyBlock.setBlock(block);
}
catch (IOException e) {
throw new PrestoException(HIVE_CURSOR_ERROR, e);
}
loaded = true;
}
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:ParquetPageSource.java
示例12: subscript
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@UsedByGeneratedCode
public static Object subscript(MethodHandle keyEqualsMethod, Type keyType, Type valueType, Block map, double key)
{
for (int position = 0; position < map.getPositionCount(); position += 2) {
try {
if ((boolean) keyEqualsMethod.invokeExact(keyType.getDouble(map, position), key)) {
return readNativeValue(valueType, map, position + 1); // position + 1: value position
}
}
catch (Throwable t) {
Throwables.propagateIfInstanceOf(t, Error.class);
Throwables.propagateIfInstanceOf(t, PrestoException.class);
throw new PrestoException(INTERNAL_ERROR, t);
}
}
return null;
}
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:MapSubscriptOperator.java
示例13: combine
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
public static void combine(KeyValuePairsState state, KeyValuePairsState otherState)
{
if (state.get() != null && otherState.get() != null) {
Block keys = otherState.get().getKeys();
Block values = otherState.get().getValues();
KeyValuePairs pairs = state.get();
long startSize = pairs.estimatedInMemorySize();
for (int i = 0; i < keys.getPositionCount(); i++) {
try {
pairs.add(keys, values, i, i);
}
catch (ExceededMemoryLimitException e) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("The result of map_agg may not exceed %s", e.getMaxMemory()));
}
}
state.addMemoryUsage(pairs.estimatedInMemorySize() - startSize);
}
else if (state.get() == null) {
state.set(otherState.get());
}
}
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:MapAggregationFunction.java
示例14: addInput
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Override
public void addInput(Page page)
{
requireNonNull(page, "page is null");
checkState(!finishing, "Operator is finishing");
checkState(outputPage == null, "Operator still has pending output");
operatorContext.setMemoryReservation(markDistinctHash.getEstimatedSize());
Block markerBlock = markDistinctHash.markDistinctRows(page);
// add the new boolean column to the page
Block[] sourceBlocks = page.getBlocks();
Block[] outputBlocks = new Block[sourceBlocks.length + 1]; // +1 for the single boolean output channel
System.arraycopy(sourceBlocks, 0, outputBlocks, 0, sourceBlocks.length);
outputBlocks[sourceBlocks.length] = markerBlock;
outputPage = new Page(outputBlocks);
}
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:MarkDistinctOperator.java
示例15: input
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
public static void input(BlockComparator comparator, Type valueType, Type keyType, MinMaxByNState state, Block value, Block key, int blockIndex, long n)
{
TypedKeyValueHeap heap = state.getTypedKeyValueHeap();
if (heap == null) {
if (n <= 0) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "third argument of max_by/min_by must be a positive integer");
}
heap = new TypedKeyValueHeap(comparator, keyType, valueType, Ints.checkedCast(n));
state.setTypedKeyValueHeap(heap);
}
long startSize = heap.getEstimatedSize();
if (!key.isNull(blockIndex)) {
heap.add(key, value, blockIndex);
}
state.addMemoryUsage(heap.getEstimatedSize() - startSize);
}
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:AbstractMinMaxByNAggregationFunction.java
示例16: addPage
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
public void addPage(Page page)
{
// ignore empty pages
if (page.getPositionCount() == 0) {
return;
}
positionCount += page.getPositionCount();
int pageIndex = (channels.length > 0) ? channels[0].size() : 0;
for (int i = 0; i < channels.length; i++) {
Block block = page.getBlock(i);
channels[i].add(block);
pagesMemorySize += block.getRetainedSizeInBytes();
}
for (int position = 0; position < page.getPositionCount(); position++) {
long sliceAddress = encodeSyntheticAddress(pageIndex, position);
valueAddresses.add(sliceAddress);
}
estimatedSize = calculateEstimatedSize();
}
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:PagesIndex.java
示例17: computeNext
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Override
protected List<Object> computeNext()
{
position++;
if (position >= page.getPositionCount()) {
return endOfData();
}
List<Object> values = new ArrayList<>(page.getChannelCount());
for (int channel = 0; channel < page.getChannelCount(); channel++) {
Type type = types.get(channel);
Block block = page.getBlock(channel);
values.add(type.getObjectValue(session, block, position));
}
return Collections.unmodifiableList(values);
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:StatementResource.java
示例18: testComplexSerialization
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
@Test
public void testComplexSerialization()
{
StateCompiler compiler = new StateCompiler();
AccumulatorStateFactory<TestComplexState> factory = compiler.generateStateFactory(TestComplexState.class);
AccumulatorStateSerializer<TestComplexState> serializer = compiler.generateStateSerializer(TestComplexState.class);
TestComplexState singleState = factory.createSingleState();
TestComplexState deserializedState = factory.createSingleState();
singleState.setBoolean(true);
singleState.setLong(1);
singleState.setDouble(2.0);
singleState.setByte((byte) 3);
BlockBuilder builder = VarcharType.VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 1);
serializer.serialize(singleState, builder);
Block block = builder.build();
serializer.deserialize(block, 0, deserializedState);
assertEquals(deserializedState.getBoolean(), singleState.getBoolean());
assertEquals(deserializedState.getLong(), singleState.getLong());
assertEquals(deserializedState.getDouble(), singleState.getDouble());
assertEquals(deserializedState.getByte(), singleState.getByte());
}
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestStateCompiler.java
示例19: getHashBlock
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
public static Block getHashBlock(List<? extends Type> hashTypes, Block... hashBlocks)
{
checkArgument(hashTypes.size() == hashBlocks.length);
int[] hashChannels = new int[hashBlocks.length];
for (int i = 0; i < hashBlocks.length; i++) {
hashChannels[i] = i;
}
HashGenerator hashGenerator = new InterpretedHashGenerator(ImmutableList.copyOf(hashTypes), hashChannels);
int positionCount = hashBlocks[0].getPositionCount();
BlockBuilder builder = BIGINT.createFixedSizeBlockBuilder(positionCount);
Page page = new Page(hashBlocks);
for (int i = 0; i < positionCount; i++) {
BIGINT.writeLong(builder, hashGenerator.hashPosition(i, page));
}
return builder.build();
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:TypeUtils.java
示例20: dropChannel
import com.facebook.presto.spi.block.Block; //导入依赖的package包/类
static List<Page> dropChannel(List<Page> pages, List<Integer> channels)
{
List<Page> actualPages = new ArrayList<>();
for (Page page : pages) {
int channel = 0;
Block[] blocks = new Block[page.getChannelCount() - channels.size()];
for (int i = 0; i < page.getChannelCount(); i++) {
if (channels.contains(i)) {
continue;
}
blocks[channel++] = page.getBlock(i);
}
actualPages.add(new Page(blocks));
}
return actualPages;
}
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:OperatorAssertion.java
注:本文中的com.facebook.presto.spi.block.Block类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论