@Override public byte[] encode(Date data) { return longEncoder.encode(data.getTime()); }
@Override protected Date decodeUnchecked(byte[] data, int offset, int len) { return new Date(longEncoder.decodeUnchecked(data, offset, len)); }
/** For use as an ApplyOp. * Create an IteratorSetting that performs a ScalarOp on every Value it sees, parsing Values as Longs. */ public static IteratorSetting applyOpLexLong(int priority, boolean constantOnRight, ScalarOp op, long scalar, boolean keepZero) { IteratorSetting itset = new IteratorSetting(priority, ApplyIterator.class); itset.addOption(ApplyIterator.APPLYOP, MathTwoScalar.class.getName()); for (Map.Entry<String, String> entry : optionMap(op, ScalarType.LEX_LONG, null, keepZero).entrySet()) itset.addOption(ApplyIterator.APPLYOP + GraphuloUtil.OPT_SUFFIX + entry.getKey(), entry.getValue()); itset = KeyTwoScalar.addOptionsToIteratorSetting(itset, constantOnRight, new Value(new LongLexicoder().encode(scalar))); return itset; }
filterTimestamp = DATE_LEXICODER.decode(value); } else if (columnQualifier.equals(MERGE_PARENT_METADATA_PARENT_TIME_OFFSET)) { parentTimeOffset = LONG_LEXICODER.decode(value);
Lexicoder<Long> lex = null; if (scalarType == ScalarType.LEX_LONG) lex = new LongLexicoder();
sparql = stringLexicoder.decode(value); } else if(columnQualifier.equals(PCJ_METADATA_CARDINALITY)) { cardinality = longLexicoder.decode(value); } else if(columnQualifier.equals(PCJ_METADATA_VARIABLE_ORDERS)) { for(final String varOrderStr : listLexicoder.decode(value)) {
@Override public byte[] encode(Date data) { return longEncoder.encode(data.getTime()); }
filterTimestamp = DATE_LEXICODER.decode(value); } else if (columnQualifier.equals(MERGE_PARENT_METADATA_PARENT_TIME_OFFSET)) { parentTimeOffset = LONG_LEXICODER.decode(value);
@Override protected Date decodeUnchecked(byte[] data, int offset, int len) { return new Date(longEncoder.decodeUnchecked(data, offset, len)); }
/** * Creates a {@link ConditionalMutation} that only updates the cardinality * of the PCJ table if the old value has not changed by the time this mutation * is committed to Accumulo. * * @param current - The current cardinality value. * @param delta - How much the cardinality will change. * @return The mutation that will perform the conditional update. */ private static ConditionalMutation makeUpdateCardinalityMutation(final long current, final long delta) { // Try to update the cardinality by the delta. final ConditionalMutation mutation = new ConditionalMutation(PCJ_METADATA_ROW_ID); final Condition lastCardinalityStillCurrent = new Condition( PCJ_METADATA_FAMILY, PCJ_METADATA_CARDINALITY); // Require the old cardinality to be the value we just read. final byte[] currentCardinalityBytes = longLexicoder.encode( current ); lastCardinalityStillCurrent.setValue( currentCardinalityBytes ); mutation.addCondition(lastCardinalityStillCurrent); // If that is the case, then update to the new value. final Value newCardinality = new Value( longLexicoder.encode(current + delta) ); mutation.put(PCJ_METADATA_FAMILY, PCJ_METADATA_CARDINALITY, newCardinality); return mutation; }
final Value cardinality = new Value( longLexicoder.encode(new Long(metadata.getCardinality())) ); mutation.put(PCJ_METADATA_FAMILY, PCJ_METADATA_CARDINALITY, cardinality); mutations.add(mutation);
final long cardinality = getPcjMetadata(accumuloConn, pcjTableName).getCardinality(); final Mutation mutation = new Mutation(PCJ_METADATA_ROW_ID); final Value newCardinality = new Value(longLexicoder.encode(cardinality + delta)); mutation.put(PCJ_METADATA_FAMILY, PCJ_METADATA_CARDINALITY, newCardinality); batchWriter.addMutation(mutation);