-
Notifications
You must be signed in to change notification settings - Fork 0
/
lucene_shard.sh
executable file
·151 lines (102 loc) · 2.33 KB
/
lucene_shard.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
sync_update=true
PREFIX=bmr
ATOM=atom
SHARDS=4
ARGV=`getopt --long -o "p:a:n:" "$@"`
eval set -- "$ARGV"
while true ; do
case "$1" in
-p)
PREFIX=$2
shift
;;
-a)
ATOM=$2
shift
;;
-n)
SHARDS=$2
shift
;;
*)
break
;;
esac
shift
done
if [ $PREFIX != "bmr" ] && [ $PREFIX != "bms" ] ; then
echo "Usage: $0 -p PREFIX"
echo PREFIX should be either \"bmr\" or \"bms\".
exit 1
fi
if [ $ATOM != "noatom" ] && [ $ATOM != "atom" ] ; then
echo "Usage: $0 -a ATOM"
echo ATOM should be either \"noatom\" or \"atom\".
exit 1
fi
if [ $SHARDS -lt 2 ] ; then
echo "Usage: $0 -p PREFIX -n SHARDS"
echo Invalid value for number of shards.
exit 1
fi
if [ $ATOM = "atom" ] ; then
XML_DOC_DIR=$PREFIX"_xml_doc"
FILE_EXT_DIGEST=.
else
XML_DOC_DIR=$PREFIX"_xml_noatom_doc"
FILE_EXT_DIGEST=-noatom
fi
XML_SCHEMA=schema/mmcif_nmr-star.xsd
IDX_DIR=lucene_shard_$PREFIX
if [ -d $IDX_DIR ] ; then
echo
echo "Do you want to update lucene index? (y [n]) "
read ans
case $ans in
y*|Y*) ;;
*) echo stopped.
exit 1;;
esac
if [ $sync_update != "true" ] ; then
rm -rf $IDX_DIR
fi
fi
WORK_DIR=lucene_work
ERR_DIR=$WORK_DIR/err
rm -rf $WORK_DIR
mkdir -p $WORK_DIR
mkdir -p $ERR_DIR
if [ $sync_update = "true" ] ; then
MD5_DIR=chk_sum_lucene
fi
err_file=$ERR_DIR/all_err
if [ $sync_update != "true" ] ; then
java -cp extlibs/xsd2pgschema.jar xml2luceneidx --xsd $XML_SCHEMA --xml $XML_DOC_DIR --idx-dir $IDX_DIR --attr-all --no-rel --no-valid --xml-file-ext gz --xml-file-ext-digest $FILE_EXT_DIGEST --shard-size $SHARDS 2> $err_file
else
java -cp extlibs/xsd2pgschema.jar xml2luceneidx --xsd $XML_SCHEMA --xml $XML_DOC_DIR --idx-dir $IDX_DIR --attr-all --no-rel --no-valid --xml-file-ext gz --xml-file-ext-digest $FILE_EXT_DIGEST --shard-size $SHARDS --sync $MD5_DIR 2> $err_file
fi
if [ $? = 0 ] && [ ! -s $err_file ] ; then
rm -f $err_file
else
echo $0 aborted.
exit 1
fi
red='\e[0;31m'
normal='\e[0m'
errs=`ls $ERR_DIR/*_err 2> /dev/null | wc -l`
if [ $errs = 0 ] ; then
if [ $? = 0 ] ; then
if [ $ATOM = "atom" ] ; then
echo "Lucene index (prefix:"$PREFIX") is update."
else
echo "Lucene index (prefix:"$PREFIX"-"$ATOM") is update."
fi
rm -rf $WORK_DIR
fi
else
echo
echo -e "${red}$errs errors were detected. Please check the log files for more details.${normal}"
exit 1
fi
date