MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / answer

Method answer

test/storage/MockBase.java:1045–1103  ·  view source on GitHub ↗
(final InvocationOnMock invocation)

Source from the content-addressed store, hash-verified

1043 */
1044 private class MockPut implements Answer<Deferred<Boolean>> {
1045 @Override
1046 public Deferred<Boolean> answer(final InvocationOnMock invocation)
1047 throws Throwable {
1048 final Object[] args = invocation.getArguments();
1049 final PutRequest put = (PutRequest)args[0];
1050
1051 if (exceptions != null) {
1052 final Pair<RuntimeException, Boolean> ex = exceptions.get(put.key());
1053 if (ex != null) {
1054 if (ex.getValue()) {
1055 return Deferred.fromError(ex.getKey());
1056 } else {
1057 throw ex.getKey();
1058 }
1059 }
1060 }
1061
1062 final ByteMap<ByteMap<ByteMap<TreeMap<Long, byte[]>>>> map =
1063 storage.get(put.table());
1064 if (map == null) {
1065 return Deferred.fromError(new RuntimeException(
1066 "No such table " + Bytes.pretty(put.table())));
1067 }
1068
1069 final ByteMap<ByteMap<TreeMap<Long, byte[]>>> cf = map.get(put.family());
1070 if (cf == null) {
1071 return Deferred.fromError(new RuntimeException(
1072 "No such CF " + Bytes.pretty(put.table())));
1073 }
1074
1075 ByteMap<TreeMap<Long, byte[]>> row = cf.get(put.key());
1076 if (row == null) {
1077 row = new ByteMap<TreeMap<Long, byte[]>>();
1078 cf.put(put.key(), row);
1079 }
1080
1081 for (int i = 0; i < put.qualifiers().length; i++) {
1082 TreeMap<Long, byte[]> column = row.get(put.qualifiers()[i]);
1083 if (column == null) {
1084 column = new TreeMap<Long, byte[]>(Collections.reverseOrder());
1085 row.put(put.qualifiers()[i], column);
1086 } else {
1087 long storedTs = column.firstKey();
1088 if(put.timestamp() >= storedTs) {
1089 column.clear();
1090 } else {
1091 continue;
1092 }
1093 }
1094
1095 column.put(put.timestamp() != Long.MAX_VALUE ? put.timestamp() :
1096 current_timestamp++, put.values()[i]);
1097 assert column.size() == 1 : "Since max versions allowed is 1, there can "
1098 + "never be two entries at similar timestamp. To resolve change the "
1099 + "code to only keep the entry with higher timestamp";
1100 }
1101
1102 return Deferred.fromResult(true);

Callers

nothing calls this directly

Calls 9

putMethod · 0.80
clearMethod · 0.80
keyMethod · 0.65
timestampMethod · 0.65
valuesMethod · 0.65
sizeMethod · 0.65
getMethod · 0.45
getValueMethod · 0.45
getKeyMethod · 0.45

Tested by

no test coverage detected