src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
DremioFutures { public static <T, X extends Exception> T getChecked( Future<T> future, Class<X> exceptionClass, Function<? super Throwable, ? extends X> mapper ) throws X { try { return Futures.getChecked(future, ExecutionException.class); } catch (ExecutionException e) { try { handleException(e, exceptionClass, mapper... | @Test public void testBasic() { SettableFuture<Integer> future = SettableFuture.create(); Integer expectedValue = 1234; future.set(expectedValue); try { Integer result = DremioFutures.getChecked(future, TestException.class, TestDremioFutures::testMapper); assertEquals(result, expectedValue); } catch (TestException igno... |
DremioVersionUtils { public static Collection<NodeEndpoint> getCompatibleNodeEndpoints(Collection<NodeEndpoint> nodeEndpoints) { List<NodeEndpoint> compatibleNodeEndpoints = new ArrayList<>(); if (nodeEndpoints != null && !nodeEndpoints.isEmpty()) { compatibleNodeEndpoints = nodeEndpoints.stream() .filter(nep -> isComp... | @Test public void testCompatibleNodeEndpoints() { NodeEndpoint nep1 = NodeEndpoint.newBuilder() .setAddress("localhost") .setDremioVersion(DremioVersionInfo.getVersion()) .build(); NodeEndpoint nep2 = NodeEndpoint.newBuilder() .setAddress("localhost") .setDremioVersion("incompatibleVersion") .build(); Collection<NodeEn... |
BackwardCompatibleSchemaDe extends StdDeserializer<Schema> { public static Schema fromJSON(String json) throws IOException { return mapper.readValue(checkNotNull(json), Schema.class); } protected BackwardCompatibleSchemaDe(); protected BackwardCompatibleSchemaDe(Class<?> vc); static Schema fromJSON(String json); @Ove... | @Test public void testBackwardCompatofSchema() throws Exception { Schema schema = DremioArrowSchema.fromJSON(OLD_SCHEMA); String newJson = schema.toJson(); assertFalse(newJson.contains("typeLayout")); } |
JsonAdditionalExceptionContext implements AdditionalExceptionContext { protected static <T extends AdditionalExceptionContext> T fromUserException(Class<T> clazz, UserException ex) { if (ex.getRawAdditionalExceptionContext() == null) { logger.debug("missing additional context in UserException"); return null; } try { re... | @Test public void testSerializeDeserialize() throws Exception { UserException ex = UserException.functionError() .message("test") .setAdditionalExceptionContext(new TestContext(TEST_DATA)) .build(logger); Assert.assertTrue(ex.getRawAdditionalExceptionContext() != null); Assert.assertTrue(TEST_DATA.equals(TestContext.fr... |
AutoCloseables { public static void close(Throwable t, AutoCloseable... autoCloseables) { close(t, Arrays.asList(autoCloseables)); } private AutoCloseables(); static AutoCloseable all(final Collection<? extends AutoCloseable> autoCloseables); static void close(Throwable t, AutoCloseable... autoCloseables); static void... | @Test public void testClose() { Resource r1 = new Resource(); Resource r2 = new Resource(); Resource r3 = new Resource(); Resource r4 = new Resource(); try { AutoCloseables.close( () -> r1.closeWithException(new IOException("R1 exception")), () -> r2.closeWithException(null), () -> r3.closeWithException(new RuntimeExce... |
ReplaceRecommender extends Recommender<ReplacePatternRule, Selection> { public static ReplaceMatcher getMatcher(ReplacePatternRule rule) { final String pattern = rule.getSelectionPattern(); ReplaceSelectionType selectionType = rule.getSelectionType(); if (rule.getIgnoreCase() != null && rule.getIgnoreCase()) { return n... | @Test public void testMatcher() { ReplaceMatcher matcher = ReplaceRecommender.getMatcher( new ReplacePatternRule(ReplaceSelectionType.MATCHES) .setSelectionPattern("[ac]") .setIgnoreCase(false)); Match match = matcher.matches("abc"); assertNotNull(match); assertEquals("Match(0, 1)", match.toString()); } |
TracingUtils { public static <R> R trace(Function<Span, R> work, Tracer tracer, String operation, String... tags) { Span span = TracingUtils.buildChildSpan(tracer, operation, tags); try (Scope s = tracer.activateSpan(span)) { return work.apply(span); } finally { span.finish(); } } private TracingUtils(); static Tracer... | @Test public void testTraceWrapperFunction() { MockSpan parent = tracer.buildSpan("parent").start(); final MockSpan[] child = new MockSpan[1]; final int ret; try(Scope s = tracer.activateSpan(parent)) { ret = TracingUtils.trace( (span) -> { span.log("someRunTimeEvent"); child[0] = ((MockSpan) span); return 42; }, trace... |
ContextMigratingExecutorService implements ExecutorService { @Override public <T> Future<T> submit(Callable<T> task) { return delegate.submit(decorate(task)); } ContextMigratingExecutorService(E delegate, Tracer tracer); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); ... | @Test public void testRunnableDecoration() throws InterruptedException, ExecutionException { Span[] runnableSpan = new Span[1]; try (Scope s = tracer.activateSpan(testSpan)) { Future<?> future = pool.submit(() -> { runnableSpan[0] = tracer.activeSpan(); }); future.get(); } assertChildSpan(runnableSpan[0]); }
@Test publ... |
GuiceServiceModule extends AbstractModule { public void close(Injector injector) throws Exception { serviceList.forEach((clazz) -> { final Object instance = injector.getInstance(clazz); if (instance instanceof Service) { try { logger.debug("stopping {}", instance.getClass().toString()); ((Service) instance).close(); } ... | @Test public void testMultiBind() throws Exception { final GuiceServiceModule guiceServiceHandler = new GuiceServiceModule(); final Injector injector = Guice.createInjector(guiceServiceHandler, new MultiBindModule()); final MultiImpl bInstance = (MultiImpl) injector.getInstance(B.class); final MultiImpl cInstance = (Mu... |
BlackListOutput implements Output { @Override public void writeInt32(int fieldNumber, int value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeInt32(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaNameTo... | @Test public void writeInt32() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeInt32(1, 9, false); subject.writeInt32(2, 8, false); Mockito.verify(delegate).writeInt32(1,9, false); Mockito.ve... |
BlackListOutput implements Output { @Override public void writeUInt32(int fieldNumber, int value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeUInt32(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaName... | @Test public void writeUInt32() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeUInt32(1, 9, false); subject.writeUInt32(2, 8, false); Mockito.verify(delegate).writeUInt32(1,9, false); Mockit... |
ReplaceRecommender extends Recommender<ReplacePatternRule, Selection> { @Override public List<ReplacePatternRule> getRules(Selection selection, DataType selColType) { Preconditions.checkArgument(selColType == DataType.TEXT, "Cards generation for Replace/Keeponly/Exclude transforms is supported only on TEXT type columns... | @Test public void ruleSuggestionsSelectMiddleText() { Selection selection = new Selection("col", "This is a text", 5, 2); List<ReplacePatternRule> rules = recommender.getRules(selection, TEXT); assertEquals(2, rules.size()); compare(ReplaceSelectionType.CONTAINS, "is", true, rules.get(0)); compare(ReplaceSelectionType.... |
BlackListOutput implements Output { @Override public void writeSInt32(int fieldNumber, int value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeSInt32(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaName... | @Test public void writeSInt32() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeSInt32(1, 9, false); subject.writeSInt32(2, 8, false); Mockito.verify(delegate).writeSInt32(1,9, false); Mockit... |
BlackListOutput implements Output { @Override public void writeFixed32(int fieldNumber, int value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeFixed32(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaNa... | @Test public void writeFixed32() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeFixed32(1, 9, false); subject.writeFixed32(2, 8, false); Mockito.verify(delegate).writeFixed32(1,9, false); Mo... |
BlackListOutput implements Output { @Override public void writeSFixed32(int fieldNumber, int value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeSFixed32(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schema... | @Test public void writeSFixed32() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeSFixed32(1, 9, false); subject.writeSFixed32(2, 8, false); Mockito.verify(delegate).writeSFixed32(1,9, false)... |
BlackListOutput implements Output { @Override public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeInt64(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaNameT... | @Test public void writeInt64() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeInt64(1, 9, false); subject.writeInt64(2, 8, false); Mockito.verify(delegate).writeInt64(1,9, false); Mockito.ve... |
BlackListOutput implements Output { @Override public void writeUInt64(int fieldNumber, long value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeUInt64(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaNam... | @Test public void writeUInt64() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeUInt64(1, 9, false); subject.writeUInt64(2, 8, false); Mockito.verify(delegate).writeUInt64(1,9, false); Mockit... |
BlackListOutput implements Output { @Override public void writeSInt64(int fieldNumber, long value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeSInt64(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaNam... | @Test public void writeSInt64() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeSInt64(1, 9, false); subject.writeSInt64(2, 8, false); Mockito.verify(delegate).writeSInt64(1,9, false); Mockit... |
BlackListOutput implements Output { @Override public void writeFixed64(int fieldNumber, long value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeFixed64(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaN... | @Test public void writeFixed64() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeFixed64(1, 9, false); subject.writeFixed64(2, 8, false); Mockito.verify(delegate).writeFixed64(1,9, false); Mo... |
BlackListOutput implements Output { @Override public void writeSFixed64(int fieldNumber, long value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeSFixed64(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schem... | @Test public void writeSFixed64() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeSFixed64(1, 9, false); subject.writeSFixed64(2, 8, false); Mockito.verify(delegate).writeSFixed64(1,9, false)... |
BlackListOutput implements Output { @Override public void writeFloat(int fieldNumber, float value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeFloat(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaName... | @Test public void writeFloat() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeFloat(1, 9, false); subject.writeFloat(2, 8, false); Mockito.verify(delegate).writeFloat(1,9, false); Mockito.ve... |
BlackListOutput implements Output { @Override public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeDouble(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaN... | @Test public void writeDouble() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeDouble(1, 9, false); subject.writeDouble(2, 8, false); Mockito.verify(delegate).writeDouble(1,9, false); Mockit... |
BlackListOutput implements Output { @Override public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeBool(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaName... | @Test public void writeBool() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeBool(1, true, false); subject.writeBool(2, false, false); Mockito.verify(delegate).writeBool(1,true, false); Mock... |
BlackListOutput implements Output { @Override public void writeEnum(int fieldNumber, int value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeEnum(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaNameToBl... | @Test public void writeEnum() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeEnum(1, 1, false); subject.writeEnum(2, 2, false); Mockito.verify(delegate).writeEnum(1,1, false); Mockito.verify... |
BlackListOutput implements Output { @Override public void writeString(int fieldNumber, String value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeString(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schemaN... | @Test public void writeString() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeString(1, "1", false); subject.writeString(2, "2", false); Mockito.verify(delegate).writeString(1,"1", false); ... |
BlackListOutput implements Output { @Override public void writeBytes(int fieldNumber, ByteString value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeBytes(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> schem... | @Test public void writeByteString() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeBytes(1, ByteString.bytesDefaultValue("1"), false); subject.writeBytes(2, ByteString.bytesDefaultValue("2")... |
BlackListOutput implements Output { @Override public void writeByteArray(int fieldNumber, byte[] value, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeByteArray(fieldNumber, value, repeated); } @VisibleForTesting BlackListOutput(
Output delegate, Map<String, int[]> s... | @Test public void writeByteArray() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeByteArray(1, new byte[]{1}, false); subject.writeByteArray(2, new byte[]{2}, false); Mockito.verify(delegate... |
BlackListOutput implements Output { @Override public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } delegate.writeByteRange(utf8String, fieldNumber, value, offset, length, repeated); } @Visib... | @Test public void writeByteRange() throws IOException { Output delegate = Mockito.mock(Output.class); BlackListOutput subject = new BlackListOutput( delegate, Collections.emptyMap(), new int[]{2} ); subject.writeByteRange(false,1, new byte[]{1}, 0, 1, false); subject.writeByteRange(false,2, new byte[]{2}, 0,1,false); M... |
BlackListOutput implements Output { @Override public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated) throws IOException { if(isBlackListed(fieldNumber)){ return; } int[] parentBlackList = currentBlackList; try { String messageFullName = schema.messageFullName(); currentBlackList = sch... | @Test public void writeObject() throws IOException { Output delegate = Mockito.mock(Output.class); Object object = new Object(); String schemaName = "Hello Schema"; String shortName = "Hello"; Schema<Object> schema = Mockito.mock(Schema.class); int[] subSet = new int[]{4}; BlackListOutput subject = new BlackListOutput(... |
HasherOutput implements Output { public Hasher getHasher() { return hasher; } HasherOutput(Hasher hasher); HasherOutput(); @Override void writeInt32(int fieldNumber, int value, boolean repeated); @Override void writeUInt32(int fieldNumber, int value, boolean repeated); @Override void writeSInt32(int fieldNumber, int v... | @Test public void testNoInput() { HasherOutput subject = new HasherOutput(); String result = subject.getHasher().hash().toString(); Assert.assertEquals("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", result); } |
UUIDAdapter { public static byte[] getBytesFromUUID(UUID uuid) { byte[] result = new byte[16]; long msb = uuid.getMostSignificantBits(); long lsb = uuid.getLeastSignificantBits(); for (int i =15;i>=8;i--) { result[i] = (byte) (lsb & 0xFF); lsb >>= 8; } for (int i =7;i>=0;i--) { result[i] = (byte) (msb & 0xFF); msb >>= ... | @Test public void testGet16BytesFromUUID() { UUID uuid = UUID.randomUUID(); byte[] result = UUIDAdapter.getBytesFromUUID(uuid); assertEquals("Expected result to be a byte array with 16 elements.", 16, result.length); }
@Test public void testShouldNotGenerateSameUUIDFromBytes() { UUID uuid = UUID.fromString("38400000-8c... |
SqlUtils { public static boolean isKeyword(String id) { Preconditions.checkState(RESERVED_SQL_KEYWORDS != null, "SQL reserved keyword list is not loaded. Please check the logs for error messages."); return RESERVED_SQL_KEYWORDS.contains(id.toUpperCase()); } static String quotedCompound(List<String> strings); static St... | @Test public void testIsKeyword() { assertTrue(SqlUtils.isKeyword("USER")); assertTrue(SqlUtils.isKeyword("FiLeS")); assertFalse(SqlUtils.isKeyword("myUSER")); } |
SqlUtils { public static String quoteIdentifier(final String id) { if (id.isEmpty()) { return id; } if (isKeyword(id)) { return quoteString(id); } if (Character.isAlphabetic(id.charAt(0)) && ALPHANUM_MATCHER.matchesAllOf(id)) { return id; } if (NEWLINE_MATCHER.matchesAnyOf(id)) { return quoteUnicodeString(id); } return... | @Test public void testQuoteIdentifier() { assertEquals("\"window\"", SqlUtils.quoteIdentifier("window")); assertEquals("\"metadata\"", SqlUtils.quoteIdentifier("metadata")); assertEquals("abc", SqlUtils.quoteIdentifier("abc")); assertEquals("abc123", SqlUtils.quoteIdentifier("abc123")); assertEquals("a_bc", SqlUtils.qu... |
SqlUtils { public static List<String> parseSchemaPath(String schemaPath) { return new StrTokenizer(schemaPath, '.', SqlUtils.QUOTE) .setIgnoreEmptyTokens(true) .getTokenList(); } static String quotedCompound(List<String> strings); static String quoteIdentifier(final String id); static boolean isKeyword(String id); sta... | @Test public void testParseSchemaPath() { assertEquals(asList("a", "b", "c"), SqlUtils.parseSchemaPath("a.b.c")); assertEquals(asList("a"), SqlUtils.parseSchemaPath("a")); assertEquals(asList("a", "b.c", "d"), SqlUtils.parseSchemaPath("a.\"b.c\".d")); assertEquals(asList("a", "c"), SqlUtils.parseSchemaPath("a..c")); } |
OptimisticByteOutput extends ByteOutput { @Override public void write(byte value) { checkArray(); arrayReference[arrayOffset++] = value; } OptimisticByteOutput(int payloadSize); @Override void write(byte value); @Override void write(byte[] value, int offset, int length); @Override void writeLazy(byte[] value, int offse... | @Test public void testWrite() throws IOException { OptimisticByteOutput byteOutput = new OptimisticByteOutput(smallData.length); for (byte b : smallData) { byteOutput.write(b); } byte[] outputData = byteOutput.toByteArray(); assertNotSame(smallData, outputData); assertArrayEquals(smallData, outputData); } |
OptimisticByteOutput extends ByteOutput { public byte[] toByteArray() { if (payloadSize == 0) { return arrayReference != null ? arrayReference : EMPTY; } Preconditions.checkState(arrayOffset == payloadSize, "Byte payload not fully received."); return arrayReference; } OptimisticByteOutput(int payloadSize); @Override vo... | @Test public void testLiteralByteString() throws Exception { ByteString literal = ByteString.copyFrom(smallData); OptimisticByteOutput byteOutput = new OptimisticByteOutput(literal.size()); UnsafeByteOperations.unsafeWriteTo(literal, byteOutput); byte[] array = (byte[]) FieldUtils.readField(literal, "bytes", true); ass... |
PathUtils { public static List<String> toPathComponents(String fsPath) { if (fsPath == null ) { return EMPTY_SCHEMA_PATHS; } final StrTokenizer tokenizer = new StrTokenizer(fsPath, SLASH_CHAR, SqlUtils.QUOTE).setIgnoreEmptyTokens(true); return tokenizer.getTokenList(); } static Path toFSPath(final List<String> schemaP... | @Test public void testPathComponents() throws Exception { assertEquals(ImmutableList.of("a", "b", "c"), PathUtils.toPathComponents(Path.of("/a/b/c"))); assertEquals(ImmutableList.of("a", "b", "c"), PathUtils.toPathComponents(Path.of("a/b/c"))); assertEquals(ImmutableList.of("a", "b", "c/"), PathUtils.toPathComponents(P... |
PathUtils { public static String toDottedPath(Path fsPath) { return constructFullPath(toPathComponents(fsPath)); } static Path toFSPath(final List<String> schemaPath); static String toFSPathString(final List<String> schemaPath); static Path toFSPathSkipRoot(final List<String> schemaPath, final String root); static Pat... | @Test public void testFSPathToSchemaPath() throws Exception { assertEquals("a.b.c", PathUtils.toDottedPath(Path.of("/a/b/c"))); assertEquals("a.b.c", PathUtils.toDottedPath(Path.of("a/b/c"))); assertEquals("a.b.\"c.json\"", PathUtils.toDottedPath(Path.of("/a/b/c.json"))); assertEquals("\"c.json\"", PathUtils.toDottedPa... |
PathUtils { public static Path toFSPath(final List<String> schemaPath) { if (schemaPath == null || schemaPath.isEmpty()) { return ROOT_PATH; } return ROOT_PATH.resolve(PATH_JOINER.join(schemaPath)); } static Path toFSPath(final List<String> schemaPath); static String toFSPathString(final List<String> schemaPath); stat... | @Test public void testToFSPath() throws Exception { assertEquals(Path.of("/a/b/c"), PathUtils.toFSPath("a.b.c")); assertEquals(Path.of("/a/b"), PathUtils.toFSPath("a.b")); assertEquals(Path.of("/c.txt"), PathUtils.toFSPath("\"c.txt\"")); assertEquals(Path.of("/a/b/c.txt"), PathUtils.toFSPath("a.b.\"c.txt\"")); }
@Test ... |
PathUtils { public static Path toFSPathSkipRoot(final List<String> schemaPath, final String root) { if (schemaPath == null || schemaPath.isEmpty()) { return ROOT_PATH; } if (root == null || !root.equals(schemaPath.get(0))) { return toFSPath(schemaPath); } else { return toFSPath(schemaPath.subList(1, schemaPath.size()))... | @Test public void testToFSPathSkipRoot() throws Exception { assertEquals(Path.of("/b/c"), PathUtils.toFSPathSkipRoot(Arrays.asList("a", "b", "c"), "a")); assertEquals(Path.of("/a/b/c"), PathUtils.toFSPathSkipRoot(Arrays.asList("a", "b", "c"), "z")); assertEquals(Path.of("/a/b/c"), PathUtils.toFSPathSkipRoot(Arrays.asLi... |
PathUtils { public static String relativePath(Path absolutePath, Path basePath) { Preconditions.checkArgument(absolutePath.isAbsolute(), "absolutePath must be an absolute path"); Preconditions.checkArgument(basePath.isAbsolute(), "basePath must be an absolute path"); List<String> absolutePathComponents = Lists.newArray... | @Test public void testRelativePath() throws Exception { assertEquals("a", PathUtils.relativePath(Path.of("/a"), Path.of("/"))); assertEquals("b", PathUtils.relativePath(Path.of("/a/b"), Path.of("/a"))); assertEquals("b/c.json", PathUtils.relativePath(Path.of("/a/b/c.json"), Path.of("/a"))); assertEquals("c/d/e", PathUt... |
PathUtils { public static String removeLeadingSlash(String path) { if (path.length() > 0 && path.charAt(0) == '/') { String newPath = path.substring(1); return removeLeadingSlash(newPath); } else { return path; } } static Path toFSPath(final List<String> schemaPath); static String toFSPathString(final List<String> sch... | @Test public void testRemoveLeadingSlash() { assertEquals("", PathUtils.removeLeadingSlash("")); assertEquals("", PathUtils.removeLeadingSlash("/")); assertEquals("aaaa", PathUtils.removeLeadingSlash("/aaaa")); assertEquals("aaaa/bbb", PathUtils.removeLeadingSlash("/aaaa/bbb")); assertEquals("aaaa/bbb", PathUtils.remov... |
PathUtils { public static void verifyNoAccessOutsideBase(Path basePath, Path givenPath) { if (!checkNoAccessOutsideBase(basePath, givenPath)) { throw UserException.permissionError() .message("Not allowed to access files outside of the source root") .addContext("Source root", Path.withoutSchemeAndAuthority(basePath).toS... | @Test public void testVerifyNoAccessOutsideBase() { PathUtils.verifyNoAccessOutsideBase(Path.of("/"), Path.of("/")); PathUtils.verifyNoAccessOutsideBase(Path.of("/"), Path.of("/a")); PathUtils.verifyNoAccessOutsideBase(Path.of("/"), Path.of("/a/b")); PathUtils.verifyNoAccessOutsideBase(Path.of("/a/"), Path.of("/a")); P... |
LocalValue { public void set(T value) { Preconditions.checkNotNull(value, "LocalValue cannot be set to null"); doSet(value); } LocalValue(); @SuppressWarnings("unchecked") Optional<T> get(); void set(T value); void clear(); static LocalValues save(); static void restore(LocalValues localValues); } | @Test public void testSet() throws Exception { stringLocalValue.set("value1"); intLocalValue.set(1); assertEquals("value1", stringLocalValue.get().get()); assertEquals(new Integer(1), intLocalValue.get().get()); stringLocalValue.set("value2"); intLocalValue.set(2); assertEquals("value2", stringLocalValue.get().get()); ... |
LocalValue { public void clear() { doSet(null); } LocalValue(); @SuppressWarnings("unchecked") Optional<T> get(); void set(T value); void clear(); static LocalValues save(); static void restore(LocalValues localValues); } | @Test public void testClear() { stringLocalValue.set("value1"); intLocalValue.set(1); stringLocalValue.clear(); intLocalValue.clear(); assertFalse(stringLocalValue.get().isPresent()); assertFalse(intLocalValue.get().isPresent()); } |
VM { private static final long maxDirectMemory() { try { return invokeMaxDirectMemory("sun.misc.VM"); } catch (ReflectiveOperationException ignored) { } try { return invokeMaxDirectMemory("jdk.internal.misc.VM"); } catch (ReflectiveOperationException ignored) { } final List<String> inputArguments = ManagementFactory.ge... | @Test public void checkMaxDirectMemory() { assertThat(VM.maxDirectMemory(arguments), is(maxDirectMemory)); } |
VM { public static boolean isDebugEnabled() { return IS_DEBUG; } private VM(); static boolean isDebugEnabled(); static int availableProcessors(); static long getMaxDirectMemory(); static long getMaxHeapMemory(); static boolean isMacOSHost(); static boolean isWindowsHost(); static final String DREMIO_CPU_AVAILABLE_PROP... | @Test public void checkDebugEnabled() { assertThat(VM.isDebugEnabled(arguments), is(debugEnabled)); } |
TimeMilliAccessor extends AbstractSqlAccessor { @Override public boolean isNull(int index) { return ac.isNull(index); } TimeMilliAccessor(TimeMilliVector vector, TimeZone defaultTZ); @Override MajorType getType(); @Override boolean isNull(int index); @Override Class<?> getObjectClass(); @Override Object getObject(int i... | @Test public void testIsNull() throws Exception { assertNotNull(accessor.getObject(0)); assertNotNull(accessor.getTime(0, PST_CALENDAR)); assertNull(accessor.getObject(1)); assertNull(accessor.getTime(1, PST_CALENDAR)); } |
TimeMilliAccessor extends AbstractSqlAccessor { @Override public Object getObject(int index) { return getTime(index, defaultTimeZone); } TimeMilliAccessor(TimeMilliVector vector, TimeZone defaultTZ); @Override MajorType getType(); @Override boolean isNull(int index); @Override Class<?> getObjectClass(); @Override Objec... | @Test public void testGetObject() throws Exception { assertEquals(new TimePrintMillis(NON_NULL_VALUE), accessor.getObject(0)); } |
TimeMilliAccessor extends AbstractSqlAccessor { @Override public Time getTime(int index, Calendar calendar) { Preconditions.checkNotNull(calendar, "Invalid calendar used when attempting to retrieve time."); return getTime(index, calendar.getTimeZone()); } TimeMilliAccessor(TimeMilliVector vector, TimeZone defaultTZ); @... | @Test(expected=NullPointerException.class) public void testNullCalendar() throws InvalidAccessException { accessor.getTime(0, null); }
@Test public void testGetTime() throws Exception { assertEquals( new TimePrintMillis(LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 14, 07, (int)TimeUnit.MILLISECONDS.toNanos(234))))... |
DateMilliAccessor extends AbstractSqlAccessor { @Override public boolean isNull(int index) { return ac.isNull(index); } DateMilliAccessor(DateMilliVector vector, TimeZone defaultTZ); @Override MajorType getType(); @Override boolean isNull(int index); @Override Class<?> getObjectClass(); @Override Object getObject(int i... | @Test public void testIsNull() throws Exception { assertNotNull(accessor.getObject(0)); assertNotNull(accessor.getDate(0, PST_CALENDAR)); assertNull(accessor.getObject(2)); assertNull(accessor.getDate(2, PST_CALENDAR)); } |
DateMilliAccessor extends AbstractSqlAccessor { @Override public Object getObject(int index) { return getDate(index, defaultTimeZone); } DateMilliAccessor(DateMilliVector vector, TimeZone defaultTZ); @Override MajorType getType(); @Override boolean isNull(int index); @Override Class<?> getObjectClass(); @Override Objec... | @Test public void testGetObject() throws Exception { assertEquals(new Date(72, 10, 4), accessor.getObject(0)); } |
DateMilliAccessor extends AbstractSqlAccessor { @Override public Date getDate(int index, Calendar calendar) { Preconditions.checkNotNull(calendar, "Invalid calendar used when attempting to retrieve date."); return getDate(index, calendar.getTimeZone()); } DateMilliAccessor(DateMilliVector vector, TimeZone defaultTZ); @... | @Test(expected=NullPointerException.class) public void testNullCalendar() throws InvalidAccessException { accessor.getDate(0, null); }
@Test public void testGetDate() throws Exception { assertEquals(new Date(72, 10, 3), accessor.getDate(0, PST_CALENDAR)); assertEquals(new Date(72, 10, 4), accessor.getDate(0, UTC_CALEND... |
GenericAccessor extends AbstractSqlAccessor { @Override public boolean isNull(int index) { return v.isNull(index); } GenericAccessor(ValueVector v); @Override Class<?> getObjectClass(); @Override boolean isNull(int index); @Override Object getObject(int index); @Override MajorType getType(); } | @Test public void testIsNull() throws Exception { assertFalse(genericAccessor.isNull(0)); assertTrue(genericAccessor.isNull(1)); } |
GenericAccessor extends AbstractSqlAccessor { @Override public Object getObject(int index) throws InvalidAccessException { return v.getObject(index); } GenericAccessor(ValueVector v); @Override Class<?> getObjectClass(); @Override boolean isNull(int index); @Override Object getObject(int index); @Override MajorType get... | @Test public void testGetObject() throws Exception { assertEquals(NON_NULL_VALUE, genericAccessor.getObject(0)); assertNull(genericAccessor.getObject(1)); }
@Test(expected=IndexOutOfBoundsException.class) public void testGetObject_indexOutOfBounds() throws Exception { genericAccessor.getObject(2); } |
GenericAccessor extends AbstractSqlAccessor { @Override public MajorType getType() { return getMajorTypeForField(v.getField()); } GenericAccessor(ValueVector v); @Override Class<?> getObjectClass(); @Override boolean isNull(int index); @Override Object getObject(int index); @Override MajorType getType(); } | @Test public void testGetType() throws Exception { assertEquals(UserBitShared.SerializedField.getDefaultInstance().getMajorType(), genericAccessor.getType()); } |
TimeStampMilliAccessor extends AbstractSqlAccessor { @Override public boolean isNull(int index) { return ac.isNull(index); } TimeStampMilliAccessor(TimeStampMilliVector vector, TimeZone defaultTZ); @Override MajorType getType(); @Override boolean isNull(int index); @Override Class<?> getObjectClass(); @Override Object ... | @Test public void testIsNull() throws Exception { assertNotNull(accessor.getObject(0)); assertNotNull(accessor.getTimestamp(0, PST_CALENDAR)); assertNull(accessor.getObject(2)); assertNull(accessor.getTimestamp(2, PST_CALENDAR)); } |
TimeStampMilliAccessor extends AbstractSqlAccessor { @Override public Object getObject(int index) { return getTimestamp(index, defaultTimeZone); } TimeStampMilliAccessor(TimeStampMilliVector vector, TimeZone defaultTZ); @Override MajorType getType(); @Override boolean isNull(int index); @Override Class<?> getObjectClas... | @Test public void testGetObject() throws Exception { assertEquals( new Timestamp(72, 10, 4, 11, 10, 8, (int)TimeUnit.MILLISECONDS.toNanos(957)), accessor.getObject(0)); } |
TimeStampMilliAccessor extends AbstractSqlAccessor { @Override public Timestamp getTimestamp(int index, Calendar calendar) { Preconditions.checkNotNull(calendar, "Invalid calendar used when attempting to retrieve timestamp."); return getTimestamp(index, calendar.getTimeZone()); } TimeStampMilliAccessor(TimeStampMilliVe... | @Test(expected=NullPointerException.class) public void testNullCalendar() throws InvalidAccessException { accessor.getTimestamp(0, null); }
@Test public void testGetTimestamp() throws Exception { assertEquals( new Timestamp(72, 10, 4, 3, 10, 8, (int)TimeUnit.MILLISECONDS.toNanos(957)), accessor.getTimestamp(0, PST_CALE... |
ReplaceRecommender extends Recommender<ReplacePatternRule, Selection> { public TransformRuleWrapper<ReplacePatternRule> wrapRule(ReplacePatternRule rule) { return new ReplaceTransformRuleWrapper(rule); } @Override List<ReplacePatternRule> getRules(Selection selection, DataType selColType); TransformRuleWrapper<Replace... | @Test public void contains() throws Exception { final File dataFile = temp.newFile("containsTest.json"); try (final PrintWriter printWriter = new PrintWriter(dataFile)) { printWriter.append("{ \"col\" : \"This is an amazing restaurant. Very good food.\" }"); printWriter.append("{ \"col\" : \"This is a worst restaurant.... |
TypeConvertingSqlAccessor implements SqlAccessor { @Override public byte getByte( int rowOffset ) throws InvalidAccessException { final byte result; switch ( getType().getMinorType() ) { case TINYINT: result = innerAccessor.getByte( rowOffset ); break; case SMALLINT: result = getByteValueOrThrow( innerAccessor.getShort... | @Test public void test_getByte_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getByte( 0 ), equalTo( (byte) 127 ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (by... |
TypeConvertingSqlAccessor implements SqlAccessor { @Override public short getShort( int rowOffset ) throws InvalidAccessException { final short result; switch ( getType().getMinorType() ) { case SMALLINT: result = innerAccessor.getShort( rowOffset ); break; case TINYINT: result = innerAccessor.getByte( rowOffset ); bre... | @Test public void test_getShort_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getShort( 0 ), equalTo( (short) 127 ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( ... |
TypeConvertingSqlAccessor implements SqlAccessor { @Override public int getInt( int rowOffset ) throws InvalidAccessException { final int result; switch ( getType().getMinorType() ) { case INT: result = innerAccessor.getInt( rowOffset ); break; case TINYINT: result = innerAccessor.getByte( rowOffset ); break; case SMAL... | @Test public void test_getInt_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getInt( 0 ), equalTo( 127 ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) -128 ... |
TypeConvertingSqlAccessor implements SqlAccessor { @Override public long getLong( int rowOffset ) throws InvalidAccessException { final long result; switch ( getType().getMinorType() ) { case BIGINT: result = innerAccessor.getLong( rowOffset ); break; case TINYINT: result = innerAccessor.getByte( rowOffset ); break; ca... | @Test public void test_getLong_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getLong( 0 ), equalTo( 127L ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) -1... |
Upgrade { @VisibleForTesting public void validateUpgrade(final LegacyKVStoreProvider storeProvider, final String curEdition) throws Exception { if (!getDACConfig().isMigrationEnabled()) { final ConfigurationStore configurationStore = new ConfigurationStore(storeProvider); final ConfigurationEntry entry = configurationS... | @Test public void testIllegalUpgrade() throws Exception { thrown.expect(Exception.class); thrown.expectMessage("Illegal upgrade from OSS to EE"); final ByteString prevEdition = ByteString.copyFrom("OSS".getBytes()); final ConfigurationEntry configurationEntry = new ConfigurationEntry(); configurationEntry.setValue(prev... |
TypeConvertingSqlAccessor implements SqlAccessor { @Override public float getFloat( int rowOffset ) throws InvalidAccessException { final float result; switch ( getType().getMinorType() ) { case FLOAT4: result = innerAccessor.getFloat( rowOffset ); break; case INT: result = innerAccessor.getInt( rowOffset ); break; cas... | @Test public void test_getFloat_on_FLOAT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new FloatStubAccessor( 1.23f ) ); assertThat( uut1.getFloat( 0 ), equalTo( 1.23f ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new FloatStubAccessor( Float.MAX_VALUE )... |
TypeConvertingSqlAccessor implements SqlAccessor { @Override public double getDouble( int rowOffset ) throws InvalidAccessException { final double result; switch ( getType().getMinorType() ) { case FLOAT8: result = innerAccessor.getDouble( rowOffset ); break; case INT: result = innerAccessor.getInt( rowOffset ); break;... | @Test public void test_getDouble_on_FLOAT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new FloatStubAccessor( 6.02e23f ) ); assertThat( uut1.getDouble( 0 ), equalTo( (double) 6.02e23f ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new FloatStubAccessor( ... |
DictionaryBuilder { public Iterable<T> build() { Preconditions.checkArgument(!isBuilt, "build can only be called once"); isBuilt = true; if (valueAccumulator.isEmpty()) { return Collections.emptyList(); } final T[] values = ObjectArrays.newArray(clazzType, valueAccumulator.size()); for (ObjectIntCursor<T> entry : value... | @Test public void testEmpty() { DictionaryBuilder<String> builder = new DictionaryBuilder<>(String.class); Iterator<String> iterator = builder.build().iterator(); assertFalse(iterator.hasNext()); } |
HiveReaderProtoUtil { @Deprecated static Map<String, Integer> buildInputFormatLookup(HiveTableXattrOrBuilder tableXattr) { int i = 0; final Map<String, Integer> lookup = Maps.newHashMap(); for (final PartitionXattr partitionXattr : tableXattr.getPartitionXattrsList()) { if (partitionXattr.hasInputFormat() && !lookup.co... | @Test public void buildInputFormatLookup() { { assertTrue(HiveReaderProtoUtil.buildInputFormatLookup(HiveTableXattr.newBuilder().build()).size() == 0); } { HiveTableXattr xattr = HiveTableXattr.newBuilder() .addAllPartitionXattrs( Lists.newArrayList( newPartitionXattrWithInputFormat("a"), newPartitionXattrWithInputForm... |
HiveReaderProtoUtil { @Deprecated static Map<Prop, Integer> buildPropLookup(HiveTableXattrOrBuilder tableXattr) { int i = 0; final Map<Prop, Integer> lookup = Maps.newHashMap(); for (final PartitionXattr partitionXattr : tableXattr.getPartitionXattrsList()) { for (final Prop prop : partitionXattr.getPartitionPropertyLi... | @Test public void buildPropLookup() { { assertTrue(HiveReaderProtoUtil.buildPropLookup(HiveTableXattr.newBuilder().build()).size() == 0); } { HiveTableXattr.Builder xattr = HiveTableXattr.newBuilder() .addAllPartitionXattrs( Lists.newArrayList( newPartitionXattrWithProps(newProp("a", "b")), newPartitionXattrWithProps(n... |
DremioFileSystem extends FileSystem { void updateOAuthConfig(Configuration conf, String accountName, String accountNameWithoutSuffix) { final String CLIENT_ID = "dremio.azure.clientId"; final String TOKEN_ENDPOINT = "dremio.azure.tokenEndpoint"; final String CLIENT_SECRET = "dremio.azure.clientSecret"; String refreshTo... | @Test public void testAzureOauthCopy() { DremioFileSystem fileSystem = new DremioFileSystem(); Configuration conf = new Configuration(); conf.set(FS_AZURE_ACCOUNT_OAUTH_CLIENT_ENDPOINT, ENDPOINT); conf.set(FS_AZURE_ACCOUNT_OAUTH_CLIENT_ID, CLIEN_ID); conf.set(FS_AZURE_ACCOUNT_OAUTH_CLIENT_SECRET, PASSWORD); fileSystem.... |
HiveScanBatchCreator implements HiveProxiedScanBatchCreator { @VisibleForTesting public UserGroupInformation getUGI(HiveStoragePlugin storagePlugin, HiveProxyingSubScan config) { final String userName = storagePlugin.getUsername(config.getProps().getUserName()); return HiveImpersonationUtil.createProxyUgi(userName); } ... | @Test public void ensureStoragePluginIsUsedForUsername() throws Exception { final String originalName = "Test"; final String finalName = "Replaced"; final HiveScanBatchCreator creator = new HiveScanBatchCreator(); final HiveStoragePlugin plugin = mock(HiveStoragePlugin.class); when(plugin.getUsername(originalName)).the... |
HiveScanBatchCreator implements HiveProxiedScanBatchCreator { boolean allSplitsAreOnS3(List<SplitAndPartitionInfo> splits) { for (SplitAndPartitionInfo split : splits) { try { final HiveReaderProto.HiveSplitXattr splitAttr = HiveReaderProto.HiveSplitXattr.parseFrom(split.getDatasetSplitInfo().getExtendedProperty()); fi... | @Test public void testAllSplitsAreOnS3() { List<SplitAndPartitionInfo> s3Splits = buildSplits("s3"); List<SplitAndPartitionInfo> hdfsplits = buildSplits("hdfs"); HiveScanBatchCreator scanBatchCreator = new HiveScanBatchCreator(); assertTrue(scanBatchCreator.allSplitsAreOnS3(s3Splits)); assertFalse(scanBatchCreator.allS... |
HiveStoragePlugin extends BaseHiveStoragePlugin implements StoragePluginCreator.PF4JStoragePlugin, SupportsReadSignature,
SupportsListingDatasets, SupportsAlteringDatasetMetadata, SupportsPF4JStoragePlugin { public String getUsername(String name) { if (isStorageImpersonationEnabled()) { return name; } return System... | @Test public void impersonationDisabledShouldReturnSystemUser() { final HiveConf hiveConf = new HiveConf(); hiveConf.setBoolVar(HIVE_SERVER2_ENABLE_DOAS, false); final SabotContext context = mock(SabotContext.class); final HiveStoragePlugin plugin = createHiveStoragePlugin(hiveConf, context); final String userName = pl... |
S3FileSystem extends ContainerFileSystem implements MayProvideAsyncStream { static software.amazon.awssdk.regions.Region getAwsRegionFromEndpoint(String endpoint) { return Optional.ofNullable(endpoint) .map(e -> e.toLowerCase(Locale.ROOT)) .filter(e -> e.endsWith(S3_ENDPOINT_END) || e.endsWith(S3_CN_ENDPOINT_END)) .fla... | @Test public void testValidRegionFromEndpoint() { Region r = S3FileSystem.getAwsRegionFromEndpoint("s3-eu-central-1.amazonaws.com"); Assert.assertEquals(Region.EU_CENTRAL_1, r); r = S3FileSystem.getAwsRegionFromEndpoint("s3-us-gov-west-1.amazonaws.com"); Assert.assertEquals(Region.US_GOV_WEST_1, r); r = S3FileSystem.ge... |
S3FileSystem extends ContainerFileSystem implements MayProvideAsyncStream { @Override protected ContainerHolder getUnknownContainer(String containerName) throws IOException { boolean containerFound = false; try { if (s3.doesBucketExistV2(containerName)) { final ListObjectsV2Request req = new ListObjectsV2Request() .wit... | @Test public void testUnknownContainerExists() { TestExtendedS3FileSystem fs = new TestExtendedS3FileSystem(); AmazonS3 mockedS3Client = mock(AmazonS3.class); when(mockedS3Client.doesBucketExistV2(any(String.class))).thenReturn(true); ListObjectsV2Result result = new ListObjectsV2Result(); result.setBucketName("testunk... |
SplitRecommender extends Recommender<SplitRule, Selection> { @Override public List<SplitRule> getRules(Selection selection, DataType selColType) { checkArgument(selColType == DataType.TEXT, "Split is supported only on TEXT type columns"); List<SplitRule> rules = new ArrayList<>(); String seltext = selection.getCellText... | @Test public void ruleSuggestionsAlphabetCharsDelimiter() { Selection selection = new Selection("col", "abbbabbabbaaa", 1, 2); List<SplitRule> rules = recommender.getRules(selection, TEXT); assertEquals(2, rules.size()); compare(MatchType.exact, "bb", false, rules.get(0)); compare(MatchType.exact, "bb", true, rules.get... |
S3FileSystem extends ContainerFileSystem implements MayProvideAsyncStream { protected void verifyCredentials(Configuration conf) throws RuntimeException { AwsCredentialsProvider awsCredentialsProvider = getAsync2Provider(conf); final StsClientBuilder stsClientBuilder = StsClient.builder() .credentialsProvider(awsCreden... | @Test public void testVerifyCredentialsRetry() { PowerMockito.mockStatic(StsClient.class); StsClient mockedClient = mock(StsClient.class); StsClientBuilder mockedClientBuilder = mock(StsClientBuilder.class); when(mockedClientBuilder.credentialsProvider(any(AwsCredentialsProvider.class))).thenReturn(mockedClientBuilder)... |
ContainerFileSystem extends FileSystem { @VisibleForTesting static Path transform(Path path, String containerName) { final String relativePath = removeLeadingSlash(Path.getPathWithoutSchemeAndAuthority(path).toString()); final Path containerPath = new Path(Path.SEPARATOR + containerName); return Strings.isNullOrEmpty(r... | @Test public void transformContainerPathWithColon() { final Path path = new Path("s3a: final String containerName = "qa1.dremio.com"; final Path transformed = ContainerFileSystem.transform(path, containerName); Assert.assertEquals(new Path("/qa1.dremio.com/test:breaks"), transformed); } |
AzureAsyncReader extends ExponentialBackoff implements AutoCloseable, AsyncByteReader { @Override public CompletableFuture<Void> readFully(long offset, ByteBuf dst, int dstOffset, int len) { return read(offset, dst, dstOffset, len, 0); } AzureAsyncReader(final String accountName,
final Path pa... | @Test public void testAsyncHttpClientClosedError() { AsyncHttpClient client = mock(AsyncHttpClient.class); when(client.isClosed()).thenReturn(true); LocalDateTime versionDate = LocalDateTime.now(ZoneId.of("GMT")).minusDays(2); AzureAsyncReader azureAsyncReader = spy(new AzureAsyncReader( "account", new Path("container/... |
AzureAsyncContainerProvider implements ContainerProvider { @Override public Stream<ContainerFileSystem.ContainerCreator> getContainerCreators() { Iterator<String> containerIterator = new DFSContainerIterator(asyncHttpClient, account, authProvider, isSecure, retryer); return StreamSupport.stream(Spliterators.spliterator... | @Test public void testListContainers() throws IOException, ExecutionException, InterruptedException { AsyncHttpClient client = mock(AsyncHttpClient.class); Response response = mock(Response.class); when(response.getHeader(any(String.class))).thenReturn(""); HttpResponseStatus status = mock(HttpResponseStatus.class); wh... |
AzureAsyncContainerProvider implements ContainerProvider { @Override public void assertContainerExists(final String containerName) { logger.debug("Checking for missing azure container " + account + ":" + containerName); final Request req = new RequestBuilder(HttpConstants.Methods.HEAD) .addHeader("x-ms-date", toHttpDat... | @Test public void testDoesContainerExists() throws ExecutionException, InterruptedException { AzureStorageFileSystem parentClass = mock(AzureStorageFileSystem.class); AzureAuthTokenProvider authTokenProvider = getMockAuthTokenProvider(); AsyncHttpClient client = mock(AsyncHttpClient.class); Response response = mock(Res... |
AsyncHttpClientProvider { public static AsyncHttpClient getInstance(){ return SingletonHelper.INSTANCE; } static AsyncHttpClient getInstance(); static final int DEFAULT_REQUEST_TIMEOUT; } | @Test public void testSameInstance() throws InterruptedException { ExecutorService ex = Executors.newFixedThreadPool(10); final Set<Integer> objectIdentities = new ConcurrentSkipListSet<>(); CountDownLatch latch = new CountDownLatch(100); for (int i=0; i<100; i++) { ex.execute(() -> { objectIdentities.add(System.identi... |
AzureSharedKeyAuthTokenProvider implements AzureAuthTokenProvider { @Override public String getAuthzHeaderValue(final Request req) { try { final URL url = new URL(req.getUrl()); final Map<String, String> headersMap = new HashMap<>(); req.getHeaders().forEach(header -> headersMap.put(header.getKey(), header.getValue()))... | @Test public void testGetAuthzHeaderValue() { String authzHeaderValue = authTokenProvider.getAuthzHeaderValue(prepareTestRequest()); assertEquals("SharedKey mock-account:ZwovG4J+nCDc3w58WPei6fvJBQsO96YojteJncy0wwI=", authzHeaderValue); } |
AzureSharedKeyAuthTokenProvider implements AzureAuthTokenProvider { @Override public boolean checkAndUpdateToken() { return false; } AzureSharedKeyAuthTokenProvider(final String accountName, final String key); @Override boolean checkAndUpdateToken(); @Override String getAuthzHeaderValue(final Request req); @Override bo... | @Test public void testCheckAndUpdate() { assertFalse("Shared key token is static. There shouldn't ever be an update required", authTokenProvider.checkAndUpdateToken()); } |
AzureSharedKeyAuthTokenProvider implements AzureAuthTokenProvider { @Override public boolean isCloseToExpiry() { return false; } AzureSharedKeyAuthTokenProvider(final String accountName, final String key); @Override boolean checkAndUpdateToken(); @Override String getAuthzHeaderValue(final Request req); @Override boolea... | @Test public void testIsCloseToExpiry() { assertFalse("Shared key token never expires", authTokenProvider.isCloseToExpiry()); } |
RemoteNodeFileSystem extends FileSystem { static DFS.FileStatus toProtoFileStatus(FileStatus status) throws IOException { DFS.FileStatus.Builder builder = DFS.FileStatus.newBuilder(); builder .setLength(status.getLen()) .setIsDirectory(status.isDirectory()) .setBlockReplication(status.getReplication()) .setBlockSize(st... | @Test public void testToProtobuFileStatus() throws IOException { FileStatus status = TEST_FILE_STATUS; DFS.FileStatus result = RemoteNodeFileSystem.toProtoFileStatus(status); assertEquals(TEST_PATH_STRING, result.getPath()); assertEquals(1024,result.getLength()); assertFalse(result.getIsDirectory()); assertEquals(1, re... |
RemoteNodeFileSystem extends FileSystem { @Override public FileStatus getFileStatus(Path f) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); final GetFileStatusCommand command = new GetFileStatusCommand(absolutePath.toUri().getPath()); runner.runCommand(command); RpcFuture<DFS.GetFil... | @Test public void testGetFileStatusRoot() throws Exception { { DFS.FileStatus status = newFileStatus(1024L, true, 0, 4096L, 37L, 42L, 0755, "root", "wheel", "/"); setupRPC( DFS.RpcType.GET_FILE_STATUS_REQUEST, DFS.GetFileStatusRequest.newBuilder().setPath("/").build(), DFS.RpcType.GET_FILE_STATUS_RESPONSE, DFS.GetFileS... |
SplitRecommender extends Recommender<SplitRule, Selection> { public TransformRuleWrapper<SplitRule> wrapRule(SplitRule rule) { return new SplitTransformRuleWrapper(rule); } @Override List<SplitRule> getRules(Selection selection, DataType selColType); TransformRuleWrapper<SplitRule> wrapRule(SplitRule rule); } | @Test public void splitListCardGen() throws Exception { File dataFile = temp.newFile("splitExact.json"); try (PrintWriter writer = new PrintWriter(dataFile)) { writer.append("{ \"col\" : \"aBa\" }"); writer.append("{ \"col\" : \"abaBa\" }"); writer.append("{ \"col\" : null }"); writer.append("{ \"col\" : \"abababa\" }"... |
RemoteNodeFileSystem extends FileSystem { @Override public FileStatus[] listStatus(Path f) throws FileNotFoundException, IOException { RemoteIterator<FileStatus> remoteIterator = listStatusIterator(f); List<FileStatus> statuses = new ArrayList<>(); while(remoteIterator.hasNext()) { statuses.add(remoteIterator.next()); ... | @Test public void testListStatusRoot() throws Exception { { DFS.ListStatusResponse listStatusResponse = DFS.ListStatusResponse.newBuilder() .addStatuses(newFileStatus(42, true, 0, 0, 456, 879, 0755, "root", "wheel", "/foo")) .addStatuses(newFileStatus(1024, false, 1, 4096, 354, 435, 0644, "admin", "admin", "/bar")) .bu... |
RemoteNodeFileSystem extends FileSystem { @Override public boolean delete(Path f, boolean recursive) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); final DeleteCommand command = new DeleteCommand(absolutePath.toUri().getPath(), recursive); runner.runCommand(command); RpcFuture<DFS.... | @Test public void testDeleteWithValidPath() throws Exception { setupRPC( DFS.RpcType.DELETE_REQUEST, DFS.DeleteRequest.newBuilder().setPath("/foo/bar").setRecursive(true).build(), DFS.RpcType.DELETE_RESPONSE, DFS.DeleteResponse.newBuilder().setValue(true).build()); FileSystem fs = newRemoteNodeFileSystem(); Path path =... |
RemoteNodeFileSystem extends FileSystem { @Override public boolean mkdirs(Path f, FsPermission permission) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); final MkdirsCommand command = new MkdirsCommand( absolutePath.toUri().getPath(), permission != null ? (int) permission.toExtende... | @Test public void testMkdirsWithValidPath() throws Exception { setupRPC( DFS.RpcType.MKDIRS_REQUEST, DFS.MkdirsRequest.newBuilder().setPath("/foo/bar").setPermission(0755).build(), DFS.RpcType.MKDIRS_RESPONSE, DFS.MkdirsResponse.newBuilder().setValue(true).build()); FileSystem fs = newRemoteNodeFileSystem(); Path path ... |
RemoteNodeFileSystem extends FileSystem { @Override public boolean rename(Path src, Path dst) throws IOException { Path absoluteSrc = toAbsolutePath(src); Path absoluteDst = toAbsolutePath(dst); checkPath(absoluteSrc); checkPath(absoluteDst); final RenameCommand command = new RenameCommand(absoluteSrc.toUri().getPath()... | @Test public void testRenameWithValidPath() throws Exception { setupRPC( DFS.RpcType.RENAME_REQUEST, DFS.RenameRequest.newBuilder().setOldpath("/foo/bar").setNewpath("/foo/bar2").build(), DFS.RpcType.RENAME_RESPONSE, DFS.RenameResponse.newBuilder().setValue(true).build()); FileSystem fs = newRemoteNodeFileSystem(); Pat... |
RemoteNodeFileSystem extends FileSystem { @Override public FSDataInputStream open(Path f, int bufferSize) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); final String path = absolutePath.toUri().getPath(); return new FSDataInputStream(new RemoteNodeInputStream(path, bufferSize)); } ... | @Test public void testInputStream() throws Exception { Path filePath = new Path("/foo/bar"); byte[] data = new byte[100]; for (int i = 0; i < 100; ++i) { data[i] = (byte)i; } byte [] readBuf = new byte[1000]; ByteBuf byteBuf = Unpooled.wrappedBuffer(data, 0, 100); setupRPC( DFS.RpcType.GET_FILE_DATA_REQUEST, DFS.GetFil... |
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public FileStatus getFileStatus(Path f) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); if (!isRemoteFile(absolutePath)) { return new GetFileStatusTask(absolutePath).get(); } try { RemotePath rem... | @Test public void testGetFileStatusRoot() throws IOException { Path root = new Path("/"); FileStatus status = fs.getFileStatus(root); assertEquals(new Path("pdfs:/"), status.getPath()); assertTrue(status.isDirectory()); assertEquals(0555, status.getPermission().toExtendedShort()); }
@Test public void testGetFileStatusF... |
DatasetTool { History getHistory(final DatasetPath datasetPath, DatasetVersion currentDataset) throws DatasetVersionNotFoundException { return getHistory(datasetPath, currentDataset, currentDataset); } DatasetTool(
DatasetVersionMutator datasetService,
JobsService jobsService,
QueryExecutor executor,
Se... | @Test public void testBrokenHistory() throws Exception { DatasetPath datasetPath = new DatasetPath(Arrays.asList("space", "dataset")); DatasetVersion current = new DatasetVersion("123"); DatasetVersion tip = new DatasetVersion("456"); DatasetVersion broken = new DatasetVersion("001"); VirtualDatasetUI tipDataset = new ... |
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public FileStatus[] listStatus(Path f) throws FileNotFoundException, IOException { final RemoteIterator<FileStatus> remoteIterator = listStatusIterator(f); final List<FileStatus> statuses = Lists.newArrayList(); while (remoteIterato... | @Test public void testListStatusRoot() throws IOException { Path root = new Path("/"); FileStatus[] statuses = fs.listStatus(root); assertEquals(1, statuses.length); assertEquals(new Path("pdfs:/foo"), statuses[0].getPath()); assertTrue(statuses[0].isDirectory()); assertEquals(0755, statuses[0].getPermission().toExtend... |
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public RemoteIterator<FileStatus> listStatusIterator(Path f) throws FileNotFoundException, IOException { final Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); if (isRemoteFile(absolutePath)) { return new RemoteIterat... | @Test public void testListStatusIteratorPastLastElement() throws IOException { final Path root = new Path("/"); final RemoteIterator<FileStatus> statusIter = fs.listStatusIterator(root); while (statusIter.hasNext()) { statusIter.next(); } try { statusIter.next(); fail("NoSuchElementException should be throw when next()... |
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public FSDataInputStream open(Path f, int bufferSize) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); if (absolutePath.isRoot()) { throw new AccessControlException("Cannot open " + f); } try { Re... | @Test public void testOpenRoot() throws IOException { Path root = new Path("/"); try { fs.open(root); fail("Expected open call to throw an exception"); } catch (AccessControlException e) { } }
@Test public void testOpenFile() throws IOException { FSDataInputStream mockFDIS = mock(FSDataInputStream.class); doReturn(mock... |
Transformer { public VirtualDatasetUI transformWithExtract(DatasetVersion newVersion, DatasetPath path, VirtualDatasetUI baseDataset, TransformBase transform) throws DatasetNotFoundException, NamespaceException{ final ExtractTransformActor actor = new ExtractTransformActor(baseDataset.getState(), false, username(), exe... | @Test public void testTransformWithExtract() throws Exception { setSpace(); DatasetPath myDatasetPath = new DatasetPath("spacefoo.folderbar.folderbaz.datasetbuzz"); createDatasetFromParentAndSave(myDatasetPath, "cp.\"tpch/supplier.parquet\""); DatasetUI dataset = getDataset(myDatasetPath); Transformer testTransformer =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.