use of java.util.SortedMap in project cdap by caskdata.
the class HBaseMetricsTable method put.
@Override
public void put(SortedMap<byte[], ? extends SortedMap<byte[], Long>> updates) {
List<Put> puts = Lists.newArrayList();
for (Map.Entry<byte[], ? extends SortedMap<byte[], Long>> row : updates.entrySet()) {
PutBuilder put = tableUtil.buildPut(row.getKey());
for (Map.Entry<byte[], Long> column : row.getValue().entrySet()) {
put.add(columnFamily, column.getKey(), Bytes.toBytes(column.getValue()));
}
puts.add(put.build());
}
try {
hTable.put(puts);
hTable.flushCommits();
} catch (IOException e) {
throw new DataSetException("Put failed on table " + tableId, e);
}
}
use of java.util.SortedMap in project cdap by caskdata.
the class HBaseMetricsTable method putBytes.
@Override
public void putBytes(SortedMap<byte[], ? extends SortedMap<byte[], byte[]>> updates) {
List<Put> puts = Lists.newArrayList();
for (Map.Entry<byte[], ? extends SortedMap<byte[], byte[]>> row : updates.entrySet()) {
PutBuilder put = tableUtil.buildPut(row.getKey());
for (Map.Entry<byte[], byte[]> column : row.getValue().entrySet()) {
put.add(columnFamily, column.getKey(), column.getValue());
}
puts.add(put.build());
}
try {
hTable.put(puts);
hTable.flushCommits();
} catch (IOException e) {
throw new DataSetException("Put failed on table " + tableId, e);
}
}
use of java.util.SortedMap in project indy by Commonjava.
the class IndyZabbixReporter method report.
@SuppressWarnings("rawtypes")
@Override
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
final long clock = System.currentTimeMillis() / 1000;
List<DataObject> dataObjectList = new LinkedList<DataObject>();
for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
DataObject dataObject = toDataObject(entry.getKey(), "", String.valueOf(entry.getValue().getValue()), clock);
dataObjectList.add(dataObject);
}
for (Map.Entry<String, Counter> entry : counters.entrySet()) {
DataObject dataObject = toDataObject(entry.getKey(), "", String.valueOf(entry.getValue().getCount()), clock);
dataObjectList.add(dataObject);
}
for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
Histogram histogram = entry.getValue();
Snapshot snapshot = histogram.getSnapshot();
addSnapshotDataObject(entry.getKey(), snapshot, clock, dataObjectList);
}
for (Map.Entry<String, Meter> entry : meters.entrySet()) {
Meter meter = entry.getValue();
addMeterDataObject(entry.getKey(), meter, clock, dataObjectList);
}
for (Map.Entry<String, Timer> entry : timers.entrySet()) {
Timer timer = entry.getValue();
addMeterDataObject(entry.getKey(), timer, clock, dataObjectList);
addSnapshotDataObjectWithConvertDuration(entry.getKey(), timer.getSnapshot(), clock, dataObjectList);
}
try {
SenderResult senderResult = indyZabbixSender.send(dataObjectList, clock);
if (!senderResult.success()) {
logger.warn("report metrics to zabbix not success!" + senderResult);
} else if (logger.isDebugEnabled()) {
logger.info("report metrics to zabbix success. " + senderResult);
}
} catch (IOException e) {
logger.error("report metrics to zabbix error! " + e);
e.printStackTrace();
} catch (IndyMetricsException e) {
logger.error("Indy metrics config error " + e);
e.printStackTrace();
} catch (IndyHttpException e) {
logger.error("Indy http client error " + e);
e.printStackTrace();
}
}
use of java.util.SortedMap in project symja_android_library by axkr.
the class Primality method multiplicativeOrder.
/**
* See <a href="https://en.wikipedia.org/wiki/Multiplicative_order">Wikipedia: Multiplicative order</a> and
* <a href="https://rosettacode.org/wiki/Multiplicative_order">Rosettacode. org: Multiplicative order</a>.
*
* @return <code>null</code> if GCD(k,N) != 1 or is negative
*/
public static BigInteger multiplicativeOrder(BigInteger k, BigInteger n) {
if (n.compareTo(BigInteger.ZERO) < 0) {
return null;
}
if (!k.gcd(n).equals(BigInteger.ONE)) {
return null;
}
SortedMap<BigInteger, Integer> map = new TreeMap<BigInteger, Integer>();
Primality.factorInteger(n, map);
BigInteger res = BigInteger.ONE;
for (Map.Entry<BigInteger, Integer> entry : map.entrySet()) {
res = lcm(res, multiplicativeOrder(k, entry.getKey(), entry.getValue()));
}
return res;
}
use of java.util.SortedMap in project symja_android_library by axkr.
the class Primality method charmichaelLambda.
public static BigInteger charmichaelLambda(BigInteger value) {
if (value.equals(BigInteger.ZERO)) {
return BigInteger.ZERO;
}
if (value.compareTo(BigInteger.ZERO) < 0) {
value = value.negate();
}
if (value.equals(BigInteger.ONE)) {
return BigInteger.ONE;
}
SortedMap<BigInteger, Integer> map = new TreeMap<BigInteger, Integer>();
factorInteger(value, map);
BigInteger l = BigInteger.ONE;
for (Map.Entry<BigInteger, Integer> entry : map.entrySet()) {
BigInteger base = entry.getKey();
int exponent = entry.getValue();
if (exponent >= 3 && base.equals(TWO)) {
l = lcm(l, base.pow(exponent - 2));
} else {
l = lcm(l, (base.pow(exponent - 1)).multiply(base.subtract(BigInteger.ONE)));
}
}
return l;
}
Aggregations