Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev idtable #4

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6e6e7a5
Influxdb service adapts to distributed MPP framework
Jul 26, 2022
d32c0dc
fix InfluxFirstFunction,InfluxLastFunction,InfluxMeanFunction
Jul 26, 2022
9e24ad1
Merge branch 'apache:master' into influxdb-service-mpp
KeeProMise Jul 26, 2022
ec08137
Create InfluxDB Protocol Test
KeeProMise Jul 27, 2022
e47bb08
Using the '.*' form of import should be avoided
Jul 27, 2022
57da703
Merge remote-tracking branch 'origin/influxdb-service-mpp' into influ…
Jul 27, 2022
19afe30
spotless apply
Jul 28, 2022
34d4642
influxdb mpp test
Jul 28, 2022
21fb41c
Merge remote-tracking branch 'upstream/master' into influxdb-service-mpp
Jul 28, 2022
3485075
influxdb mpp test
Jul 28, 2022
b688c4d
Modified to rely on an AbstractInfluxDBMetaManager
Jul 28, 2022
9ba89db
Merge branch 'apache:master' into new_influxdb_Mpp
KeeProMise Jul 29, 2022
e0241b6
Generate tag timestamps using AtomicLong
Jul 29, 2022
1ef83e8
Merge branch 'apache:master' into new_influxdb_Mpp
KeeProMise Jul 29, 2022
5b94822
Merge remote-tracking branch 'origin/new_influxdb_Mpp' into influxdb-…
Jul 29, 2022
3482ca2
IDtable add getDiskSchemaEntries()
Aug 16, 2022
2a6b394
Merge remote-tracking branch 'upstream/master' into idtable-disk_read
Aug 16, 2022
9845157
IDtable add deleteTimeserie method
Aug 16, 2022
73b8afb
Merge remote-tracking branch 'upstream/master' into idtable-disk_read
Aug 16, 2022
6cf0506
IDtable add deleteTimeserie method
Aug 18, 2022
fff9512
IDtable add deleteTimeserie method
Aug 18, 2022
790de6e
IDtable add deleteTimeserie method
Aug 18, 2022
d82524f
add AutoIncrementDeviceID
Aug 20, 2022
83b2e04
add AutoIncrementDeviceID use idtable
Aug 22, 2022
db56e67
Merge branch 'apache:master' into master
KeeProMise Aug 23, 2022
f350676
StandAloneAutoIncDeviceID use List
Aug 23, 2022
a5e827a
Merge remote-tracking branch 'origin/master' into dev-idtable
Aug 23, 2022
8210f7f
no
Aug 23, 2022
6d43024
Merge remote-tracking branch 'origin/master'
Aug 23, 2022
5d35f3b
Merge remote-tracking branch 'origin/master' into dev-idtable
Aug 23, 2022
876dc69
not use idtable
Aug 23, 2022
9a72ab5
fix:AppendOnlyDiskSchemaManagerTest.recover
Aug 23, 2022
bc0a513
doc fix
Aug 24, 2022
7216153
fix:test error
Aug 24, 2022
709f8a2
add schemaID
Aug 25, 2022
a942209
test error
Aug 25, 2022
bfb843c
delete getAndSetDeviceEntryWithAlignedCheck
Aug 25, 2022
0d42437
merge DeviceIDTest
Aug 25, 2022
62ff923
getandset to getautocreat
Aug 25, 2022
1cfc7c9
add Notes
Aug 25, 2022
07d9676
add INVALID_DEVICE_PATH and deviceIdOfNonExistentDevice
Aug 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.iotdb.db.engine.memtable.IWritableMemChunk;
import org.apache.iotdb.db.engine.memtable.IWritableMemChunkGroup;
import org.apache.iotdb.db.exception.runtime.FlushRunTimeException;
import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;
import org.apache.iotdb.db.rescon.SystemInfo;
import org.apache.iotdb.db.service.metrics.MetricService;
import org.apache.iotdb.db.service.metrics.enums.Metric;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceIDFactory;
import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.utils.ResourceByPathUtils;
import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowNode;
import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertTabletNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;
import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowNode;
import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertTabletNode;
import org.apache.iotdb.db.qp.physical.crud.InsertRowPlan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.iotdb.db.engine.memtable;

import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.apache.iotdb.db.exception.WriteProcessException;
import org.apache.iotdb.db.exception.WriteProcessRejectException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceIDFactory;
import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.path.AlignedPath;
import org.apache.iotdb.db.metadata.utils.ResourceByPathUtils;
import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.metadata.idtable.deviceID.IStatefulDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceIDFactory;
import org.apache.iotdb.db.metadata.idtable.entry.DiskSchemaEntry;
import org.apache.iotdb.db.metadata.idtable.entry.SchemaEntry;
Expand All @@ -38,6 +39,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -148,7 +150,6 @@ public void recover(IDTable idTable) {
try (FileInputStream inputStream = new FileInputStream(dataFile)) {
// read file version
ReadWriteIOUtils.readString(inputStream);

while (inputStream.available() > 0) {
DiskSchemaEntry cur = DiskSchemaEntry.deserialize(inputStream);
if (!cur.deviceID.equals(DiskSchemaEntry.TOMBSTONE)) {
Expand All @@ -158,11 +159,30 @@ public void recover(IDTable idTable) {
TSEncoding.deserialize(cur.encoding),
CompressionType.deserialize(cur.compressor),
loc);
// if the system uses IStatefulDeviceID, need to recover the state of device id
if (IStatefulDeviceID.class.isAssignableFrom(
DeviceIDFactory.getInstance().getDeviceIDClass())) {
IStatefulDeviceID statefulIDeviceID =
(IStatefulDeviceID)
DeviceIDFactory.getInstance()
.getDeviceIDClass()
.getDeclaredConstructor()
.newInstance();
statefulIDeviceID.recover(
cur.seriesKey.substring(
0, cur.seriesKey.length() - cur.measurementName.length() - 1),
cur.deviceID);
}
idTable.putSchemaEntry(cur.deviceID, cur.measurementName, schemaEntry, cur.isAligned);
}
loc += cur.entrySize;
}
} catch (IOException | MetadataException e) {
} catch (IOException
| MetadataException
| IllegalAccessException
| InstantiationException
| NoSuchMethodException
| InvocationTargetException e) {
logger.info("Last entry is incomplete, we will recover as much as we can.");
try {
outputStream.getChannel().truncate(loc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceEntry;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceIDFactory;
import org.apache.iotdb.db.metadata.idtable.entry.DiskSchemaEntry;
import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.SchemaEntry;
import org.apache.iotdb.db.metadata.idtable.entry.TimeseriesID;
import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
Expand Down Expand Up @@ -133,6 +133,7 @@ void updateLastCache(
throws MetadataException;

/** clear id table and close file */
@TestOnly
void clear() throws IOException;

/**
Expand All @@ -143,6 +144,14 @@ void updateLastCache(
*/
DeviceEntry getDeviceEntry(String deviceName);

/**
* get device entry from device id
*
* @param deviceID device id of the device path
* @return device entry
*/
DeviceEntry getDeviceEntry(IDeviceID deviceID);

/**
* get schema from device and measurements
*
Expand All @@ -162,13 +171,13 @@ void updateLastCache(
/**
* put schema entry to id table, currently used in recover
*
* @param devicePath device path (can be device id formed path)
* @param deviceID device id
* @param measurement measurement name
* @param schemaEntry schema entry to put
* @param isAligned is the device aligned
*/
void putSchemaEntry(
String devicePath, String measurement, SchemaEntry schemaEntry, boolean isAligned)
String deviceID, String measurement, SchemaEntry schemaEntry, boolean isAligned)
throws MetadataException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.metadata.DataTypeMismatchException;
import org.apache.iotdb.db.metadata.idtable.deviceID.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.deviceID.StandAloneAutoIncDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceEntry;
import org.apache.iotdb.db.metadata.idtable.entry.DeviceIDFactory;
import org.apache.iotdb.db.metadata.idtable.entry.DiskSchemaEntry;
import org.apache.iotdb.db.metadata.idtable.entry.IDeviceID;
import org.apache.iotdb.db.metadata.idtable.entry.InsertMeasurementMNode;
import org.apache.iotdb.db.metadata.idtable.entry.SchemaEntry;
import org.apache.iotdb.db.metadata.idtable.entry.TimeseriesID;
Expand Down Expand Up @@ -72,6 +73,7 @@ public class IDTableHashmapImpl implements IDTable {

/** disk schema manager to manage disk schema entry */
private IDiskSchemaManager IDiskSchemaManager;

/** iotdb config */
protected static IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();

Expand Down Expand Up @@ -307,10 +309,14 @@ public synchronized void updateLastCache(
}

@Override
@TestOnly
public void clear() throws IOException {
if (IDiskSchemaManager != null) {
IDiskSchemaManager.close();
}
if (DeviceIDFactory.getInstance().getDeviceIDClass() == StandAloneAutoIncDeviceID.class) {
StandAloneAutoIncDeviceID.clear();
}
}

/**
Expand All @@ -321,7 +327,17 @@ public void clear() throws IOException {
*/
@Override
public DeviceEntry getDeviceEntry(String deviceName) {
IDeviceID deviceID = DeviceIDFactory.getInstance().getDeviceID(deviceName);
return getDeviceEntry(DeviceIDFactory.getInstance().getDeviceID(deviceName));
}

/**
* get device entry from deviceID
*
* @param deviceID deviceID of the device path
* @return device entry
*/
@Override
public DeviceEntry getDeviceEntry(IDeviceID deviceID) {
int slot = calculateSlot(deviceID);

// reuse device entry in map
Expand Down Expand Up @@ -355,6 +371,11 @@ public IMeasurementSchema getSeriesSchema(String deviceName, String measurementN
schemaEntry.getCompressionType());
}

/**
* get all useful deviceEntry of idTable
*
* @return device entries
*/
@Override
public List<DeviceEntry> getAllDeviceEntry() {
List<DeviceEntry> res = new ArrayList<>();
Expand All @@ -365,11 +386,20 @@ public List<DeviceEntry> getAllDeviceEntry() {
return res;
}

/**
* put schema entry to id table, currently used in recover
*
* @param deviceID device id
* @param measurement measurement name
* @param schemaEntry schema entry to put
* @param isAligned is the device aligned
* @throws MetadataException
*/
@Override
public void putSchemaEntry(
String devicePath, String measurement, SchemaEntry schemaEntry, boolean isAligned)
String deviceID, String measurement, SchemaEntry schemaEntry, boolean isAligned)
throws MetadataException {
DeviceEntry deviceEntry = getDeviceEntryWithAlignedCheck(devicePath, isAligned);
DeviceEntry deviceEntry = getDeviceEntryWithAlignedCheck(deviceID, isAligned);
deviceEntry.putSchemaEntry(measurement, schemaEntry);
}

Expand Down Expand Up @@ -460,7 +490,7 @@ private IMeasurementMNode getOrCreateMeasurementIfNotExist(
*/
private DeviceEntry getDeviceEntryWithAlignedCheck(String deviceName, boolean isAligned)
throws MetadataException {
IDeviceID deviceID = DeviceIDFactory.getInstance().getDeviceID(deviceName);
IDeviceID deviceID = DeviceIDFactory.getInstance().getDeviceIDWithAutoCreate(deviceName);
int slot = calculateSlot(deviceID);

DeviceEntry deviceEntry = idTables[slot].get(deviceID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.file.SystemFileFactory;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.metadata.PathNotExistException;
import org.apache.iotdb.db.service.IoTDB;
Expand Down Expand Up @@ -127,6 +128,7 @@ public synchronized IMeasurementSchema getSeriesSchema(String deviceName, String
}

/** clear id table map */
@TestOnly
public void clear() throws IOException {
for (IDTable idTable : idTableMap.values()) {
idTable.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iotdb.db.metadata.idtable.entry;
package org.apache.iotdb.db.metadata.idtable.deviceID;

import java.nio.ByteBuffer;

Expand All @@ -29,7 +29,7 @@ public interface IDeviceID {
*
* @return string format device id
*/
public String toStringID();
String toStringID();

public void serialize(ByteBuffer byteBuffer);
void serialize(ByteBuffer byteBuffer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.db.metadata.idtable.deviceID;

/** stateful device id interface */
public interface IStatefulDeviceID extends IDeviceID {

/**
* recover state using devicePath and device id
*
* @param devicePath device path of the time series
* @param deviceID device id
*/
void recover(String devicePath, String deviceID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

package org.apache.iotdb.db.metadata.idtable.entry;
package org.apache.iotdb.db.metadata.idtable.deviceID;

import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.db.metadata.idtable.entry;
package org.apache.iotdb.db.metadata.idtable.deviceID;

import org.apache.iotdb.db.metadata.idtable.IDTable;
import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
Expand Down Expand Up @@ -90,7 +90,7 @@ private void fromSHA256String(String deviceID) {
*
* @param deviceID device path
*/
private void buildSHA256(String deviceID) {
protected void buildSHA256(String deviceID) {
byte[] hashVal;
int slot = calculateSlot(deviceID);

Expand Down
Loading