congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ObjectStoreDataset
Code IndexAdd Tabnine to your IDE (free)

How to use
ObjectStoreDataset
in
co.cask.cdap.data2.dataset2.lib.table

Best Java code snippets using co.cask.cdap.data2.dataset2.lib.table.ObjectStoreDataset (Showing top 20 results out of 315)

origin: cdapio/cdap

public RecordScanner<KeyValue<byte[], T>> createSplitRecordScanner(Split split) {
 return Scannables.splitRecordScanner(createSplitReader(split), new ObjectRecordMaker());
}
origin: cdapio/cdap

@ReadOnly
@Override
public T read(byte[] key) {
 byte[] read = kvTable.read(key);
 return decode(read);
}
origin: cdapio/cdap

@WriteOnly
@Override
public void write(byte[] key, T object) {
 kvTable.write(key, encode(object));
}
origin: caskdata/cdap

Schema schema = new ReflectionSchemaGenerator().generate(type);
final ObjectStoreDataset<Custom> objectStore = new ObjectStoreDataset<>("kv", kvTable, typeRep, schema, loader);
TransactionExecutor txnl = dsFrameworkUtil.newInMemoryTransactionExecutor(objectStore);
objectStore.getRecordType();
txnl.execute(new TransactionExecutor.Subroutine() {
 @Override
origin: cdapio/cdap

 @Override
 public ObjectStoreDataset<?> getDataset(DatasetContext datasetContext, DatasetSpecification spec,
                     Map<String, String> arguments, ClassLoader classLoader) throws IOException {
  DatasetSpecification kvTableSpec = spec.getSpecification("objects");
  KeyValueTable table = tableDef.getDataset(datasetContext, kvTableSpec, arguments, classLoader);

  TypeRepresentation typeRep = GSON.fromJson(spec.getProperty("type"), TypeRepresentation.class);
  Schema schema = GSON.fromJson(spec.getProperty("schema"), Schema.class);
  return new ObjectStoreDataset(spec.getName(), table, typeRep, schema, classLoader);
 }
}
origin: caskdata/cdap

 @Override
 public void apply() throws Exception {
  Custom custom = store.read(a);
  Preconditions.checkNotNull(custom);
 }
});
origin: cdapio/cdap

private T decode(byte[] bytes) {
 if (bytes == null) {
  return null;
 }
 // decode T using schema
 ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
 BinaryDecoder decoder = new BinaryDecoder(bis);
 try {
  return getReflectionDatumReader().read(decoder, this.schema);
 } catch (IOException e) {
  // SHOULD NEVER happen
  throw new DataSetException("Failed to decode read object: " + e.getMessage(), e);
 }
}
origin: caskdata/cdap

 @Override
 public void apply() throws Exception {
  // get specific number of splits for a subrange
  TreeSet<Long> keysToVerify = Sets.newTreeSet(keysWritten.subSet(0x10000000L, 0x40000000L));
  List<Split> splits = t.getSplits(5, Bytes.toBytes(0x10000000L), Bytes.toBytes(0x40000000L));
  Assert.assertTrue(splits.size() <= 5);
  // read each split and verify the keys
  verifySplits(t, splits, keysToVerify);
 }
});
origin: caskdata/cdap

 @Override
 public void apply() throws Exception {
  CloseableIterator<KeyValue<byte[], String>> objectsIterator = t.scan(Bytes.toBytes(0), Bytes.toBytes(10));
  int rowCount = 0;
  while (objectsIterator.hasNext() && (rowCount < 5)) {
   rowCount++;
  }
  objectsIterator.close();
  try {
   objectsIterator.next();
   Assert.fail("Reading after closing Scanner returned result.");
  } catch (NoSuchElementException e) {
  }
 }
});
origin: caskdata/cdap

 @WriteOnly
 public void delete(int key) {
  super.delete(Bytes.toBytes(key));
 }
}
origin: co.cask.cdap/cdap-data-fabric

 @Override
 public ObjectStoreDataset<?> getDataset(DatasetContext datasetContext, DatasetSpecification spec,
                     Map<String, String> arguments, ClassLoader classLoader) throws IOException {
  DatasetSpecification kvTableSpec = spec.getSpecification("objects");
  KeyValueTable table = tableDef.getDataset(datasetContext, kvTableSpec, arguments, classLoader);

  TypeRepresentation typeRep = GSON.fromJson(spec.getProperty("type"), TypeRepresentation.class);
  Schema schema = GSON.fromJson(spec.getProperty("schema"), Schema.class);
  return new ObjectStoreDataset(spec.getName(), table, typeRep, schema, classLoader);
 }
}
origin: caskdata/cdap

 @Override
 public void apply() throws Exception {
  Custom result = customStore.read(a);
  Assert.assertEquals(custom, result);
 }
});
origin: co.cask.cdap/cdap-data-fabric

private T decode(byte[] bytes) {
 if (bytes == null) {
  return null;
 }
 // decode T using schema
 ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
 BinaryDecoder decoder = new BinaryDecoder(bis);
 try {
  return getReflectionDatumReader().read(decoder, this.schema);
 } catch (IOException e) {
  // SHOULD NEVER happen
  throw new DataSetException("Failed to decode read object: " + e.getMessage(), e);
 }
}
origin: co.cask.cdap/cdap-data-fabric

public RecordScanner<KeyValue<byte[], T>> createSplitRecordScanner(Split split) {
 return Scannables.splitRecordScanner(createSplitReader(split), new ObjectRecordMaker());
}
origin: caskdata/cdap

 @Override
 public void apply() throws Exception {
  ImmutablePair<Integer, String> result = pairStore.read(a);
  Assert.assertEquals(pair, result);
 }
});
origin: co.cask.cdap/cdap-data-fabric

@WriteOnly
@Override
public void write(byte[] key, T object) {
 kvTable.write(key, encode(object));
}
origin: co.cask.cdap/cdap-data-fabric

@ReadOnly
@Override
public T read(byte[] key) {
 byte[] read = kvTable.read(key);
 return decode(read);
}
origin: caskdata/cdap

private void verifySplits(ObjectStoreDataset<String> t, List<Split> splits, SortedSet<Long> keysToVerify)
 throws InterruptedException {
 // read each split and verify the keys, remove all read keys from the set
 for (Split split : splits) {
  SplitReader<byte[], String> reader = t.createSplitReader(split);
  reader.initialize(split);
  while (reader.nextKeyValue()) {
   byte[] key = reader.getCurrentKey();
   String value = reader.getCurrentValue();
   // verify each row has the two columns written
   Assert.assertEquals(Long.toString(Bytes.toLong(key)), value);
   Assert.assertTrue(keysToVerify.remove(Bytes.toLong(key)));
  }
 }
 // verify all keys have been read
 if (!keysToVerify.isEmpty()) {
  System.out.println("Remaining [" + keysToVerify.size() + "]: " + keysToVerify);
 }
 Assert.assertTrue(keysToVerify.isEmpty());
}
origin: caskdata/cdap

 @Override
 public void apply() throws Exception {
  Custom result = customStore.read(a);
  Assert.assertEquals(custom2, result);
 }
});
origin: cdapio/cdap

@WriteOnly
@Override
public void write(String key, T object) {
 kvTable.write(Bytes.toBytes(key), encode(object));
}
co.cask.cdap.data2.dataset2.lib.tableObjectStoreDataset

Javadoc

Default implementation for ObjectStore

Most used methods

  • <init>
  • createSplitReader
  • decode
  • delete
  • encode
  • getRecordType
  • getReflectionDatumReader
  • getSplits
  • read
  • scan
  • write
  • write

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Menu (java.awt)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now