热更新二元接续词典<br>
集群环境（或其他IOAdapter）需要自行删除缓存文件
@return 是否成功
339759
public static boolean reload()
    {
        String biGramDictionaryPath = HanLP.Config.BiGramDictionaryPath;
        IOUtil.deleteFile(biGramDictionaryPath + ".table" + Predefine.BIN_EXT);

        return load(biGramDictionaryPath);
    }
1359074
@Override
    public Tuple getNext()
            throws IOException {
        Tuple tuple = null;
        try {
            if (isBuildingExample) {
                isBuildingExample = false; // Terminate on the next iteration
                return tupleFactory.newTuple(createPigExample());
            }

            boolean notDone = reader.nextKeyValue();
            if (!notDone) {
                return null;
            }

            ParsedRecord value = reader.getCurrentValue();

            if (value != null) {
                List<Object> values = new ArrayList<>();
                if (onlyWantListOfFields) {
                    values.add(value.getString(ApacheHttpdLogfileRecordReader.FIELDS));
                } else {
                    for (String fieldName : requestedFields) {
                        if (fieldName.endsWith(".*")) {
                            values.add(value.getStringSet(fieldName));
                            continue;
                        } else {
                            EnumSet<Casts> casts = reader.getParser().getCasts(fieldName);

                            if (casts != null) {
                                if (casts.contains(Casts.LONG)) {
                                    values.add(value.getLong(fieldName));
                                    continue;
                                }

                                if (casts.contains(Casts.DOUBLE)) {
                                    values.add(value.getDouble(fieldName));
                                    continue;
                                }
                            }
                        }
                        values.add(value.getString(fieldName));
                    }
                }
                tuple = tupleFactory.newTuple(values);
            }
        } catch (InvalidDissectorException | MissingDissectorsException e) {
            throw new IOException("Fatal error in the parser", e);
        }
        return tuple;
    }
758425
private ReadFuture newReadFuture() {
        Queue<ReadFuture> readyReadFutures = getReadyReadFutures();
        Queue<ReadFuture> waitingReadFutures = getWaitingReadFutures();
        ReadFuture future;
        synchronized (readyReadFutures) {
            future = waitingReadFutures.poll();
            if (future == null) {
                future = new DefaultReadFuture(this);
                readyReadFutures.offer(future);
            }
        }
        return future;
    }
1156280
public Blob reload() {
    // [START reload]
    Blob latestBlob = blob.reload(BlobSourceOption.generationNotMatch());
    if (latestBlob == null) {
      // the blob was not found
    }
    // [END reload]
    return latestBlob;
  }
1124088
public static FilterAdapter buildAdapter() {
    FilterAdapter adapter = new FilterAdapter();
    adapter.addFilterAdapter(
        ColumnPrefixFilter.class, new ColumnPrefixFilterAdapter());
    adapter.addFilterAdapter(
        ColumnRangeFilter.class, new ColumnRangeFilterAdapter());
    adapter.addFilterAdapter(
        KeyOnlyFilter.class, new KeyOnlyFilterAdapter());
    adapter.addFilterAdapter(
        MultipleColumnPrefixFilter.class, new MultipleColumnPrefixFilterAdapter());
    adapter.addFilterAdapter(
        TimestampsFilter.class, new TimestampsFilterAdapter());
    adapter.addFilterAdapter(
      TimestampRangeFilter.class, new TimestampRangeFilterAdapter());
    ValueFilterAdapter valueFilterAdapter = new ValueFilterAdapter();
    adapter.addFilterAdapter(
        ValueFilter.class, valueFilterAdapter);
    SingleColumnValueFilterAdapter scvfa =
        new SingleColumnValueFilterAdapter(valueFilterAdapter);
    adapter.addFilterAdapter(
        SingleColumnValueFilter.class, scvfa);
    adapter.addFilterAdapter(
        SingleColumnValueExcludeFilter.class,
        new SingleColumnValueExcludeFilterAdapter(scvfa));
    adapter.addFilterAdapter(
        ColumnPaginationFilter.class, new ColumnPaginationFilterAdapter());
    adapter.addFilterAdapter(
        FirstKeyOnlyFilter.class, new FirstKeyOnlyFilterAdapter());
    adapter.addFilterAdapter(
        ColumnCountGetFilter.class, new ColumnCountGetFilterAdapter());
    adapter.addFilterAdapter(
        RandomRowFilter.class, new RandomRowFilterAdapter());
    adapter.addFilterAdapter(
        PrefixFilter.class, new PrefixFilterAdapter());
    adapter.addFilterAdapter(
        QualifierFilter.class, new QualifierFilterAdapter());
    adapter.addFilterAdapter(
        PageFilter.class, new PageFilterAdapter());
    adapter.addFilterAdapter(
      WhileMatchFilter.class, new WhileMatchFilterAdapter(adapter));
    adapter.addFilterAdapter(
        org.apache.hadoop.hbase.filter.RowFilter.class, new RowFilterAdapter());
    adapter.addFilterAdapter(FuzzyRowFilter.class, new FuzzyRowFilterAdapter());
    adapter.addFilterAdapter(FamilyFilter.class, new FamilyFilterAdapter());
    adapter.addFilterAdapter(BigtableFilter.class, new BigtableFilterAdapter());

    // MultiRowRangeFilter only exists in hbase >= 1.1
    try {
      adapter.addFilterAdapter(
          org.apache.hadoop.hbase.filter.MultiRowRangeFilter.class,
          new MultiRowRangeFilterAdapter()
      );
    } catch (NoClassDefFoundError ignored) {
    }

    // Passing the FilterAdapter in to the FilterListAdapter is a bit
    // unfortunate, but makes adapting the FilterList's subfilters simpler.
    FilterListAdapter filterListAdapter = new FilterListAdapter(adapter);
    // FilterList implements UnsupportedStatusCollector so it should
    // be used when possible (third parameter to addFilterAdapter()).
    adapter.addFilterAdapter(
        FilterList.class, filterListAdapter, filterListAdapter);

    return adapter;
  }
417429
@Override
    public Map<Integer, Long> createUpdatedMap() {
        if (storageFile == null) {
            //In-Memory Stats Storage
            db = DBMaker.memoryDB().make();
        } else {
            db = DBMaker.fileDB(storageFile).closeOnJvmShutdown().transactionEnable() //Default to Write Ahead Log - lower performance, but has crash protection
                            .make();
        }

        updated = db.hashMap("updated").keySerializer(Serializer.INTEGER).valueSerializer(Serializer.LONG)
                        .createOrOpen();
        return updated;
    }
1046403
@Override
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        for (Class<?> t = type.getRawType(); (t != Object.class) && (t.getSuperclass() != null); t = t.getSuperclass()) {
            for (Method m : t.getDeclaredMethods()) {
                if (m.isAnnotationPresent(PostConstruct.class)) {
                    m.setAccessible(true);
                    TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
                    return new PostConstructAdapter<T>(delegate, m);
                }
            }
        }
        return null;
    }
551676
public JSONObject getRawDataAsJson() throws IOException
    {
        String input = getRawDataAsString();
        if ( input == null ) {
            return null;
        }
        
        return new JSONObject(input);
    }
128137
public BufferedInputStream asBufferedInputStream() {
        InputStream is = asInputStream();
        if (is == null) return null;
        if (is instanceof BufferedInputStream) return (BufferedInputStream) is;
        return new BufferedInputStream(is);
    }
275034
public Iterable<MultiPart> parts() throws IOException {
        if (!isMultipart()) return emptyIterable;
        final String boundarystr = "--" + this.boundary;
        final Pattern fielnameReg = this.fielnamePattern;
        final String endboundary = boundarystr + "--";
        final byte[] boundarray = ("\n" + boundarystr).getBytes();
        final byte[] buffer = new byte[boundarray.length];
        final InputStream input = this.in;
        final DefaultAnyValue params = this.parameters;
        final AtomicBoolean finaled = new AtomicBoolean(false);
        return () -> new Iterator<MultiPart>() {

            private String boundaryline;

            private MultiPart lastentry;

            @Override
            public boolean hasNext() {
                try {
                    if (lastentry != null) {
                        lastentry.skip();
                        if (finaled.get()) return false;
                    }
                    if (boundaryline == null) boundaryline = readBoundary();
                    //if (debug) System.out.print("boundaryline=" + boundaryline + "  ");
                    if (endboundary.equals(boundaryline) || !boundarystr.equals(boundaryline)) { //结尾或异常
                        lastentry = null;
                        return false;
                    }
                    final String disposition = readLine();
                    //if (debug) System.out.println("disposition=" + disposition);
                    if (disposition.contains("; filename=\"")) { //是上传文件
                        String contentType = "";
                        //读掉HTTP Header和空白行 通常情况下Content-Type后面就是内容，但是有些特殊情况下后面会跟其他如Content-Length: xxx等HTTP header，所以需要循环读取
                        String rl;
                        while (!(rl = readLine()).isEmpty()) {
                            if (rl.startsWith("Content-Type:")) contentType = rl.substring(rl.indexOf(':') + 1).trim();
                        }
                        //if (debug) System.out.println("file.contentType=" + contentType);

                        String name = parseValue(disposition, "name");
                        String filename = parseValue(disposition, "filename");
                        if (filename == null || filename.isEmpty()) { //没有上传
                            readLine(); //读掉空白行
                            this.boundaryline = null;
                            this.lastentry = null;
                            return this.hasNext();
                        } else {
                            int p1 = filename.lastIndexOf('/');
                            if (p1 < 0) p1 = filename.lastIndexOf('\\');
                            if (p1 >= 0) filename = filename.substring(p1 + 1);
                        }
                        final AtomicLong counter = new AtomicLong(0);
                        InputStream source = new InputStream() {

                            private int bufposition = buffer.length;

                            private boolean end;

                            @Override
                            public int read() throws IOException {
                                if (end) return -1;
                                final byte[] buf = buffer;
                                int ch = (this.bufposition < buf.length) ? (buf[this.bufposition++] & 0xff) : input.read();
                                if ((ch == '\r' && readBuffer())) return -1;
                                counter.incrementAndGet();
                                return ch;
                            }

                            private boolean readBuffer() throws IOException {
                                final byte[] buf = buffer;
                                final int pos = this.bufposition;
                                int s = 0;
                                for (int i = pos; i < buf.length; i++) {
                                    buf[s++] = buf[i];
                                }
                                int readed = 0;
                                while ((readed += input.read(buf, s + readed, pos - readed)) != pos);
                                this.bufposition = 0;
                                if (Arrays.equals(boundarray, buf)) {
                                    this.end = true;
                                    int c1 = input.read();
                                    int c2 = input.read();
                                    finaled.set(c1 == '-' && c2 == '-');
                                    return true;
                                }
                                return false;
                            }

                            @Override
                            public long skip(long count) throws IOException {
                                if (end) return -1;
                                if (count <= 0) return 0;
                                long s = 0;
                                while (read() != -1) {
                                    s++;
                                    if (--count <= 0) break;
                                }
                                return s;
                            }
                        };
                        this.lastentry = new MultiPart(filename, name, contentType, counter, source);
                        if (fielnameReg != null && !fielnameReg.matcher(filename).matches()) {
                            return this.hasNext();
                        }
                        return true;
                    } else { //不是文件
                        readLine(); //读掉空白
                        params.addValue(parseValue(disposition, "name"), readLine());
                        this.boundaryline = null;
                        this.lastentry = null;
                        return this.hasNext();
                    }
                } catch (IOException ex) {
                    logger.log(Level.FINER, "list multiparts abort", ex);
                    return false;
                }
            }

            @Override
            public MultiPart next() {
                return lastentry;
            }

        };
    }
673523
public CsvRow nextRow() throws IORuntimeException {
		long startingLineNo;
		List<String> currentFields;
		int fieldCount;
		while (false == finished) {
			startingLineNo = ++lineNo;
			currentFields = readLine();
			if(null == currentFields) {
				break;
			}
			fieldCount = currentFields.size();
			// 末尾
			if (fieldCount == 0) {
				break;
			}

			// 跳过空行
			if (config.skipEmptyRows && fieldCount == 1 && currentFields.get(0).isEmpty()) {
				continue;
			}

			// 检查每行的字段数是否一致
			if (config.errorOnDifferentFieldCount) {
				if (firstLineFieldCount == -1) {
					firstLineFieldCount = fieldCount;
				} else if (fieldCount != firstLineFieldCount) {
					throw new IORuntimeException(String.format("Line %d has %d fields, but first line has %d fields", lineNo, fieldCount, firstLineFieldCount));
				}
			}

			// 记录最大字段数
			if (fieldCount > maxFieldCount) {
				maxFieldCount = fieldCount;
			}

			//初始化标题
			if (config.containsHeader && null == header) {
				initHeader(currentFields);
				// 作为标题行后，此行跳过，下一行做为第一行
				continue;
			}

			return new CsvRow(startingLineNo, null == header ? null : header.headerMap, currentFields);
		}

		return null;
	}
1224109
public int generate() {
		int validPort = alternativePort.get();
		// 获取可用端口
		while (false == NetUtil.isUsableLocalPort(validPort)) {
			validPort = alternativePort.incrementAndGet();
		}
		return validPort;
	}
1131747
private void makeNewFile() throws IOException {
		String filename=prefix+(files.size()+1)+suffix;
		File file=new File(parent, filename);
		out=new FileOutputStream(file);
		bytesOut=0;
		files.add(file);
	}
755359
private Map<String, List<String>> map() throws IOException {
        if (this.saved.isEmpty()) {
            this.saved.add(this.freshMap());
        }
        return this.saved.get(0);
    }
129615
public static File getNewSubroot() throws IOException {
        ensureUserRootExists();
        File tempFile = File.createTempFile("foo", "", m_root);
        if (!tempFile.delete()) {
            throw new IOException();
        }
        tempFile = new File(tempFile.getPath() + m_magic);
        if (!tempFile.mkdir()) {
            throw new IOException();
        }
        File tempDir = new File(tempFile, "tmp");
        if (!tempDir.mkdir()) {
            throw new IOException();
        }
        File tempUserDir = new File(tempDir, System.getProperty("user.name"));
        if (!tempUserDir.mkdir()) {
            throw new IOException();
        }
        return tempFile;
    }
119353
public byte[] getBytes() throws IOException {
        InputStream input = getInputStream();
        ByteArrayOutputStream output = new ByteArrayOutputStream();

        final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
        int len;

        try {
            while ((len = input.read(buffer)) != -1) {
                output.write(buffer, 0, len);
            }
        } finally {
            try {
                output.close();
            } catch (IOException e) {
                // ignore
            }
            try {
                input.close();
            } catch (IOException e) {
                // ignore
            }
        }

        return output.toByteArray();
    }
1044942
@Override
    public InputStream getInputStream() throws IOException {
        InputStream inputStream = fileItem.getInputStream();
        return (inputStream != null ? inputStream : new ByteArrayInputStream(new byte[0]));
    }