public static <E> Entry ofBytes(E element, StaticArrayEntry.GetColVal<E,byte[]> getter) { return of(element, getter, ByteArrayHandler.INSTANCE); }
public static Entry readEntry(ReadBuffer in, Serializer serializer) { long valuePosition = VariableLong.readPositive(in); Preconditions.checkArgument(valuePosition>0 && valuePosition<=Integer.MAX_VALUE); StaticBuffer buffer = readBuffer(in); StaticArrayEntry entry = new StaticArrayEntry(buffer, (int) valuePosition); int metaSize = in.getByte(); for (int i=0;i<metaSize;i++) { EntryMetaData meta = EntryMetaData.values()[in.getByte()]; entry.setMetaData(meta,serializer.readObjectNotNull(in,meta.getDataType())); } return entry; }
private Entry getEntry(KeyValueEntry entry) { return StaticArrayEntry.ofStaticBuffer(entry,kvEntryGetter); }
private static <E,D> Entry of(E element, StaticArrayEntry.GetColVal<E,D> getter, StaticArrayEntry.DataHandler<D> dataHandler) { StaticArrayEntry entry = of(getter.getColumn(element),getter.getValue(element),dataHandler); //Add meta data if exists if (getter.getMetaSchema(element).length>0) { for (EntryMetaData meta : getter.getMetaSchema(element)) { entry.setMetaData(meta,getter.getMetaData(element,meta)); } } return entry; }
public static Entry of(StaticBuffer buffer) { return new StaticArrayEntry(buffer,buffer.length()); }
int ttl = getTTL(edge); if (ttl > 0) { entry.setMetaData(EntryMetaData.TTL, ttl);
@Override public Entry next() { ensureOpen(); return StaticArrayEntry.ofBytes(kv.next(), entryGetter); }
for (int i = 0; i < ttls.length; i++) { StaticBuffer col = KeyColumnValueStoreUtil.longToByteBuffer(i); StaticArrayEntry entry = (StaticArrayEntry) StaticArrayEntry.of(col, col); entry.setMetaData(EntryMetaData.TTL, ttls[i]); additions.add(entry);
private static <E,D> StaticArrayEntry of(D column, D value, StaticArrayEntry.DataHandler<D> dataHandler) { int valuePos = dataHandler.getSize(column); byte[] data = new byte[valuePos+dataHandler.getSize(value)]; dataHandler.copy(column,data,0); dataHandler.copy(value,data,valuePos); return new StaticArrayEntry(data,valuePos); }
public static <E> Entry ofStaticBuffer(E element, StaticArrayEntry.GetColVal<E,StaticBuffer> getter) { return of(element, getter, StaticBufferHandler.INSTANCE); }
private Entry writeMessage(KCVSMessage msg) { StaticBuffer content = msg.getContent(); DataOutput out = manager.serializer.getDataOutput(8 + 8 + manager.senderId.length() + 2 + content.length()); Instant rawTimestamp = msg.getTimestamp(); Preconditions.checkArgument(rawTimestamp.isAfter(Instant.EPOCH)); out.putLong(times.getTime(rawTimestamp)); out.writeObjectNotNull(manager.senderId); out.putLong(numMsgCounter.incrementAndGet()); final int valuePos = out.getPosition(); out.putBytes(content); return new StaticArrayEntry(out.getStaticBuffer(),valuePos); }
@Override protected Entry computeNext() { if (this.iterator.hasNext()) { return StaticArrayEntry.ofStaticBuffer(this.iterator.next(), this.getter); } return endOfData(); }
public static <E> Entry of(StaticBuffer column, StaticBuffer value) { return of(column, value, StaticBufferHandler.INSTANCE); }
public static Entry getEntry(int col, int val) { return new StaticArrayEntry(new WriteByteBuffer(4 * 2).putInt(col).putInt(val).getStaticBuffer(), 4); }
public static <E> Entry ofByteBuffer(E element, StaticArrayEntry.GetColVal<E,ByteBuffer> getter) { return of(element, getter, ByteBufferHandler.INSTANCE); }
private Entry getIndexEntry(CompositeIndexType index, RecordEntry[] record, JanusGraphElement element) { final DataOutput out = serializer.getDataOutput(1+8+8*record.length+4*8); out.putByte(FIRST_INDEX_COLUMN_BYTE); if (index.getCardinality()!=Cardinality.SINGLE) { VariableLong.writePositive(out,element.longId()); if (index.getCardinality()!=Cardinality.SET) { for (final RecordEntry re : record) { VariableLong.writePositive(out,re.relationId); } } } final int valuePosition=out.getPosition(); if (element instanceof JanusGraphVertex) { VariableLong.writePositive(out,element.longId()); } else { assert element instanceof JanusGraphRelation; final RelationIdentifier rid = (RelationIdentifier)element.id(); final long[] longs = rid.getLongRepresentation(); Preconditions.checkArgument(longs.length == 3 || longs.length == 4); for (final long aLong : longs) VariableLong.writePositive(out, aLong); } return new StaticArrayEntry(out.getStaticBuffer(),valuePosition); }
int getIndex(StaticBuffer column) { return Arrays.binarySearch(array, 0, size, StaticArrayEntry.of(column)); }
return new StaticArrayEntry(type.getSortOrder() == Order.DESC ? out.getStaticBufferFlipBytes(keyStartPos, keyEndPos) : out.getStaticBuffer(), valuePosition);
@Test(expected = PermanentLockingException.class) public void expectedValueMismatchCausesMutateFailure() throws BackendException { store[0].acquireLock(k, c1, v1, tx[0][0]); store[0].mutate(k, Collections.singletonList(StaticArrayEntry.of(c1, v1)), NO_DELETIONS, tx[0][0]); }
@Test public void testMutateManyWithoutLockUsesInconsistentTx() throws BackendException { final ImmutableList<Entry> adds = ImmutableList.of(StaticArrayEntry.of(DATA_COL, DATA_VAL)); final ImmutableList<StaticBuffer> deletions = ImmutableList.of(); Map<String, Map<StaticBuffer, KCVMutation>> mutations = ImmutableMap.of(STORE_NAME, ImmutableMap.of(DATA_KEY, new KCVMutation(adds, deletions))); // Run mutateMany backingManager.mutateMany(mutations, inconsistentTx); // consistency level is unconstrained w/o locks ctrl.replay(); // Run mutateMany expectManager.mutateMany(mutations, expectTx); } }