I am looking to create a pdf using latex but i couldn't position graphics correctly - graphics

I am trying to make a copy of the photo below using LaTeX but I don't know how to wrap images around a text; they always go to the middle
These are the two images:
\documentclass[9pt]{book}
\usepackage[9pt,article]{extsizes}
\usepackage[russian]{babel}
\usepackage{amssymb,amsmath,amsfonts}
\usepackage{mathtools}
\usepackage{fancyhdr}
\usepackage{textcomp,enumitem}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage[left=4.9cm,right=5.8cm,top=3cm,bottom=2cm,bindingoffset=0cm]{geometry}
\linespread{0.9}
\usepackage{ragged2e}
\usepackage{color}
\usepackage{graphics}
\usepackage{pgfplots}
\pagestyle{fancy}
\thispagestyle{empty}
\usepackage{wrapfig}
\begin{document}
\begin{flushleft}
\small{\bf 72 ]} \scriptsize{\hfill 7. НЕКОТОРЫЕ ГЕОМЕТРИЧЕСКИЕ ПРИЛОЖЕНИЯ \footnotesize\hfill 171}
\end{flushleft}
\ \indent Заметим, что изменение радиуса кривизны совсем не так наглядно, как изменение касательной. Рассмотрим линию, состоящую из отрезка \textit{АВ} пря- мой и дуги\textit{ ВС} окружности, касательной к отрезку в конце в (рис. 79). На участке\textit{ AB }радиус кривизны равен бесконечности, на участке жеn\textit{ВС}
\begin{wrapfigure}{r}{0.5\textwidth}
\includegraphics[width=2cm]{photo1.PNG} \includegraphics[width=50pt]{Image-015_23_30_45.jpg}
\end{wrapfigure}
он равен радиусу окружности r и, таким образом, в точке \textit{B} он терпит разрыв непрерывности, хотя при этом направление касательной ме- няется непрерывно. Этим обстоятель- ством объясняются толчки вагонов на поворотах. Допустим, что вели- чина скорости движения вагона остается неизменной. В этом случае, как известно из механики, сила будет направлена по нормали к траектории
и равна $m \frac {v^2}R$ где м есть масса движущегося тела и R - радиус кривизны R траектории. Отсюда видно, что в точках разрыва непрерывности радиуса кривизны и сила будет претерпевать разрыв непрерывности, что и обуслов- ливает толчок.\\
\vskip\textbf{72. Асимптоти}
Перейдем теперь к изучению бесконечных ветвей кривой, на которых одна из координат х или у или обе вместе беспре\begin{wrapfigure}{l}{0.5\textwidth}
\includegraphics[width=4cm]{latex firsr graphic.png}
\end{wrapfigure}дельно возрастают. Гипербола и па- рабола дают нам примеры кривых с беско- нечными ветвями.Асимптотой кривой с бесконечною ветвью называемся такая прямая, что расстояние точек кривой до этой пря- мой при беспредельном удалении по беско- нечной ветви стремится к нулю.
Покажем сначала, как находить асимпто- ты кривой, параллельные оси \textit{OY}. Уравне- ние такой асимптоты должно иметь вид:
\\
\vskip
\hspace*{6cm} $x=c,$ \\
где с - постоянная, и в этом случае при движении по соответствую- щей бесконечной ветви с должно стремиться к с, а у - к бесконеч- ности (рис. 80). Мы получаем, таким образом, следующее правило. Все асимптомы кривой\\
\hspace*{5cm} $y=f(x)$\\
параллельные оси OY, можно получить, найдя ме значения x=c, при приближении к которым f(x) стремимся к бесконечности. Для исследования того, как расположена кривая относительно асимп- тоты, надо определить знак f(x) при стремлении х к с слева и справа. Перейдем теперь к нахождению асимптот, непараллельных оси OY. В этом случае уравнение асимптоты должно иметь вид\\
\hspace*{5cm}
\displaystyle $\eta =\S a+b $
\end{document}
This is what a tried and the result should be like this

Related

Using mutex to synchronize two kernel threads causes a system panic

I used the mutex to synchronize the two kernel threads. After running, panic occurred in the system and abnormal memory was found in mutex by kdump.
Here is a simplified code example, You can run it directly to reproduce the problem.
I changed the memory allocation method to use kmalloc instead of vmalloc, and then it worked, Who knows why?
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/kthread.h>
#include <linux/slab.h>
struct product {
struct list_head list;
struct mutex lock;
bool finish;
};
struct task_struct *task1;
struct task_struct *task2;
spinlock_t spin;
struct list_head products;
struct product *create_product(void)
{
struct product *p_prod;
p_prod = vmalloc(sizeof(struct product));
// p_prod = kmalloc(sizeof(struct product), GFP_KERNEL);
if(!p_prod)
return NULL;
INIT_LIST_HEAD(&p_prod->list);
mutex_init(&p_prod->lock);
p_prod->finish = false;
return p_prod;
}
void remove_product(struct product **pp_prod)
{
vfree(*pp_prod);
// kfree(*pp_prod);
*pp_prod = NULL;
}
int producer(void *data)
{
while(!kthread_should_stop())
{
struct product *p_prod = create_product();
if(!p_prod)
continue;
spin_lock(&spin);
list_add_tail(&p_prod->list, &products);
spin_unlock(&spin);
while (true)
{
mutex_lock(&p_prod->lock);
if(p_prod->finish)
{
mutex_unlock(&p_prod->lock);
schedule();
break;
}
mutex_unlock(&p_prod->lock);
}
remove_product(&p_prod);
}
do_exit(0);
}
int consumer(void *data)
{
while(!kthread_should_stop())
{
struct product *p_prod;
spin_lock(&spin);
if(list_empty(&products))
{
spin_unlock(&spin);
schedule();
continue;
}
p_prod = list_first_entry(&products, struct product, list);
list_del(&p_prod->list);
spin_unlock(&spin);
mutex_lock(&p_prod->lock);
p_prod->finish = true;
mutex_unlock(&p_prod->lock);
}
do_exit(0);
}
static int __init kdemo_init(void) {
printk(">>> demo driver begin!\n");
spin_lock_init(&spin);
INIT_LIST_HEAD(&products);
task1 = kthread_run(producer, NULL, "hdz-producer");
task2 = kthread_run(consumer, NULL, "hdz-consumer");
return 0;
}
static void __exit kdemo_exit(void) {
kthread_stop(task1);
kthread_stop(task2);
printk(">>> demo driver exit!\n");
}
module_init(kdemo_init);
module_exit(kdemo_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("xxxx#xxx.com");
MODULE_VERSION("1.0");
dmesg log and consumer stack
[ 176.599116] >>> demo driver begin!
[ 177.167659] BUG: unable to handle kernel NULL pointer dereference at 0000000000000fb0
[ 177.167695] IP: [<ffffffff9e0caa47>] wake_q_add+0x17/0x50
[ 177.167719] PGD 0
[ 177.167729] Oops: 0002 [#1] SMP
[ 177.167743] Modules linked in: kdemo(OE) mpt3sas mptctl mptbase nvmet_rdma nvmet nvme_rdma nvme_fabrics nvme nvme_core drbd(OE) dell_rbu kvdo(OE) uds(OE) bonding sha512_ssse3 sha512_generic qat_api(OE) usdm_drv(OE) intel_qat(OE) authenc uio ib_isert iscsi_target_mod ib_srpt target_core_mod ib_srp scsi_transport_srp scsi_tgt ib_ucm rpcrdma sunrpc rdma_ucm ib_umad ib_uverbs ib_iser rdma_cm ib_ipoib iw_cm libiscsi scsi_transport_iscsi ib_cm mlx5_ib ib_core intelcas(OE) inteldisk(OE) iTCO_wdt iTCO_vendor_support dell_smbios sparse_keymap dcdbas skx_edac intel_powerclamp coretemp intel_rapl iosf_mbi kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd sg joydev pcspkr ipmi_si i2c_i801 lpc_ich shpchp ipmi_devintf ipmi_msghandler mei_me acpi_power_meter
[ 177.168071] mei acpi_pad wmi nfit libnvdimm dm_multipath binfmt_misc ip_tables xfs libcrc32c mgag200 drm_kms_helper crc32c_intel syscopyarea sysfillrect sysimgblt mlx5_core fb_sys_fops ttm ixgbe drm igb mlxfw devlink mdio ptp i2c_algo_bit pps_core i2c_core dca sr_mod cdrom sd_mod crc_t10dif crct10dif_generic crct10dif_pclmul crct10dif_common ahci libahci libata mpt2sas raid_class scsi_transport_sas megaraid_sas dm_mirror dm_region_hash dm_log dm_mod
[ 177.168263] CPU: 24 PID: 5412 Comm: hdz-consumer Kdump: loaded Tainted: G OE ------------ 3.10.0-862.el7.x86_64 #1
[ 177.168297] Hardware name: Dell Inc. PowerEdge R740/08D89F, BIOS 2.10.2 02/24/2021
[ 177.168320] task: ffff93db22af3f40 ti: ffff93dc89354000 task.ti: ffff93dc89354000
[ 177.168344] RIP: 0010:[<ffffffff9e0caa47>] [<ffffffff9e0caa47>] wake_q_add+0x17/0x50
[ 177.168372] RSP: 0018:ffff93dc89357e48 EFLAGS: 00010246
[ 177.168389] RAX: 0000000000000000 RBX: ffffbe2ce6533018 RCX: 0000000000000fb0
[ 177.168410] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff93dc89357e58
[ 177.168432] RBP: ffff93dc89357e48 R08: ffffbe2ce6533000 R09: 0000000000000000
[ 177.168453] R10: 0000000000000001 R11: 0000000000000001 R12: ffffbe2ce6533014
[ 177.168475] R13: ffff93dc89357e58 R14: 0000000000000000 R15: 0000000000000000
[ 177.168497] FS: 0000000000000000(0000) GS:ffff93dca9400000(0000) knlGS:0000000000000000
[ 177.168540] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 177.168560] CR2: 0000000000000fb0 CR3: 00000002b7a0e000 CR4: 00000000007607e0
[ 177.168583] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 177.168606] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 177.168629] PKRU: 00000000
[ 177.168640] Call Trace:
[ 177.168656] [<ffffffff9e711b2e>] __mutex_unlock_slowpath+0x5e/0x90
[ 177.168679] [<ffffffff9e710fab>] mutex_unlock+0x1b/0x20
[ 177.168699] [<ffffffffc0637064>] consumer+0x64/0x90 [kdemo]
[ 177.168723] [<ffffffffc0637000>] ? 0xffffffffc0636fff
[ 177.168746] [<ffffffff9e0bae31>] kthread+0xd1/0xe0
[ 177.168765] [<ffffffff9e0bad60>] ? insert_kthread_work+0x40/0x40
[ 177.168788] [<ffffffff9e71f61d>] ret_from_fork_nospec_begin+0x7/0x21
[ 177.168811] [<ffffffff9e0bad60>] ? insert_kthread_work+0x40/0x40
[ 177.168831] Code: 09 00 00 31 c9 31 d2 e8 18 41 ff ff eb e4 66 0f 1f 44 00 00 0f 1f 44 00 00 55 48 8d 8e b0 0f 00 00 31 c0 ba 01 00 00 00 48 89 e5 <f0> 48 0f b1 96 b0 0f 00 00 48 85 c0 74 0b 5d c3 66 0f 1f 84 00
[ 177.168996] RIP [<ffffffff9e0caa47>] wake_q_add+0x17/0x50
[ 177.169017] RSP <ffff93dc89357e48>
[ 177.169959] CR2: 0000000000000fb0
producer stask
crash> bt 5411
PID: 5411 TASK: ffff93db22af4f10 CPU: 1 COMMAND: "hdz-producer"
bt: page excluded: kernel virtual address: ffffffffffffffff type: "cpu_online_map"
#0 [ffff93dca8e48e48] crash_nmi_callback at ffffffff9e0533b7
#1 [ffff93dca8e48e58] nmi_handle at ffffffff9e71790c
#2 [ffff93dca8e48eb0] do_nmi at ffffffff9e717b2d
#3 [ffff93dca8e48ef0] end_repeat_nmi at ffffffff9e716d79
#4 [ffff93dca8e48f28] __vmalloc_node_range at ffffffff9e1d7518
[exception RIP: mutex_unlock+20]
RIP: ffffffff9e710fa4 RSP: ffff93ddafd73e98 RFLAGS: 00000202
RAX: 0000000000000010 RBX: 0000000000000010 RCX: 0000000000000202
RDX: ffff93ddafd73e98 RSI: 0000000000000018 RDI: 0000000000000001
RBP: ffffffff9e710fa4 R8: ffffffff9e710fa4 R9: 0000000000000018
R10: ffff93ddafd73e98 R11: 0000000000000202 R12: ffffffffffffffff
R13: ffffbe2ce6535010 R14: ffffffffc0639240 R15: 0000000000000000
ORIG_RAX: ffffffffc0639240 CS: 0010 SS: 0018
--- <(unknown) exception stack> ---
#5 [ffff93ddafd73e98] mutex_unlock at ffffffff9e710fa4
#6 [ffff93ddafd73ea0] producer at ffffffffc0637145 [kdemo]
#7 [ffff93ddafd73ec8] kthread at ffffffff9e0bae31
#8 [ffff93ddafd73f50] ret_from_fork_nospec_begin at ffffffff9e71f61d

Flutter Advance pdf viewer plugin works fine in emulator but in real device it shows error

I am completely a beginer in flutter .I have developing an app which shows pdf from local storage and store it in local db.when I am running in Emulator it works fine but when runing in real device it shows error I using Advance pdf viewer plugin I also create proguard-rues.pro file also. can any help me solve this issue.
Here is my pdf fetching code
FilePickerResult pdf = await FilePicker.platform
.pickFiles(type: FileType.custom, allowedExtensions: ['pdf']);
_pdf = File(pdf.files.single.path);
doc = await PDFDocument.fromFile(_pdf);
MyPdf Docviewer code
Container(
width: 120,
height: 120,
margin: EdgeInsets.all(10.0),
child: PDFViewer(
document: doc,
),
)
My proguard rules.pro file
-keep class com.shockwave.**
-keepclassmembers class com.shockwave.** { *; }
My android build gradle file
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
My android manifest file
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
<application
android:requestLegacyExternalStorage="true"
Error message while running in real device
D/FilePickerUtils(22253): Allowed file extensions mimes: [application/pdf]
D/FilePickerDelegate(22253): Selected type */*
I/SurfaceView(22253): updateWindow -- onWindowVisibilityChanged, visibility = 8, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 Changes: creating=false format=false size=false visible=true left=false top=false mUpdateWindowNeeded=false mReportDrawNeeded=false redrawNeeded=false forceSizeChanged=false mVisible=true mRequestedVisible=false, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 Cur surface: Surface(name=null)/#0xce7fd99, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 New surface: Surface(name=null)/#0xb61c85e, vis=false, frame=Rect(0, 0 - 480, 854), this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 visibleChanged -- surfaceDestroyed, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): surfaceDestroyed callback +, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
D/GraphicBuffer(22253): register, handle(0x86399440) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/Surface (22253): Surface::disconnect(this=0x9038d700,api=1)
D/GraphicBuffer(22253): unregister, handle(0x86398300) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/GraphicBuffer(22253): unregister, handle(0x86398480) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/GraphicBuffer(22253): unregister, handle(0x86399440) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/Surface (22253): Surface::disconnect(this=0x9038d700,api=1)
I/SurfaceView(22253): surfaceDestroyed callback -, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
V/SurfaceView(22253): Layout: x=0 y=0 w=480 h=854, frame=Rect(0, 0 - 480, 854), this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
D/SurfaceView(22253): 156878148 windowPositionLostRT RT, frameNr = 0
D/Surface (22253): Surface::disconnect(this=0x9038fa00,api=1)
D/GraphicBuffer(22253): unregister, handle(0x9172aec0) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/GraphicBuffer(22253): unregister, handle(0x9172b040) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/GraphicBuffer(22253): unregister, handle(0x9172af80) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/Surface (22253): Surface::disconnect(this=0x9038fa00,api=1)
V/PhoneWindow(22253): DecorView setVisiblity: visibility = 4, Parent = ViewRoot{bfd9ce3 com.example.detailscollector/com.example.detailscollector.MainActivity,ident = 0}, this = DecorView#be0ade5[MainActivity]
I/SurfaceView(22253): updateWindow -- onWindowVisibilityChanged, visibility = 4, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/FilePickerUtils(22253): Caching from URI: content://com.android.providers.downloads.documents/document/3389
V/PhoneWindow(22253): DecorView setVisiblity: visibility = 0, Parent = ViewRoot{bfd9ce3 com.example.detailscollector/com.example.detailscollector.MainActivity,ident = 0}, this = DecorView#be0ade5[MainActivity]
D/ActivityThread(22253): isAppLocked r.intent.getComponent().getPackageName() = com.example.detailscollector
D/ActivityThread(22253): isAppLocked r.intent.getComponent() = ComponentInfo{com.example.detailscollector/com.example.detailscollector.MainActivity}
I/SurfaceView(22253): updateWindow -- onWindowVisibilityChanged, visibility = 0, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 Changes: creating=false format=false size=false visible=true left=false top=false mUpdateWindowNeeded=false mReportDrawNeeded=false redrawNeeded=false forceSizeChanged=false mVisible=false mRequestedVisible=true, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 Cur surface: Surface(name=null)/#0xce7fd99, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 New surface: Surface(name=null)/#0xb61c85e, vis=true, frame=Rect(0, 0 - 480, 854), this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 visibleChanged -- surfaceCreated, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): surfaceCreated callback +, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
D/Surface (22253): Surface::connect(this=0x9038fa00,api=1)
W/libEGL (22253): [ANDROID_RECORDABLE] format: 1
D/mali_winsys(22253): EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
I/SurfaceView(22253): surfaceCreated callback -, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 surfaceChanged -- format=4 w=480 h=854, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): surfaceChanged callback +, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): surfaceChanged callback -, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 surfaceRedrawNeeded, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
I/SurfaceView(22253): 156878148 finishedDrawing, this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
V/SurfaceView(22253): Layout: x=0 y=0 w=480 h=854, frame=Rect(0, 0 - 480, 854), this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
D/OpenGLRenderer(22253): CanvasContext() 0x90237000 initialize window=0x9038f300, title=com.example.detailscollector/com.example.detailscollector.MainActivity
D/Surface (22253): Surface::connect(this=0x9038f300,api=1)
W/libEGL (22253): [ANDROID_RECORDABLE] format: 1
V/InputMethodManager(22253): onWindowFocus: io.flutter.embedding.android.FlutterView{bebe62d VFE...... .F...... 0,0-480,854} softInputMode=16 first=true flags=#81810100
D/mali_winsys(22253): EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
I/SurfaceView(22253): Punch a hole(dispatchDraw), this = io.flutter.embedding.android.FlutterSurfaceView{959c544 V.E...... ........ 0,0-480,854}
D/SurfaceView(22253): 156878148 updateWindowPosition RT, frameNr = 1, postion = [0, 0, 480, 854]
D/GraphicBuffer(22253): register, handle(0x9172af80) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/GraphicBuffer(22253): register, handle(0x9172b4c0) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/GraphicBuffer(22253): register, handle(0x9172b040) (w:480 h:854 s:480 f:0x1 u:0x000b00)
D/FilePickerUtils(22253): File loaded and cached at:/data/user/0/com.example.detailscollector/cache/file_picker/96842
D/FilePickerDelegate(22253): File path:[com.mr.flutter.plugin.filepicker.FileInfo#a9b953c]
I/flutter (22253): pdf file
I/flutter (22253): found
I/art (22253): Enter while loop.
I/art (22253): Background sticky concurrent mark sweep GC freed 15207(1053KB) AllocSpace objects, 5(100KB) LOS objects, 0% free, 23MB/23MB, paused 1.951ms total 108.250ms
I/art (22253): Enter while loop.
I/System.out(22253): length=5; regionStart=0; regionLength=-1
W/System.err(22253): java.lang.StringIndexOutOfBoundsException: length=5; regionStart=0; regionLength=-1
W/System.err(22253): at java.lang.String.substring(String.java:1931)
W/System.err(22253): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.getFileNameFromPath(FlutterPluginPdfViewerPlugin.java:125)
W/System.err(22253): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.createTempPreview(FlutterPluginPdfViewerPlugin.java:130)
W/System.err(22253): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.getPage(FlutterPluginPdfViewerPlugin.java:170)
W/System.err(22253): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.access$100(FlutterPluginPdfViewerPlugin.java:29)
W/System.err(22253): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1.run(FlutterPluginPdfViewerPlugin.java:70)
W/System.err(22253): at android.os.Handler.handleCallback(Handler.java:836)
W/System.err(22253): at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err(22253): at android.os.Looper.loop(Looper.java:203)
W/System.err(22253): at android.os.HandlerThread.run(HandlerThread.java:61)
D/GraphicBuffer(22253): register, handle(0x9172b580) (w:480 h:854 s:480 f:0x1 u:0x000b00)
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following ArgumentError was thrown building NotificationListener<KeepAliveNotification>:
Invalid argument(s) (path): Must not be null
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
When the exception was thrown, this was the stack:
#0 ArgumentError.checkNotNull (dart:core/errors.dart:194:27)
#1 _File._checkNotNull (dart:io/file_impl.dart:641:19)
#2 new _File (dart:io/file_impl.dart:205:17)
#3 new File (dart:io/file.dart:250:18)
#4 _PDFPageState._repaint (package:advance_pdf_viewer/src/page.dart:47:26)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 259 pos 16: 'child == null || indexOf(child) > index': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
A RenderViewport expected a child of type RenderSliver but received a child of type RenderErrorBox.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4345 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
The relevant error-causing widget was:
PDFViewer file:///C:/Users/Dell/Desktop/New%20folder/12-11-2020-detailscollector/lib/create.dart:200:40
════════════════════════════════════════════════════════════════════════════════════════════════════
.pickFiles(type: FileType.custom, allowedExtensions: ['pdf']);
change To:
FilePickerResult pdf = await FilePicker.platform
.pickFiles(type: FileType.custom, allowedExtensions: ['.pdf']);
This should resolve the issue. if not then show some code of create.dart line 190 to 210 by modifying your question.
Here is my uploading function
void selectpdf() async {
pdf = await FilePicker.platform
.pickFiles(type: FileType.custom, allowedExtensions: ['pdf']);
_pdf = File(pdf.files.single.path);
);
doc = await PDFDocument.fromFile(pdf);
imgFile2 = pdf.readAsBytesSync();
imageString2 = base64Encode(imgFile2);
//print(imageString2);
note.photoname2 = imageString2;
note.type2 = 2;
decode2(imageString2);
setState(() {
pdfdoc = true;
doc = doc;
imageFile = pdf;
});
}
try this,
Container(
width: 120,
height: 120,
margin: EdgeInsets.all(10.0),
child: PDFViewer(
document: doc,
zoomSteps: 1,
lazyLoad: false,
),
)

org.apache.poi: POIFSFileSystem is not assignable to NPOIFSFileSystem on new new HSSFWorkbook() on Linux

Getting an exception when just creating a new HSSFWorkbook object using poi 3.17 on Linux but the same code works on Windows. Using Redhat Linux 7.6 and openjdk version "1.8.0_181". The same code works find on Windows.
I've tried everything I can thing of without success.
The code is pretty trivial:
public RenderForXLS(RendererProperties rendererProperties) throws MOException
{
locale = rendererProperties.getLocale();
log.debug("Locale == " + locale);
workbook = new HSSFWorkbook();
normalFont = createFont(workbook, HSSFColor.HSSFColorPredefined.BLACK.getIndex(), false);
boldFont = createFont(workbook, HSSFColor.HSSFColorPredefined.BLACK.getIndex(), true);
headerCellStyle = createHeaderCellStyle(workbook);
dataCellStyle = createDataCellStyle(workbook);
doubleNumericCellStyle = createDoubleNumericCellStyle(workbook);
integerNumericCellStyle = createIntegerNumericCellStyle(workbook);
percentageCellStyle = createPercentageCellStyle(workbook);
}
java.lang.VerifyError: Stack map does not match the one at exception handler 172
Exception Details:
Location:
org/apache/poi/POIDocument.getPropertySet(Ljava/lang/String;Lorg/apache/poi/poifs/crypt/EncryptionInfo;)Lorg/apache/poi/hpsf/PropertySet; #172: astore
Reason:
Type 'org/apache/poi/poifs/filesystem/POIFSFileSystem' (current frame, locals[4]) is not assignable to 'org/apache/poi/poifs/filesystem/NPOIFSFileSystem' (stack map, locals[4])
Current Frame:
bci: #94
flags: { }
locals: { 'org/apache/poi/POIDocument', 'java/lang/String', 'org/apache/poi/poifs/crypt/EncryptionInfo', 'org/apache/poi/poifs/filesystem/DirectoryNode', 'org/apache/poi/poifs/filesystem/POIFSFileSystem', 'java/lang/String', 'java/lang/String', 'org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor' }
stack: { 'java/io/IOException' }
Stackmap Frame:
bci: #172
flags: { }
locals: { 'org/apache/poi/POIDocument', 'java/lang/String', 'org/apache/poi/poifs/crypt/EncryptionInfo', 'org/apache/poi/poifs/filesystem/DirectoryNode', 'org/apache/poi/poifs/filesystem/NPOIFSFileSystem', 'java/lang/String' }
stack: { 'java/io/IOException' }
Bytecode:
0x0000000: 2ab4 0002 4e01 3a04 1225 3a05 2cc6 0057
0x0000010: 2cb6 0026 9900 5012 273a 052a b600 283a
0x0000020: 062d 1906 b600 299a 0024 bb00 2a59 bb00
0x0000030: 1959 b700 1a12 2bb6 001b 1906 b600 1b12
0x0000040: 2cb6 001b b600 1eb7 002d bf2c b600 2ec0
0x0000050: 002f 3a07 1907 2d19 06b6 0030 3a04 1904
0x0000060: b600 054e 2dc6 000b 2d2b b600 299a 000e
0x0000070: 013a 0619 04b8 0031 1906 b012 253a 052d
0x0000080: 2d2b b600 32b6 0033 3a06 1234 3a05 1906
0x0000090: b800 353a 0719 06b6 0036 1904 b800 3119
0x00000a0: 07b0 3a08 1906 b600 3619 08bf 3a06 1906
0x00000b0: bf3a 06bb 0021 59bb 0019 59b7 001a 1238
0x00000c0: b600 1b19 05b6 001b 1239 b600 1b2b b600
0x00000d0: 1bb6 001e 1906 b700 3abf 3a09 1904 b800
0x00000e0: 3119 09bf
Exception Handler Table:
bci [138, 149] => handler: 162
bci [162, 164] => handler: 162
bci [12, 115] => handler: 172
bci [123, 154] => handler: 172
bci [162, 172] => handler: 172
bci [12, 115] => handler: 177
bci [123, 154] => handler: 177
bci [162, 172] => handler: 177
bci [12, 115] => handler: 218
bci [123, 154] => handler: 218
bci [162, 220] => handler: 218
Stackmap Table:
full_frame(#75,{Object[#178],Object[#157],Object[#179],Object[#180],Object[#181],Object[#157],Object[#157]},{})
chop_frame(#100,1)
same_frame(#112)
same_frame(#123)
full_frame(#162,{Object[#178],Object[#157],Object[#179],Object[#180],Object[#181],Object[#157],Object[#182]},{Object[#183]})
full_frame(#172,{Object[#178],Object[#157],Object[#179],Object[#180],Object[#181],Object[#157]},{Object[#159]})
same_locals_1_stack_item_frame(#177,Object[#184])
same_locals_1_stack_item_frame(#218,Object[#183])
at com.sas.analytics.mo.services.report.RenderForXLS.<init>(RenderForXLS.java:82)

BeautifulSoup place content outside the real element while reading or parsing

I have to parse content of last dd and take its text as list of its child-p texts. See the screenshot below:
I used the flllowing code:
with open('strange_dl.html') as f:
soup = BeautifulSoup(f, 'html.parser')
target=soup.dl.find_all('dd')[-1]
p_elements=target.find_all('p')
Unexpectedly it returns the results, which is on the screenshot below:
So you can see that it return not all the actual p and also twised the second p element.
When I started to dig deeper I find that has corrupted html inside itself:
You can reproduce it with beautifulsoup4 from Anaconda and the html snippet below:
<dl data-test="memory-book-bank-details" class="definition-list padding-default">
<dt class="font-bold color-text">Полное наименование</dt>
<dd>АКБ «ЧУВАШКРЕДИТПРОМБАНК» ПАО</dd>
<dt class="font-bold color-text">Город</dt>
<dd data-test="memory-book-bank-city">Чебоксары</dd>
<dt class="font-bold color-text">Номер лицензии</dt>
<dd data-test="memory-book-bank-license">
1280
|
<a href="http://www.cbr.ru/credit/coinfo.asp?id=970000003"
target="_blank" rel="nofollow">Информация на сайте ЦБ</a>
</dd>
<dt class="font-bold color-text">Причина</dt>
<dd>отзыв лицензии</dd>
<dt class="font-bold color-text">Дата</dt>
<dd>07.11.2019</dd>
<dt class="font-bold color-text">Причина отзыва лицензии</dt>
<dd class="margin-bottom-zero"><p>Банк России принял решение в соответствии с п. п. 6 и 6.1 части первой ст. 20 Федерального закона «О банках и банковской деятельности»2, руководствуясь тем, что Чувашкредитпромбанк:
<p>— допускал нарушения законодательства и нормативных актов Банка России в области противодействия легализации (отмыванию) доходов, полученных преступным путем, и финансированию терроризма. Кредитная организация представляла в уполномоченный орган неполную и некорректную информацию, в том числе по операциям, подлежащим обязательному контролю;
</br>— проводил сомнительные операции, связанные с продажей наличной иностранной валюты;
</br>— допускал нарушения порядка расчета капитала и занижал величину необходимых к формированию резервов на возможные потери. По оценке Банка России, отражение в финансовой отчетности достоверной величины капитала и реальных кредитных рисков, принимаемых кредитной организацией, приводит к значительному (более 35%) снижению размера собственных средств банка. В результате возникают основания для осуществления мер по предупреждению несостоятельности (банкротства) и создается реальная угроза интересам кредиторов и вкладчиков;
</br>— нарушал федеральные законы, регулирующие банковскую деятельность, а также нормативные акты Банка России, в связи с чем регулятор в течение последних 12 месяцев неоднократно применял к нему меры, в том числе вводил ограничения на привлечение денежных средств физических лиц.
<p>На балансе Чувашкредитпромбанка образовался значительный объем корпоративных кредитов низкого качества. Банк России направил в адрес кредитной организации предписание с требованиями об адекватной оценке принимаемых рисков и отражении в отчетности своего реального финансового положения.</dd>
</dl>
This is because your <p> tags are not closed with a closing paragraph tag </p>.
BeautifulSoup gets confused for where the paragraphs end and it supposes it to be where the next one starts. But the last one cannot be guessed due to no following paragraph. This is why you are having all these problems.
Easiest solution is to put paragraph closing tags in your html.
<dl data-test="memory-book-bank-details" class="definition-list padding-default">
<dt class="font-bold color-text">Полное наименование</dt>
<dd>АКБ «ЧУВАШКРЕДИТПРОМБАНК» ПАО</dd>
<dt class="font-bold color-text">Город</dt>
<dd data-test="memory-book-bank-city">Чебоксары</dd>
<dt class="font-bold color-text">Номер лицензии</dt>
<dd data-test="memory-book-bank-license">
1280
|
<a href="http://www.cbr.ru/credit/coinfo.asp?id=970000003"
target="_blank" rel="nofollow">Информация на сайте ЦБ</a>
</dd>
<dt class="font-bold color-text">Причина</dt>
<dd>отзыв лицензии</dd>
<dt class="font-bold color-text">Дата</dt>
<dd>07.11.2019</dd>
<dt class="font-bold color-text">Причина отзыва лицензии</dt>
<dd class="margin-bottom-zero"><p>Банк России принял решение в соответствии с п. п. 6 и 6.1 части первой ст. 20 Федерального закона «О банках и банковской деятельности»2, руководствуясь тем, что Чувашкредитпромбанк:</p>
<p>— допускал нарушения законодательства и нормативных актов Банка России в области противодействия легализации (отмыванию) доходов, полученных преступным путем, и финансированию терроризма. Кредитная организация представляла в уполномоченный орган неполную и некорректную информацию, в том числе по операциям, подлежащим обязательному контролю;
</br>— проводил сомнительные операции, связанные с продажей наличной иностранной валюты;
</br>— допускал нарушения порядка расчета капитала и занижал величину необходимых к формированию резервов на возможные потери. По оценке Банка России, отражение в финансовой отчетности достоверной величины капитала и реальных кредитных рисков, принимаемых кредитной организацией, приводит к значительному (более 35%) снижению размера собственных средств банка. В результате возникают основания для осуществления мер по предупреждению несостоятельности (банкротства) и создается реальная угроза интересам кредиторов и вкладчиков;
</br>— нарушал федеральные законы, регулирующие банковскую деятельность, а также нормативные акты Банка России, в связи с чем регулятор в течение последних 12 месяцев неоднократно применял к нему меры, в том числе вводил ограничения на привлечение денежных средств физических лиц.</p>
<p>На балансе Чувашкредитпромбанка образовался значительный объем корпоративных кредитов низкого качества. Банк России направил в адрес кредитной организации предписание с требованиями об адекватной оценке принимаемых рисков и отражении в отчетности своего реального финансового положения.</p></dd>
</dl>

How to Convert Parquet to Spark Delta Lake?

I was trying to convert a set of parquet files into delta format in-place. I tried using the CONVERT command as mentioned in the Databricks documentation. https://docs.databricks.com/spark/latest/spark-sql/language-manual/convert-to-delta.html
CONVERT TO DELTA parquet.'path/to/table'
I am using Spark 2.4.4 and PySpark (Python version 3.5.3). This is the command I am executing
spark.sql("CONVERT TO DELTA parquet. '/usr/spark-2.4.4/data/delta-parquet/'")
where '/usr/spark-2.4.4/data/delta-parquet/' is the path where the parquet files are located.
But, I am getting an exception.
File "/usr/spark-2.4.4/python/pyspark/sql/utils.py", line 63, in deco
return f(*a, **kw)
File "/usr/spark-2.4.4/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o25.sql.
: org.apache.spark.sql.catalyst.parser.ParseException:
mismatched input 'CONVERT' expecting {'(', 'SELECT', 'FROM', 'ADD', 'DESC', 'WITH', 'VALUES', 'CREATE', 'TABLE', 'INSERT', 'DELETE', 'DESCRIBE', 'EXPLAIN', 'SHOW', 'USE', 'DROP', 'ALTER', 'MAP', 'SET', 'RESET', 'START', 'COMMIT', 'ROLLBACK', 'REDUCE', 'REFRESH', 'CLEAR', 'CACHE', 'UNCACHE', 'DFS', 'TRUNCATE', 'ANALYZE', 'LIST', 'REVOKE', 'GRANT', 'LOCK', 'UNLOCK', 'MSCK', 'EXPORT', 'IMPORT', 'LOAD'}(line 1, pos 0)
== SQL ==
CONVERT TO DELTA parquet. '/usr/spark-2.4.4/data/delta-parquet/'
^^^
at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:241)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:117)
at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:48)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:69)
at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:642)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Thread.java:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/spark-2.4.4/python/pyspark/sql/session.py", line 767, in sql
return DataFrame(self._jsparkSession.sql(sqlQuery), self._wrapped)
File "/usr/spark-2.4.4/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in __call__
File "/usr/spark-2.4.4/python/pyspark/sql/utils.py", line 73, in deco
raise ParseException(s.split(': ', 1)[1], stackTrace)
pyspark.sql.utils.ParseException: "\nmismatched input 'CONVERT' expecting {'(', 'SELECT', 'FROM', 'ADD', 'DESC', 'WITH', 'VALUES', 'CREATE', 'TABLE', 'INSERT', 'DELETE', 'DESCRIBE', 'EXPLAIN', 'SHOW', 'USE', 'DROP', 'ALTER', 'MAP', 'SET', 'RESET', 'START', 'COMMIT', 'ROLLBACK', 'REDUCE', 'REFRESH', 'CLEAR', 'CACHE', 'UNCACHE', 'DFS', 'TRUNCATE', 'ANALYZE', 'LIST', 'REVOKE', 'GRANT', 'LOCK', 'UNLOCK', 'MSCK', 'EXPORT', 'IMPORT', 'LOAD'}(line 1, pos 0)\n\n== SQL ==\nCONVERT TO DELTA parquet. '/usr/spark-2.4.4/data/delta-parquet/'\n^^^\n"
Am I using the CONVERT command in the right way? Any help would be appreciated.
For PySpark, using the latest Delta Lake version, you can convert as follows:
from delta.tables import *
deltaTable = DeltaTable.convertToDelta(spark, "parquet.`/usr/spark-2.4.4/data/delta-parquet/`")
This example is taken from the docs
Just a syntax error, you are using the CONVERT command in the right way;
CONVERT TO DELTA parquet.`/usr/spark-2.4.4/data/delta-parquet/`
Use Backtick and remove unnecessary spaces.

Resources