Skip to content

Instantly share code, notes, and snippets.

@hn5092
hn5092 / udf_jieba.py
Created April 10, 2017 09:14
hive python udf
#coding=utf-8
import logging
import traceback
import jieba
import jieba.analyse
import redis
import sys
import os
import json
import codecs
package com.pajk.bigdata.flink.utils;
import org.apache.hadoop.hbase.util.Bytes;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/*
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
CronTrigger cronTrigger = new CronTrigger("* 0/2 * * * * ");
SimpleTriggerContext triggerContext = new SimpleTriggerContext();
triggerContext.update(new Date(System.currentTimeMillis()),new Date(System.currentTimeMillis()+10),
new Date(System.currentTimeMillis()+100));
Date date = cronTrigger.nextExecutionTime(triggerContext);
System.out.println(date);
@hn5092
hn5092 / spring scheduler
Created December 25, 2016 09:08
如何动态的使用spring的调度,支持cron 表达式
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
@hn5092
hn5092 / bootstrap.js
Created August 16, 2016 02:39
angular watch
$rootScope.$watch('tmpChartCount', function (newValue, oldValue, isRefren) {
console.log("change");
if ($rootScope.tmpChartMap.count() > 0)
$rootScope.tmpChartMap.forEach(function (k, v) {
$http.get(v.url).then(function (response) {
v.data = response.data;
v.draw();
$rootScope.chartMap.set(k, v);
$rootScope.tmpChartMap.remove(k);
});
@hn5092
hn5092 / DefaultMemStore.java
Created July 20, 2016 01:52
singletion obj
Collections.<KeyValueScanner> singletonList(new MemStoreScanner(readPt));
@hn5092
hn5092 / HRegion.java
Created July 19, 2016 08:53
user executorcompletionservice
CompletionService<HStore> completionService =
new ExecutorCompletionService<HStore>(storeOpenerThreadPool);
// initialize each store in parallel
for (final HColumnDescriptor family : htableDescriptor.getFamilies()) {
status.setStatus("Instantiating store for column family " + family);
completionService.submit(new Callable<HStore>() {
@Override
public HStore call() throws IOException {
return instantiateHStore(family);
@hn5092
hn5092 / ExecutorCompletionService.java
Created July 19, 2016 08:50
how to use futuretask
public class ExecutorCompletionService<V> implements CompletionService<V> {
private final Executor executor;
private final AbstractExecutorService aes;
private final BlockingQueue<Future<V>> completionQueue;
/**
* FutureTask extension to enqueue upon completion
*/
private class QueueingFuture extends FutureTask<Void> {
QueueingFuture(RunnableFuture<V> task) {
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0