public SinglePartitionInsertionIds( final byte[] partitionKey, final SinglePartitionInsertionIds insertionId2) { this(new SinglePartitionInsertionIds(partitionKey, (List<byte[]>) null), insertionId2); }
public InsertionIds(final byte[] partitionKey) { this(new SinglePartitionInsertionIds(partitionKey)); }
public InsertionIds(final List<byte[]> sortKeys) { this(new SinglePartitionInsertionIds(null, sortKeys)); }
public InsertionIds(final byte[] partitionKey, final List<byte[]> sortKeys) { this(new SinglePartitionInsertionIds(partitionKey, sortKeys)); }
@Override public MultiDimensionalNumericData getRangeForId( final byte[] partitionKey, final byte[] sortKey) { final List<byte[]> insertionIds = new SinglePartitionInsertionIds(partitionKey, sortKey).getCompositeInsertionIds(); if (insertionIds.isEmpty()) { LOGGER.warn("Unexpected empty insertion ID in getRangeForId()"); return null; } final byte[] rowId = insertionIds.get(0); return BinnedSFCUtils.getRangeForId(rowId, baseDefinitions, sfc); }
@Override public void fromBinary(final byte[] bytes) { final ByteBuffer buf = ByteBuffer.wrap(bytes); final int size = VarintUtils.readUnsignedInt(buf); if (size > 0) { partitionKeys = new ArrayList<>(size); for (int i = 0; i < size; i++) { final int length = VarintUtils.readUnsignedInt(buf); final byte[] pBytes = new byte[length]; buf.get(pBytes); final SinglePartitionInsertionIds pId = new SinglePartitionInsertionIds(); pId.fromBinary(pBytes); partitionKeys.add(pId); } } else { partitionKeys = new ArrayList<>(); } } }
private synchronized SinglePartitionInsertionIds getRowIds( final BinnedNumericDataset index, final BigInteger maxEstimatedDuplicateIds) { // most times this should be a single row ID, but if the lowest // precision tier does not have a single SFC value for this data, it // will be multiple row IDs // what tier does this entry belong in? for (int sfcIndex = orderedSfcs.length - 1; sfcIndex >= 0; sfcIndex--) { final SpaceFillingCurve sfc = orderedSfcs[sfcIndex]; // loop through space filling curves and stop when both the min and // max of the ranges fit the same row ID final byte tierId = orderedSfcIndexToTierId.get(sfcIndex); final SinglePartitionInsertionIds rowIdsAtTier = getRowIdsAtTier(index, tierId, sfc, maxEstimatedDuplicateIds, sfcIndex); if (rowIdsAtTier != null) { return rowIdsAtTier; } } // this should never happen because of the check for tier 0 return new SinglePartitionInsertionIds(null, new ArrayList<byte[]>()); }
public static InsertionIds keysToInsertionIds(final GeoWaveKey... geoWaveKeys) { final Map<ByteArray, List<byte[]>> sortKeysPerPartition = new HashMap<>(); for (final GeoWaveKey key : geoWaveKeys) { final ByteArray partitionKey = new ByteArray(key.getPartitionKey()); List<byte[]> sortKeys = sortKeysPerPartition.get(partitionKey); if (sortKeys == null) { sortKeys = new ArrayList<>(); sortKeysPerPartition.put(partitionKey, sortKeys); } sortKeys.add(key.getSortKey()); } final Set<SinglePartitionInsertionIds> insertionIds = new HashSet<>(); for (final Entry<ByteArray, List<byte[]>> e : sortKeysPerPartition.entrySet()) { insertionIds.add(new SinglePartitionInsertionIds(e.getKey().getBytes(), e.getValue())); } return new InsertionIds(insertionIds); }
@Override public MultiDimensionalNumericData getRangeForId( final byte[] partitionKey, final byte[] sortKey) { final List<byte[]> insertionIds = new SinglePartitionInsertionIds(partitionKey, sortKey).getCompositeInsertionIds(); if (insertionIds.isEmpty()) { LOGGER.warn("Unexpected empty insertion ID in getRangeForId()"); return null; } final byte[] rowId = insertionIds.get(0); if (rowId.length > 0) { final Integer orderedSfcIndex = orderedSfcIndexToTierId.inverse().get(rowId[0]); return BinnedSFCUtils.getRangeForId(rowId, baseDefinitions, orderedSfcs[orderedSfcIndex]); } else { LOGGER.warn("Row must at least contain a byte for tier"); } return null; }
@Override public SinglePartitionInsertionIds apply( final SinglePartitionInsertionIds input) { if (input.getPartitionKey() != null) { return new SinglePartitionInsertionIds( ByteArrayUtils.combineArrays(partitionKey, input.getPartitionKey()), input.getSortKeys()); } else { return new SinglePartitionInsertionIds(partitionKey, input.getSortKeys()); } } }));
return new InsertionIds( Arrays.stream(partitionKeys).map( input -> new SinglePartitionInsertionIds(input)).collect(Collectors.toList())); final SinglePartitionInsertionIds input) { if (input.getPartitionKey() != null) { return new SinglePartitionInsertionIds( ByteArrayUtils.combineArrays(partitionKey, input.getPartitionKey()), input.getSortKeys()); } else { return new SinglePartitionInsertionIds(partitionKey, input.getSortKeys());
private InsertionIds trimPartitionForSubstrategy(final InsertionIds insertionIds) { final List<SinglePartitionInsertionIds> retVal = new ArrayList<>(); for (final SinglePartitionInsertionIds partitionIds : insertionIds.getPartitionKeys()) { final byte[] trimmedPartitionId = CompoundIndexStrategy.trimPartitionForSubstrategy( partition1Length, index == 0, partitionIds.getPartitionKey()); if (trimmedPartitionId == null) { return insertionIds; } else { retVal.add( new SinglePartitionInsertionIds(trimmedPartitionId, partitionIds.getSortKeys())); } } return new InsertionIds(retVal); }
return new SinglePartitionInsertionIds(tierAndBinId, retVal);
public static SinglePartitionInsertionIds getSingleBinnedInsertionId( final BigInteger rowCount, final byte multiDimensionalId, final BinnedNumericDataset index, final SpaceFillingCurve sfc) { if (rowCount.equals(BigInteger.ONE)) { final byte[] tierAndBinId = ByteArrayUtils.combineArrays(new byte[] {multiDimensionalId}, index.getBinId()); final double[] minValues = index.getMinValuesPerDimension(); final double[] maxValues = index.getMaxValuesPerDimension(); byte[] singleId = null; if (Arrays.equals(maxValues, minValues)) { singleId = sfc.getId(minValues); } else { final byte[] minId = sfc.getId(minValues); final byte[] maxId = sfc.getId(maxValues); if (Arrays.equals(minId, maxId)) { singleId = minId; } } if (singleId != null) { return new SinglePartitionInsertionIds(tierAndBinId, singleId); } } return null; }
new SinglePartitionInsertionIds( ByteArrayUtils.combineArrays( new byte[] {xzCurveMultiDimensionalId},