Search in sources :

Example 86 with Nullable

use of javax.annotation.Nullable in project pinot by linkedin.

the class SegmentDirectoryPaths method findFormatFile.

@Nullable
private static File findFormatFile(@Nonnull File indexDir, String fileName) {
    Preconditions.checkNotNull(indexDir);
    Preconditions.checkArgument(indexDir.exists(), "Path %s does not exist", indexDir);
    if (!indexDir.isDirectory()) {
        return indexDir;
    }
    File v1File = new File(indexDir, fileName);
    if (v1File.exists()) {
        return v1File;
    }
    File v3Dir = segmentDirectoryFor(indexDir, SegmentVersion.v3);
    File v3File = new File(v3Dir, fileName);
    if (v3File.exists()) {
        return v3File;
    }
    return null;
}
Also used : File(java.io.File) Nullable(javax.annotation.Nullable)

Example 87 with Nullable

use of javax.annotation.Nullable in project presto by prestodb.

the class QueryStateMachine method transitionToFinishing.

public boolean transitionToFinishing() {
    Duration durationSinceCreation = nanosSince(createNanos).convertToMostSuccinctTimeUnit();
    queuedTime.compareAndSet(null, durationSinceCreation);
    totalPlanningStartNanos.compareAndSet(null, tickerNanos());
    totalPlanningTime.compareAndSet(null, nanosSince(totalPlanningStartNanos.get()));
    DateTime now = DateTime.now();
    executionStartTime.compareAndSet(null, now);
    finishingStartNanos.compareAndSet(null, tickerNanos());
    if (!queryState.setIf(FINISHING, currentState -> currentState != FINISHING && !currentState.isDone())) {
        return false;
    }
    if (autoCommit) {
        ListenableFuture<?> commitFuture = transactionManager.asyncCommit(session.getTransactionId().get());
        Futures.addCallback(commitFuture, new FutureCallback<Object>() {

            @Override
            public void onSuccess(@Nullable Object result) {
                transitionToFinished();
            }

            @Override
            public void onFailure(Throwable throwable) {
                transitionToFailed(throwable);
            }
        });
    } else {
        transitionToFinished();
    }
    return true;
}
Also used : NOT_FOUND(com.facebook.presto.spi.StandardErrorCode.NOT_FOUND) Duration.succinctNanos(io.airlift.units.Duration.succinctNanos) FINISHING(com.facebook.presto.execution.QueryState.FINISHING) Duration(io.airlift.units.Duration) PLANNING(com.facebook.presto.execution.QueryState.PLANNING) OperatorStats(com.facebook.presto.operator.OperatorStats) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) Map(java.util.Map) FAILED(com.facebook.presto.execution.QueryState.FAILED) GENERAL_POOL(com.facebook.presto.memory.LocalMemoryManager.GENERAL_POOL) TransactionId(com.facebook.presto.transaction.TransactionId) URI(java.net.URI) StageInfo.getAllStages(com.facebook.presto.execution.StageInfo.getAllStages) ImmutableSet(com.google.common.collect.ImmutableSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Failures.toFailure(com.facebook.presto.util.Failures.toFailure) ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) Set(java.util.Set) ThreadSafe(javax.annotation.concurrent.ThreadSafe) Ticker(com.google.common.base.Ticker) Sets(com.google.common.collect.Sets) List(java.util.List) USER_CANCELED(com.facebook.presto.spi.StandardErrorCode.USER_CANCELED) Optional(java.util.Optional) QUEUED(com.facebook.presto.execution.QueryState.QUEUED) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Logger(io.airlift.log.Logger) ErrorCode(com.facebook.presto.spi.ErrorCode) NANOSECONDS(java.util.concurrent.TimeUnit.NANOSECONDS) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DataSize.succinctBytes(io.airlift.units.DataSize.succinctBytes) PrestoException(com.facebook.presto.spi.PrestoException) VersionedMemoryPoolId(com.facebook.presto.memory.VersionedMemoryPoolId) AtomicReference(java.util.concurrent.atomic.AtomicReference) TERMINAL_QUERY_STATES(com.facebook.presto.execution.QueryState.TERMINAL_QUERY_STATES) HashSet(java.util.HashSet) TableScanNode(com.facebook.presto.sql.planner.plan.TableScanNode) ImmutableList(com.google.common.collect.ImmutableList) FailureInfo(com.facebook.presto.client.FailureInfo) Objects.requireNonNull(java.util.Objects.requireNonNull) TransactionManager(com.facebook.presto.transaction.TransactionManager) Nullable(javax.annotation.Nullable) BlockedReason(com.facebook.presto.operator.BlockedReason) RUNNING(com.facebook.presto.execution.QueryState.RUNNING) Executor(java.util.concurrent.Executor) Session(com.facebook.presto.Session) DateTime(org.joda.time.DateTime) FutureCallback(com.google.common.util.concurrent.FutureCallback) FINISHED(com.facebook.presto.execution.QueryState.FINISHED) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) StateChangeListener(com.facebook.presto.execution.StateMachine.StateChangeListener) QueryId(com.facebook.presto.spi.QueryId) STARTING(com.facebook.presto.execution.QueryState.STARTING) Metadata(com.facebook.presto.metadata.Metadata) AccessControl(com.facebook.presto.security.AccessControl) Duration(io.airlift.units.Duration) DateTime(org.joda.time.DateTime)

Example 88 with Nullable

use of javax.annotation.Nullable in project presto by prestodb.

the class ExchangeClient method getNextPage.

@Nullable
public SerializedPage getNextPage(Duration maxWaitTime) throws InterruptedException {
    checkState(!Thread.holdsLock(this), "Can not get next page while holding a lock on this");
    throwIfFailed();
    if (closed.get()) {
        return null;
    }
    scheduleRequestIfNecessary();
    SerializedPage page = pageBuffer.poll();
    // only wait for a page if we have remote clients
    if (page == null && maxWaitTime.toMillis() >= 1 && !allClients.isEmpty()) {
        page = pageBuffer.poll(maxWaitTime.toMillis(), TimeUnit.MILLISECONDS);
    }
    return postProcessPage(page);
}
Also used : SerializedPage(com.facebook.presto.execution.buffer.SerializedPage) Nullable(javax.annotation.Nullable)

Example 89 with Nullable

use of javax.annotation.Nullable in project querydsl by querydsl.

the class AbstractSQLQuery method fetchOne.

@SuppressWarnings("unchecked")
@Override
@Nullable
public T fetchOne() {
    if (getMetadata().getModifiers().getLimit() == null) {
        limit(2);
    }
    Query query = createQuery(false);
    Object rv = execute(query, false);
    if (rv instanceof List) {
        List<?> list = (List<?>) rv;
        if (!list.isEmpty()) {
            if (list.size() > 1) {
                throw new NonUniqueResultException();
            }
            return (T) list.get(0);
        } else {
            return null;
        }
    } else {
        return (T) rv;
    }
}
Also used : ProjectableSQLQuery(com.querydsl.sql.ProjectableSQLQuery) SQLQuery(com.querydsl.sql.SQLQuery) Query(javax.jdo.Query) ArrayList(java.util.ArrayList) List(java.util.List) Nullable(javax.annotation.Nullable)

Example 90 with Nullable

use of javax.annotation.Nullable in project querydsl by querydsl.

the class GeoDBWkbType method getValue.

@Override
@Nullable
public Geometry getValue(ResultSet rs, int startIndex) throws SQLException {
    byte[] bytes = rs.getBytes(startIndex);
    if (bytes != null) {
        byte[] wkb;
        if (bytes[0] != 0 && bytes[0] != 1) {
            // decodes EWKB
            wkb = new byte[bytes.length - 32];
            System.arraycopy(bytes, 32, wkb, 0, wkb.length);
        } else {
            wkb = bytes;
        }
        WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.POSTGIS_EWKB_1);
        return decoder.decode(ByteBuffer.from(wkb));
    } else {
        return null;
    }
}
Also used : WkbDecoder(org.geolatte.geom.codec.WkbDecoder) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)735 IOException (java.io.IOException)85 Test (org.junit.Test)59 Map (java.util.Map)58 Function (com.google.common.base.Function)57 List (java.util.List)55 ArrayList (java.util.ArrayList)43 File (java.io.File)42 HashMap (java.util.HashMap)37 ItemStack (net.minecraft.item.ItemStack)36 ImmutableList (com.google.common.collect.ImmutableList)32 SkyKey (com.google.devtools.build.skyframe.SkyKey)28 Nonnull (javax.annotation.Nonnull)28 ImmutableMap (com.google.common.collect.ImmutableMap)27 Predicate (com.google.common.base.Predicate)26 URL (java.net.URL)22 Label (com.google.devtools.build.lib.cmdline.Label)21 HashSet (java.util.HashSet)20 Collectors (java.util.stream.Collectors)15 TypeElement (javax.lang.model.element.TypeElement)15