2222import sleeper .foreign .bridge .FFIContext ;
2323import sleeper .foreign .datafusion .DataFusionAwsConfig ;
2424import sleeper .query .core .rowretrieval .LeafPartitionRowRetrieverProvider ;
25- import sleeper .query .core .rowretrieval .QueryEngineSelector ;
2625
2726import java .util .function .Supplier ;
2827
2928/**
30- * A wrapper for the DataFusion FFI context. Allows for fallback if DataFusion could not be loaded.
29+ * A wrapper for the DataFusion FFI context. Allows for delayed failure if DataFusion could not be loaded, in case you
30+ * only want to use the Java data engine.
3131 */
3232public class DataFusionQueryContext implements AutoCloseable {
3333
@@ -44,7 +44,7 @@ private DataFusionQueryContext(FFIContext<DataFusionQueryFunctions> context, Buf
4444 /**
4545 * Creates the DataFusion FFI context and Arrow allocator if the DataFusion functions were loaded. The FFI context
4646 * and Arrow allocator will be closed when the query context is closed. If the DataFusion functions were not loaded,
47- * this allows falling back to the Java implementation .
47+ * this avoids immediate failure in case you only want to use the Java data engine .
4848 *
4949 * @param allocator a constructor for the Arrow allocator
5050 * @return the context
@@ -56,35 +56,19 @@ public static DataFusionQueryContext createIfLoaded(Supplier<BufferAllocator> al
5656 }
5757
5858 /**
59- * Creates a context where no DataFusion functions are used. Will always fall back to the Java implementation.
59+ * Creates a context where no DataFusion functions are used. Supports cases where an instance of this class is
60+ * required but we will always use the Java data engine.
6061 *
6162 * @return the context
6263 */
6364 public static DataFusionQueryContext none () {
6465 return new DataFusionQueryContext (null , null );
6566 }
6667
67- /**
68- * Creates a row retriever provider for use in queries, using the Java or DataFusion implementation depending on
69- * configuration. If the DataFusion functions could not be loaded, the Java implementation will always be used.
70- *
71- * @param awsConfig a constructor for the AWS configuration
72- * @param javaProvider the Java implementation
73- * @return the row retriever provider
74- */
75- public LeafPartitionRowRetrieverProvider createQueryEngineSelectorWithFallback (Supplier <DataFusionAwsConfig > awsConfig , LeafPartitionRowRetrieverProvider javaProvider ) {
76- if (context == null ) {
77- LOGGER .warn ("Falling back to Java row retriever as DataFusion was not loaded" );
78- return javaProvider ;
79- } else {
80- return QueryEngineSelector .javaAndDataFusion (javaProvider ,
81- new DataFusionLeafPartitionRowRetriever .Provider (awsConfig .get (), allocator , context ));
82- }
83- }
84-
8568 /**
8669 * Creates a DataFusion row retriever provider for use in queries. If the DataFusion functions could not be loaded,
87- * the returned row retriever will fail if it is used.
70+ * the returned row retriever will fail if it is used. This is usually wrapped with an engine selector to allow
71+ * switching between different data engines.
8872 *
8973 * @param awsConfig a constructor for the AWS configuration
9074 * @return the row retriever provider
0 commit comments