MCPcopy
hub / github.com/OpenTSDB/opentsdb / advance

Method advance

test/storage/MockBase.java:1801–1852  ·  view source on GitHub ↗

Insanely inefficient and ugly way of advancing the cursors

()

Source from the content-addressed store, hash-verified

1799
1800 /** Insanely inefficient and ugly way of advancing the cursors */
1801 private void advance() {
1802 // first time to get the ceiling
1803 if (last_row == null) {
1804 for (final Entry<byte[],
1805 Iterator<Entry<byte[], ByteMap<TreeMap<Long, byte[]>>>>> iterator :
1806 cursors.entrySet()) {
1807 final Entry<byte[], ByteMap<TreeMap<Long, byte[]>>> row =
1808 iterator.getValue().hasNext() ? iterator.getValue().next() : null;
1809 cf_rows.put(iterator.getKey(), row);
1810 if (last_row == null) {
1811 last_row = row.getKey();
1812 } else {
1813 if (Bytes.memcmp(last_row, row.getKey()) < 0) {
1814 last_row = row.getKey();
1815 }
1816 }
1817 }
1818 return;
1819 }
1820
1821 for (final Entry<byte[], Entry<byte[], ByteMap<TreeMap<Long, byte[]>>>> cf :
1822 cf_rows.entrySet()) {
1823 final Entry<byte[], ByteMap<TreeMap<Long, byte[]>>> row = cf.getValue();
1824 if (row == null) {
1825 continue;
1826 }
1827
1828 if (Bytes.memcmp(last_row, row.getKey()) == 0) {
1829 if (!cursors.get(cf.getKey()).hasNext()) {
1830 cf_rows.put(cf.getKey(), null); // EX?
1831 } else {
1832 cf_rows.put(cf.getKey(), cursors.get(cf.getKey()).next());
1833 }
1834 }
1835 }
1836
1837 last_row = null;
1838 for (final Entry<byte[], ByteMap<TreeMap<Long, byte[]>>> row :
1839 cf_rows.values()) {
1840 if (row == null) {
1841 continue;
1842 }
1843
1844 if (last_row == null) {
1845 last_row = row.getKey();
1846 } else {
1847 if (Bytes.memcmp(last_row, row.getKey()) < 0) {
1848 last_row = row.getKey();
1849 }
1850 }
1851 }
1852 }
1853
1854 /** @return The scanner for this mock */
1855 public Scanner getScanner() {

Callers 1

answerMethod · 0.95

Calls 7

putMethod · 0.80
hasNextMethod · 0.65
nextMethod · 0.65
valuesMethod · 0.65
getValueMethod · 0.45
getKeyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected