本文整理汇总了Java中com.amazon.carbonado.Storable类的典型用法代码示例。如果您正苦于以下问题:Java Storable类的具体用法?Java Storable怎么用?Java Storable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Storable类属于com.amazon.carbonado包,在下文中一共展示了Storable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLobFromLocator
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Generates code to get a Lob from a locator from RawSupport. RawSupport
* instance, Storable instance, property name and long locator must be on
* the stack. Result is a Lob on the stack, which may be null.
*/
private void getLobFromLocator(CodeAssembler a, StorablePropertyInfo info) {
if (!info.isLob()) {
throw new IllegalArgumentException();
}
TypeDesc type = info.getStorageType();
String name;
if (Blob.class.isAssignableFrom(type.toClass())) {
name = "getBlob";
} else if (Clob.class.isAssignableFrom(type.toClass())) {
name = "getClob";
} else {
throw new IllegalArgumentException();
}
a.invokeInterface(TypeDesc.forClass(RawSupport.class), name,
type, new TypeDesc[] {TypeDesc.forClass(Storable.class),
TypeDesc.STRING, TypeDesc.LONG});
}
示例2: mostOrdering
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Given a list of chained ordering properties, returns the properties
* stripped of the matching chain prefix for the targetToSourceProperty. As
* the target ordering is scanned left-to-right, if any property is found
* which doesn't match the targetToSourceProperty, the building of the new
* list stops. In other words, it returns a consecutive run of matching
* properties.
*/
private static <T extends Storable> OrderingList
mostOrdering(StorableProperty<T> primeTarget, OrderingList<T> targetOrdering)
{
OrderingList handledOrdering = OrderingList.emptyList();
for (OrderedProperty<T> targetProp : targetOrdering) {
ChainedProperty<T> chainedProp = targetProp.getChainedProperty();
if (chainedProp.getPrimeProperty().equals(primeTarget)) {
handledOrdering = handledOrdering
// I hate Java generics. Note the stupid cast. I have finally
// realized the core problem: the wildcard model is broken.
.concat(OrderedProperty
.get((ChainedProperty) chainedProp.tail(),
targetProp.getDirection()));
} else {
break;
}
}
return handledOrdering;
}
示例3: LoggingRepository
import com.amazon.carbonado.Storable; //导入依赖的package包/类
LoggingRepository(AtomicReference<Repository> rootRef,
Repository actual, Log log)
{
mRootRef = rootRef;
mRepo = actual;
mLog = log;
mStoragePool = new StoragePool() {
@Override
protected <S extends Storable> Storage<S> createStorage(Class<S> type)
throws RepositoryException
{
return new LoggingStorage(LoggingRepository.this, mRepo.storageFor(type));
}
};
}
示例4: getGeneratedClass
import com.amazon.carbonado.Storable; //导入依赖的package包/类
static <S extends Storable> Class<? extends S> getGeneratedClass(JDBCStorableInfo<S> info,
boolean isMaster,
boolean autoVersioning,
boolean suppressReload)
throws SupportException
{
Object key = KeyFactory.createKey(new Object[] {
info, isMaster, autoVersioning, suppressReload});
synchronized (cCache) {
Class<? extends S> generatedClass = (Class<? extends S>) cCache.get(key);
if (generatedClass != null) {
return generatedClass;
}
generatedClass = new JDBCStorableGenerator<S>
(info, isMaster, autoVersioning, suppressReload)
.generateAndInjectClass();
cCache.put(key, generatedClass);
return generatedClass;
}
}
示例5: getIndexEntryAccessors
import com.amazon.carbonado.Storable; //导入依赖的package包/类
public <S extends Storable> IndexEntryAccessor<S>[]
getIndexEntryAccessors(Class<S> storableType)
throws RepositoryException
{
if (Unindexed.class.isAssignableFrom(storableType)) {
return new IndexEntryAccessor[0];
}
Storage<S> masterStorage = mRepository.storageFor(storableType);
IndexAnalysis<S> analysis = mIndexAnalysisPool.get(masterStorage);
List<IndexEntryAccessor<S>> accessors =
new ArrayList<IndexEntryAccessor<S>>(analysis.allIndexInfoMap.size());
for (IndexInfo info : analysis.allIndexInfoMap.values()) {
if (info instanceof IndexEntryAccessor) {
accessors.add((IndexEntryAccessor<S>) info);
}
}
return accessors.toArray(new IndexEntryAccessor[accessors.size()]);
}
示例6: getFactory
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Returns a factory for creating new filtered cursor instances.
*
* @param filter filter specification
* @throws IllegalArgumentException if filter is null
* @throws UnsupportedOperationException if filter is not supported
*/
@SuppressWarnings("unchecked")
static <S extends Storable> Factory<S> getFactory(Filter<S> filter) {
if (filter == null) {
throw new IllegalArgumentException();
}
synchronized (cCache) {
Factory<S> factory = (Factory<S>) cCache.get(filter);
if (factory != null) {
return factory;
}
Class<Cursor<S>> clazz = generateClass(filter);
factory = QuickConstructorGenerator.getInstance(clazz, Factory.class);
cCache.put(filter, factory);
return factory;
}
}
示例7: register
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Registers the given cursor against the active transaction, allowing it
* to be closed on transaction exit or transaction manager close. If there
* is no active transaction in scope, the cursor is registered as not part
* of a transaction. Cursors should register when created.
*/
public <S extends Storable> void register(Class<S> type, Cursor<S> cursor) {
mLock.lock();
try {
checkClosed();
if (mCursors == null) {
mCursors = new IdentityHashMap<Class<?>, CursorList<TransactionImpl<Txn>>>();
}
CursorList<TransactionImpl<Txn>> cursorList = mCursors.get(type);
if (cursorList == null) {
cursorList = new CursorList<TransactionImpl<Txn>>();
mCursors.put(type, cursorList);
}
cursorList.register(cursor, mActive);
if (mActive != null) {
mActive.register(cursor);
}
} finally {
mLock.unlock();
}
}
示例8: addPropertyMapMethod
import com.amazon.carbonado.Storable; //导入依赖的package包/类
private void addPropertyMapMethod() {
TypeDesc mapType = TypeDesc.forClass(Map.class);
MethodInfo mi = addMethodIfNotFinal(Modifiers.PUBLIC, PROPERTY_MAP, mapType, null);
if (mi == null) {
return;
}
CodeBuilder b = new CodeBuilder(mi);
TypeDesc propertyMapType = TypeDesc.forClass(StorablePropertyMap.class);
b.loadConstant(TypeDesc.forClass(mStorableType));
b.loadThis();
b.invokeStatic(propertyMapType, "createMap", propertyMapType,
new TypeDesc[] {TypeDesc.forClass(Class.class),
TypeDesc.forClass(Storable.class)});
b.returnValue(mapType);
}
示例9: StorableClassFileBuilder
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Initialize the injector and classfile, defining the basic information
* for a synthetic class
*
* @param className
* name with which to christen this class -- must be globally
* unique
* @param sourceClass
* class to credit with creating the class, usually the class
* making the call
*/
StorableClassFileBuilder(ClassNameProvider nameProvider,
ClassLoader loader,
Class sourceClass,
boolean evolvable) {
String className = nameProvider.getName();
if (nameProvider.isExplicit()) {
mInjector = ClassInjector.createExplicit(className, loader);
} else {
mInjector = ClassInjector.create(className, loader);
}
mClassFile = new ClassFile(mInjector.getClassName());
Modifiers modifiers = mClassFile.getModifiers().toAbstract(true);
mClassFile.setModifiers(modifiers);
mClassFile.addInterface(Storable.class);
if (!evolvable) {
mClassFile.addInterface(Unevolvable.class);
}
mClassFile.markSynthetic();
mClassFile.setSourceFile(sourceClass.getName());
mClassFile.setTarget("1.5");
mClassFile.addDefaultConstructor();
}
示例10: get
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Returns a canonical instance.
*
* @throws IllegalArgumentException if prime is null or if chained
* properties are not formed properly
* @since 1.2
*/
@SuppressWarnings("unchecked")
public static <S extends Storable> ChainedProperty<S> get(StorableProperty<S> prime,
StorableProperty<?>[] chain,
boolean[] outerJoin) {
return (ChainedProperty<S>) cCanonical.put
(new ChainedProperty<S>(prime, chain, outerJoin));
}
示例11: createCodec
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* @param type type of storable to create codec for
* @param pkIndex suggested index for primary key (optional)
* @param isMaster when true, version properties and sequences are managed
* @param layout when non-null, encode a storable layout generation
* value in one or four bytes. Generation 0..127 is encoded in one byte, and
* 128..max is encoded in four bytes, with the most significant bit set.
* @throws SupportException if type is not supported
*/
@SuppressWarnings("unchecked")
public <S extends Storable> GenericStorableCodec<S> createCodec(Class<S> type,
StorableIndex pkIndex,
boolean isMaster,
Layout layout)
throws SupportException
{
return createCodec(type, pkIndex, isMaster, layout, null);
}
示例12:
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Override to return a different EncodingStrategy.
*
* @param type type of Storable to generate code for
* @param pkIndex specifies sequence and ordering of key properties (optional)
*/
protected <S extends Storable> GenericEncodingStrategy<S> createStrategy
(Class<S> type, StorableIndex<S> pkIndex)
throws SupportException
{
return new GenericEncodingStrategy<S>(type, pkIndex);
}
示例13: getCanonical
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Returns a canonical instance, creating a new one if there isn't one
* already in the cache.
*/
@SuppressWarnings("unchecked")
private static <S extends Storable> ExistsFilter<S> getCanonical(ChainedProperty<S> property,
Filter<?> subFilter,
boolean not)
{
return (ExistsFilter<S>) cCanonical.put(new ExistsFilter<S>(property, subFilter, not));
}
示例14: get
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Returns a canonical instance composed of the given ordering.
*
* @throws IllegalArgumentException if ordering property is not in S
*/
public static <S extends Storable> OrderingList<S> get(Class<S> type, String property) {
OrderingList<S> list = emptyList();
if (property != null) {
list = list.concat(type, property);
}
return list;
}
示例15: setDatabasePageSize
import com.amazon.carbonado.Storable; //导入依赖的package包/类
/**
* Sets the desired page size for a given type. If not specified, the page
* size applies to all types.
*/
public void setDatabasePageSize(Integer bytes, Class<? extends Storable> type) {
if (mDatabasePageSizes == null) {
mDatabasePageSizes = new HashMap<Class<?>, Integer>();
}
mDatabasePageSizes.put(type, bytes);
}