当前位置: 首页>>代码示例>>Java>>正文


Java Range类代码示例

本文整理汇总了Java中org.apache.accumulo.core.data.Range的典型用法代码示例。如果您正苦于以下问题:Java Range类的具体用法?Java Range怎么用?Java Range使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Range类属于org.apache.accumulo.core.data包,在下文中一共展示了Range类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: multipleWritesNotSearchableTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void multipleWritesNotSearchableTest() throws Exception {
  List<String> rows = Arrays.asList("row1", "row2", "row3");
  List<String> colFs = Arrays.asList("colF1", "colF2", "colF3");
  List<String> colQs = Arrays.asList("colQ1", "colQ2", "colQ3");
  List<String> colVs = Arrays.asList("secret", ColumnVisibility.quote("top secret"));
  List<String> values = Arrays.asList("value1", "value2", "value3");

  // Initial data.
  EncryptedBatchWriter writer = getEncryptedWriter(CHARLIE, "all.ini");
  writeData(writer, rows, colFs, colQs, colVs, values);
  writer.close();

  EncryptedBatchScanner scanner = getEncryptedScanner(CHARLIE, "all.ini");
  scanner.setRanges(Collections.singletonList(new Range()));
  assertThat("contains the correct data", scanner, hasData(rows, colFs, colQs, colVs, values));

  // Update the data.
  writer = getEncryptedWriter(CHARLIE, "all.ini");
  writeData(writer, rows, colFs, colQs, colVs, Collections.singletonList("value4"));
  writer.close();

  scanner = getEncryptedScanner(CHARLIE, "all.ini");
  scanner.setRanges(Collections.singletonList(new Range()));
  assertThat("contains the correct data", scanner, hasData(rows, colFs, colQs, colVs, Arrays.asList("value1", "value2", "value3", "value4")));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:27,代码来源:FilteringIT.java

示例2: multipleWritesSearchableTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void multipleWritesSearchableTest() throws Exception {
  List<String> rows = Arrays.asList("row1", "row2", "row3");
  List<String> colFs = Arrays.asList("colF1", "colF2", "colF3");
  List<String> colQs = Arrays.asList("colQ1", "colQ2", "colQ3");
  List<String> colVs = Arrays.asList("secret", ColumnVisibility.quote("top secret"));
  List<String> values = Arrays.asList("value1", "value2", "value3");

  // Initial data.
  EncryptedBatchWriter writer = getEncryptedWriter(CHARLIE, "searchable.ini");
  writeData(writer, rows, colFs, colQs, colVs, values);
  writer.close();

  EncryptedBatchScanner scanner = getEncryptedScanner(CHARLIE, "searchable.ini");
  scanner.setRanges(Collections.singletonList(new Range()));
  assertThat("contains the most recent version of the data", scanner, hasData(rows, colFs, colQs, colVs, Collections.singletonList("value3")));

  // Update the data.
  writer = getEncryptedWriter(CHARLIE, "searchable.ini");
  writeData(writer, rows, colFs, colQs, colVs, Collections.singletonList("value4"));
  writer.close();

  scanner = getEncryptedScanner(CHARLIE, "searchable.ini");
  scanner.setRanges(Collections.singletonList(new Range()));
  assertThat("contains the most recent version of the data", scanner, hasData(rows, colFs, colQs, colVs, Collections.singletonList("value4")));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:27,代码来源:FilteringIT.java

示例3: setRangesTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
private void setRangesTest(String configuration) throws Exception {
  List<String> rows = Arrays.asList("row1", "row2");
  List<String> colFs = Arrays.asList("colF1", "colF2");
  List<String> colQs = Arrays.asList("colQ1", "colQ2");
  List<String> colVs = Collections.singletonList("");
  List<String> values = Collections.singletonList("value");

  clearTable();
  EncryptedBatchWriter writer = getEncryptedWriter(CHARLIE, configuration);
  writeData(writer, rows, colFs, colQs, colVs, values);
  writer.close();

  EncryptedBatchScanner scanner = getEncryptedScanner(CHARLIE, configuration);
  scanner.setRanges(Collections.singletonList(new Range(new Key("row1", "colF1", "colQ1"), true, new Key("row1", "colF1", "colQ2")
      .followingKey(PartialKey.ROW_COLFAM_COLQUAL), false)));
  assertThat("contains the filtered data", scanner, hasData(Collections.singletonList("row1"), Collections.singletonList("colF1"), colQs, colVs, values));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:18,代码来源:FilteringIT.java

示例4: fetchColumnFamilyTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
private void fetchColumnFamilyTest(String configuration) throws Exception {
  List<String> rows = Arrays.asList("row1", "row2");
  List<String> colFs = Arrays.asList("colF1", "colF2");
  List<String> colQs = Arrays.asList("colQ1", "colQ2");
  List<String> colVs = Collections.singletonList("");
  List<String> values = Collections.singletonList("value");

  clearTable();
  EncryptedBatchWriter writer = getEncryptedWriter(CHARLIE, configuration);
  writeData(writer, rows, colFs, colQs, colVs, values);
  writer.close();

  EncryptedBatchScanner scanner = getEncryptedScanner(CHARLIE, configuration);
  scanner.setRanges(Collections.singletonList(new Range()));
  scanner.fetchColumnFamily(new Text("colF1"));
  assertThat("contains the filtered data", scanner, hasData(rows, Collections.singletonList("colF1"), colQs, colVs, values));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:18,代码来源:FilteringIT.java

示例5: fetchColumnTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
private void fetchColumnTest(String configuration) throws Exception {
  List<String> rows = Arrays.asList("row1", "row2");
  List<String> colFs = Arrays.asList("colF1", "colF2");
  List<String> colQs = Arrays.asList("colQ1", "colQ2");
  List<String> colVs = Collections.singletonList("");
  List<String> values = Collections.singletonList("value");

  clearTable();
  EncryptedBatchWriter writer = getEncryptedWriter(CHARLIE, configuration);
  writeData(writer, rows, colFs, colQs, colVs, values);
  writer.close();

  EncryptedBatchScanner scanner = getEncryptedScanner(CHARLIE, configuration);
  scanner.setRanges(Collections.singletonList(new Range()));
  scanner.fetchColumn(new IteratorSetting.Column(new Text("colF1"), new Text("colQ1")));
  assertThat("contains the filtered data", scanner, hasData(rows, Collections.singletonList("colF1"), Collections.singletonList("colQ1"), colVs, values));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:18,代码来源:FilteringIT.java

示例6: setRanges

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * Automatically creates a set of server and client side ranges that most efficiently filter for the given ranges.
 *
 * @throws EncryptionException
 *           The reason for the failure can be retrieved by calling {@link EncryptionException#getCause()}.
 */
@Override
public void setRanges(Collection<Range> collection) {
  checkArgument(collection != null && collection.size() > 0, "ranges must be non null and contain at least 1 range");

  List<Range> serverSideRanges = new ArrayList<>();
  clientSideRanges = new ArrayList<>();

  // Transform the ranges as needed to deal with different encryption configurations.
  for (Range range : collection) {
    if (encryptor.transformRange(range, serverSideRanges)) {
      clientSideRanges.add(range);
    }
  }

  scanner.setRanges(serverSideRanges);
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:25,代码来源:EncryptedBatchScanner.java

示例7: appendServerSideRanges

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
/**
 * @param serverSideRanges
 *          List of server side filters.
 * @param originalRange
 *          Range to convert.
 * @param startKeys
 *          Set of start key filters.
 * @param endKeys
 *          Set of end key filters.
 * @param prefix
 *          What portion of the key are we filtering?
 */
private void appendServerSideRanges(Collection<Range> serverSideRanges, Range originalRange, List<MutableEntry> startKeys, List<MutableEntry> endKeys,
    PartialKey prefix) {
  if (prefix == null) {
    serverSideRanges.add(new Range());
    return;
  }

  if (originalRange.isInfiniteStartKey()) {
    for (MutableEntry endKey : endKeys) {
      serverSideRanges.add(new Range(null, true, endKey.toKey().followingKey(prefix), false));
    }
  } else if (originalRange.isInfiniteStopKey()) {
    for (MutableEntry startKey : startKeys) {
      serverSideRanges.add(new Range(startKey.toKey(), true, null, true));
    }
  } else {
    Iterator<MutableEntry> startKeyIterator = startKeys.iterator();
    Iterator<MutableEntry> endKeyIterator = endKeys.iterator();
    while (startKeyIterator.hasNext()) {
      serverSideRanges.add(new Range(startKeyIterator.next().toKey(), true, endKeyIterator.next().toKey().followingKey(prefix), false));
    }
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:36,代码来源:EntryEncryptor.java

示例8: hasNextTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void hasNextTest() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
  entries.add(encryptor.encrypt(entry));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), encryptor, Collections.singletonList(new Range()),
      new TreeSet<Column>());

  assertThat("has next item", iterator.hasNext(), is(true));
  assertThat("has next item", iterator.hasNext(), is(true));
  iterator.next();
  assertThat("does not have a next item", iterator.hasNext(), is(false));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:18,代码来源:EncryptedScannerIteratorTest.java

示例9: nextTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void nextTest() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
  entries.add(encryptor.encrypt(entry));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), encryptor, Collections.singletonList(new Range()),
      new TreeSet<Column>());
  assertThat("next item is correct", iterator.next(), Matchers.equalTo(entry));

  try {
    iterator.next();
    fail("no items should be left");
  } catch (NoSuchElementException e) { /* expected */}
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:19,代码来源:EncryptedScannerIteratorTest.java

示例10: matchRangeTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void matchRangeTest() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.VISIBILITY_CHARSET), 0,
      false, false), new Value(new byte[] {4}));
  Entry<Key,Value> entry2 = new SimpleImmutableEntry<>(new Key(new byte[] {5}, new byte[] {6}, new byte[] {7}, "secret".getBytes(Utils.VISIBILITY_CHARSET),
      0, false, false), new Value(new byte[] {8}));
  entries.add(encryptor.encrypt(entry));
  entries.add(encryptor.encrypt(entry2));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), new EntryEncryptor(getConfig("config.ini"), KEYS),
      Collections.singletonList(new Range()), new TreeSet<>());
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = new EncryptedScannerIterator(entries.iterator(), new EntryEncryptor(getConfig("config.ini"), KEYS), new ArrayList<Range>(),
      new TreeSet<Column>());
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = getIteratorForRange(entries, (byte) 1);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(1));

  iterator = getIteratorForRange(entries, (byte) 3);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(0));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:27,代码来源:EncryptedScannerIteratorTest.java

示例11: matchColumnFilters

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void matchColumnFilters() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3}, "secret".getBytes(Utils.VISIBILITY_CHARSET), 0,
      false, false), new Value(new byte[] {4}));
  Entry<Key,Value> entry2 = new SimpleImmutableEntry<>(new Key(new byte[] {5}, new byte[] {2}, new byte[] {7}, "secret".getBytes(Utils.VISIBILITY_CHARSET),
      0, false, false), new Value(new byte[] {8}));
  entries.add(encryptor.encrypt(entry));
  entries.add(encryptor.encrypt(entry2));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), new EntryEncryptor(getConfig("config.ini"), KEYS),
      Collections.singletonList(new Range()), new TreeSet<>());
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = getIteratorForColumn(entries, new byte[] {2}, null);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(2));

  iterator = getIteratorForColumn(entries, new byte[] {3}, null);
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(0));

  iterator = getIteratorForColumn(entries, new byte[] {2}, new byte[] {7});
  assertThat("correct number of items", Lists.newArrayList(iterator), hasSize(1));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:26,代码来源:EncryptedScannerIteratorTest.java

示例12: removeException

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void removeException() throws Exception {
  EntryEncryptor encryptor = new EntryEncryptor(getConfig("config.ini"), KEYS);

  List<Entry<Key,Value>> entries = new ArrayList<>();
  Entry<Key,Value> entry = new SimpleImmutableEntry<Key,Value>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
  entries.add(encryptor.encrypt(entry));

  EncryptedScannerIterator iterator = new EncryptedScannerIterator(entries.iterator(), encryptor, Collections.singletonList(new Range()), new TreeSet<>());

  try {
    iterator.remove();
    fail("remove not supported");
  } catch (UnsupportedOperationException e) { /* expected */}
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:17,代码来源:EncryptedScannerIteratorTest.java

示例13: setRangesSearchableTest

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
@Test
public void setRangesSearchableTest() throws Exception {
  when(mockConnector.createBatchScanner(TEST_TABLE, authorizations, 1)).thenReturn(mockScanner);

  EntryEncryptor encryptor = new EntryEncryptor(getConfig("searchable-row.ini"), KEYS);
  List<Map.Entry<Key,Value>> entries = new ArrayList<>();
  Map.Entry<Key,Value> entry = new SimpleImmutableEntry<>(new Key(new byte[] {1}, new byte[] {2}, new byte[] {3},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {4}));
  Map.Entry<Key,Value> entry2 = new SimpleImmutableEntry<>(new Key(new byte[] {5}, new byte[] {6}, new byte[] {7},
      "secret".getBytes(Utils.VISIBILITY_CHARSET), 0, false, false), new Value(new byte[] {8}));
  entries.add(encryptor.encrypt(entry));
  entries.add(encryptor.encrypt(entry2));
  when(mockScanner.iterator()).thenReturn(entries.iterator()).thenReturn(entries.iterator()).thenReturn(entries.iterator());

  BatchScanner scanner = new EncryptedBatchScanner(mockConnector, TEST_TABLE, authorizations, 1, getConfig("searchable-row.ini"), KEYS);
  scanner.setRanges(Collections.singletonList(new Range(new Text(new byte[] {1}))));
  assertThat("has correct number of elements", scanner, iterableWithSize(2));

  verify(mockScanner).setRanges(captor.capture());
  assertThat("correct number of ranges", captor.getValue(), hasSize(2));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:22,代码来源:EncryptedBatchScannerTest.java

示例14: main

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class)
                .bannerMode(Mode.OFF).web(false).run(args)) {
            Configuration conf = ctx.getBean(Configuration.class);

            final BaseConfiguration apacheConf = new BaseConfiguration();
            Configuration.Accumulo accumuloConf = conf.getAccumulo();
            apacheConf.setProperty("instance.name", accumuloConf.getInstanceName());
            apacheConf.setProperty("instance.zookeeper.host", accumuloConf.getZookeepers());
            final ClientConfiguration aconf = new ClientConfiguration(Collections.singletonList(apacheConf));
            final Instance instance = new ZooKeeperInstance(aconf);
            Connector con = instance.getConnector(accumuloConf.getUsername(),
                    new PasswordToken(accumuloConf.getPassword()));
            Scanner s = con.createScanner(conf.getMetaTable(),
                    con.securityOperations().getUserAuthorizations(con.whoami()));
            try {
                s.setRange(new Range(Meta.METRIC_PREFIX, true, Meta.TAG_PREFIX, false));
                for (Entry<Key, Value> e : s) {
                    System.out.println(e.getKey().getRow().toString().substring(Meta.METRIC_PREFIX.length()));
                }
            } finally {
                s.close();
            }
        }
    }
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:27,代码来源:GetMetricTableSplitPoints.java

示例15: getRangeList

import org.apache.accumulo.core.data.Range; //导入依赖的package包/类
/**
 * @return ranges for rowkeys [0-255][startDay-endDay][setOfGeohashes]
 */
private List<Range> getRangeList() {
    List<Range> rangeList = new ArrayList<>();

    Coverage coverage = GeoHash.coverBoundingBoxMaxHashes(north, west, south, east, 100);
    log.debug("coverage:  [size:" + coverage.getHashes().size() + ", ratio:" + coverage.getRatio() + "]");

    Set<String> hashes = coverage.getHashes();
    for (String hash : hashes) {
        for (short day = startDay; day <= endDay; day++) {
            for (int spreadingByte = 0; spreadingByte <= 255; spreadingByte++) {
                ByteBuffer startKey = ByteBuffer.allocate(3 + hash.length());
                if (hash.length() > 8) {
                    hash = hash.substring(0, 8);
                }
                startKey.put((byte) spreadingByte).putShort(day).put(hash.getBytes());
                rangeList.add(Range.prefix(new Text(startKey.array())));
            }
        }
    }

    return rangeList;
}
 
开发者ID:IIDP,项目名称:OSTMap,代码行数:26,代码来源:GeoTemporalTweetQuery.java


注:本文中的org.apache.accumulo.core.data.Range类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。